C语言——打字游戏
#define MAXCOUNT 100
#define FALLSTEP 5
#define SCREENW 60
#define SCREENH 19
#define USERNAME "hmz"
#include
#include
#include
#define FULLBLOCK 219
int Alphabit[26][5][5]={0,0,1,0,0,
0,1,0,1,0,
1,1,1,1,1,
1,0,0,0,1,
1,0,0,0,1, /* A */
1,1,1,1,0,
1,0,0,0,1,
1,1,1,1,0,
1,0,0,0,1,
1,1,1,1,1, /* B */
0,1,1,1,0,
1,0,0,0,1,
1,0,0,0,0,
1,0,0,0,1,
0,1,1,1,0, /* C */
1,1,1,1,0,
1,0,0,0,1,
1,0,0,0,1,
1,0,0,0,1,
1,1,1,1,0, /* D */
1,1,1,1,1,
1,0,0,0,0,
1,1,1,1,0,
1,0,0,0,0,
1,1,1,1,1, /* E */
1,1,1,1,1,
1,0,0,0,0,
1,1,1,1,0,
1,0,0,0,0,
1,0,0,0,0, /* F */
0,1,1,1,0,
1,0,0,0,0,
1,0,1,1,0,
1,0,0,1,0,
0,1,1,1,0, /* G */
1,0,0,0,1,
1,0,0,0,1,
1,1,1,1,1,
1,0,0,0,1,
1,0,0,0,1, /* H */
0,1,1,1,0,
0,0,1,0,0,
0,0,1,0,0,
0,0,1,0,0,
0,1,1,1,0, /* I */
0,1,1,1,0,
0,0,1,0,0,
0,0,1,0,0,
1,0,1,0,0,
0,1,0,0,0, /* J */
1,0,0,1,0,
1,0,1,0,0,
1,1,0,0,0,
1,0,1,0,0,
1,0,0,1,0, /* K */
1,0,0,0,0,
1,0,0,0,0,
1,0,0,0,0,
1,0,0,0,0,
1,1,1,1,0, /* L */
0,1,0,1,0,
1,0,1,0,1,
1,0,1,0,1,
1,0,1,0,1,
1,0,1,0,1, /* M */
1,0,0,0,1,
1,1,0,0,1,
1,0,1,0,1,
1,0,0,1,1,
1,0,0,0,1, /* N */
0,1,1,1,0,
1,0,0,0,1,
1,0,0,0,1,
1,0,0,0,1,
0,1,1,1,0, /* O */
0,1,1,1,0,
1,0,0,0,1,
1,1,1,1,0,
1,0,0,0,0,
1,0,0,0,0, /* P */
0,1,1,1,0,
1,0,0,0,1,
1,0,0,0,1,
0,1,1,1,0,
0,0,0,0,1, /* Q */
0,1,1,1,0,
1,0,0,0,1,
1,1,1,1,0,
1,0,1,0,0,
1,0,0,1,0, /* R */
0,0,1,1,0,
0,1,0,0,1,
0,0,1,0,0,
0,1,0,1,0,
0,0,1,1,0, /* S */
1,1,1,1,1,
0,0,1,0,0,
0,0,1,0,0,
0,0,1,0,0,
0,0,1,0,0, /* T */
1,0,0,0,1,
1,0,0,0,1,
1,0,0,0,1,
1,0,0,0,1,
0,1,1,1,0, /* U */
1,0,0,0,1,
1,0,0,0,1,
1,0,0,0,1,
0,1,0,1,0,
0,0,1,0,0, /* V */
1,0,0,0,1,
1,0,0,0,1,
1,0,1,0,1,
0,1,0,1,1,
1,0,0,0,1, /* W */
1,0,0,0,1,
0,1,0,1,0,
0,0,1,0,0,
0,1,0,1,0,
1,0,0,0,1, /* X */
1,0,0,0,1,
0,1,0,1,0,
0,0,1,0,0,
0,0,1,0,0,
0,0,1,0,0, /* Y */
1,1,1,1,1,
0,0,0,1,0,
0,0,1,0,0,
0,1,0,0,0,
1,1,1,1,1, /* Z */};
void RecoverArea(int x,int y,int width,int height,int ScreenColor[80][24])
{
int i,j;
for(i=x;i25 || x<1 || x>76 || y<1 || y>20)
return;
for(c=1;c<16;c++)
{
textcolor(c);
for(i=0;i<5;i++)
{
for(j=0;j<5;j++)
{
if(Alphabit[index][j][i])
{
gotoxy(x+i,y+j);
putch(FULLBLOCK);
}
if(Alphabit[index][j][i])
{
gotoxy(x+i,y+j);
putch(32);
}
}
}
delay(8000);
}
}
void AlphabitRotate(int index,int x,int y) {
int i,j,aa,bb,ScreenColor;
if(index<0 || index>25 || x<1 || x>76 || y<1 || y>20)
return;
RecoverArea(x,y,5,5,ScreenColor);
for(i=0;i<5;i++)
for(j=0;j<5;j++)
{
if(Alphabit[index][i][j])
{
gotoxy(x+i,y+j);
putch(FULLBLOCK);
}
}
delay(6000);
RecoverArea(x,y,5,5,ScreenColor);
for(i=0;i<5;i++)
for(j=0;j<5;j++)
{
if(Alphabit[index][j][i])
{
gotoxy(x+i,y+j);
putch(FULLBLOCK);
}
}
delay(6000);
RecoverArea(x,y,5,5,ScreenColor);
for(i=0;i<5;i++)
for(j=0;j<5;j++)
{
if(Alphabit[index][4-i][4-j])
{
gotoxy(x+i,y+j);
putch(FULLBLOCK);
}
}
delay(6000);
RecoverArea(x,y,5,5,ScreenColor);
for(i=0;i<5;i++)
for(j=0;j<5;j++)
{
if(Alphabit[index][4-j][4-i])
{
gotoxy(x+i,y+j);
putch(FULLBLOCK);
}
}
delay(6000);
RecoverArea(x,y,5,5,ScreenColor); }
void ShowFace(int x,int y,int a)
{
char s[3][9][15]={ " _______ ",
" / \\ ",
" | O O | ",
" | . | ",
" | \\___/ | ",
" \\_______/ ",
" |---------| ",
" | GOOD! | ",
" |---------| ",
" _______ ",
" / \\ ",
" | o o | ",
" | ^ | ",
" | --- | ",
" \\_______/ ",
" |---------| ",
" | HURRY!! | ",
" |---------| ",
" _______ ",
" / \\ ",
" | _ _ | ",
" | . | ",
" | /\\ | ",
" \\_______/ ",
" |---------| ",
" | Oh no! | ",
" |---------| ", };
int i,j;
if(a<0 || a>=3)
return;
textcolor(13);
for(i=0;i<9;i++)
{
gotoxy(x,y+i);
for(j=0;j<15;j++)
putch(s[a][i][j]);
}
}
void RandomBackground(int number,int ScreenColor[80][24]) {
int i,j,k,c,x,y,g;
int pic[5][5][8]={0,0,1,0,0,0,0,0,
0,1,0,1,1,1,1,0,
1,0,0,0,0,0,0,1,
0,1,1,1,1,1,0,1,
0,0,0,0,0,0,1,0,
0,0,1,1,0,0,0,0,
0,1,0,0,1,1,1,0,
1,0,0,0,0,0,0,1,
0,1,1,1,1,1,1,0,
0,0,0,0,0,0,0,0, /* No 2:a small '+' */
0,0,0,0,0,0,0,0,
0,1,1,1,1,1,1,0,
1,0,0,0,0,0,0,1,
0,1,0,1,0,1,1,0,
0,0,1,0,1,0,0,0, /* No 3 */
0,0,0,1,1,0,0,0,
0,1,1,0,0,1,1,0,
1,0,0,0,0,0,1,0,
0,1,1,1,1,1,1,0,
0,0,0,0,0,0,0,0, /* No 4 */
0,0,0,0,0,1,0,0,
0,1,1,1,1,0,1,0,
1,0,0,0,0,0,0,1,
0,1,1,1,1,0,1,0,
0,0,0,0,0,1,0,0 /* No 5 */};
for(i=1;i<80;i++)
for(j=0;j<25;j++)
ScreenColor[i][j]=0;
for(i=0;i25 || x<1 || x>76 || y<1 || y>20)
return;
for(l=0;l<7;l++)
{
for(i=0;i<5;i++)
for(j=0;j<5;j++)
{
if(Alphabit[index][j][i])
{
gotoxy(x+i,y+j);
putch(c[l]);
}
}
delay(100000);
}
}
void PrintAlphabit(int index,int x,int y,int p)
{ /* index 0-6 means alphabit a-f */
int i,j;
if(index<0 || index>25 || x<1 || x>76 || y<1 || y>20)
return;
for(i=0;i<5;i++)
for(j=0;j<5;j++)
if(Alphabit[index][j][i])
{
textcolor(p);
gotoxy(x+i,y+j);
putch(FULLBLOCK);
}
}
void ShowLose(int x,int y,int q) {
sound(622);
delay(3000);
nosound();
gotoxy(x,y);
putch(' ');
ShowFace(65,14,2);
AlphabitColor(q,x,y); }
void ShowWin(int x,int y,int q) {
sound(3000);
delay(2000);
nosound();
sound(2400);
delay(2000);
nosound();
gotoxy(x,y);
putch(' ');
PrintAlphabitFade(q,x,y);
ShowFace(65,14,0);
}
main()
{
int x[MAXCOUNT],y[MAXCOUNT],c[MAXCOUNT],p[MAXCOUNT];
char presskey;
int count=0;
int step=0,despeed=0;
int i,j,t,a,score=0,miss=0;
int ScreenColor[80][24];
clrscr();
RandomBackground(10,ScreenColor);
PrintLine(1,1,80,24);
randomize();
while(1)
{
step++;
PrintFrame(66,1,14,12,USERNAME,score,miss);
PrintValue(66,1,score,miss);
if(step==FALLSTEP)
{
step=0;
if(countSCREENH)
{
ShowLose(x[i],y[i],c[i]);
for(j=i+1;j=20)
ShowFace(65,14,1);
if(miss>=50)
{
clrscr();
getch();
gotoxy(10,40);
printf("Game is over !");
getch();
exit(1);
}
despeed+=20;
if(despeed>2000)
despeed=0;
if(2000-despeed < 1500 && miss==0)
score+=100;
}
}
本文档为【C语言——打字游戏】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。