分享
 
 
 

打字游戏

王朝other·作者佚名  2008-06-01
窄屏简体版  字體: |||超大  

#define MAXCOUNT 100

#define FALLSTEP 5

#define SCREENW 60

#define SCREENH 19

#define USERNAME "hmz"

#include <stdio.h>

#include <stdlib.h>

#include <dos.h>

#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;i<x+width;i++)

{

for(j=y;j<y+height;j++)

{

gotoxy(i,j);

textcolor(ScreenColor[i-1][j-1]);

putch(FULLBLOCK);

}

}

}

void PrintFrame(int x,int y,int width,int height,char username[12],int score,int miss)

{

int i;

textcolor(1);

gotoxy(x,y);

putch(201);

for(i=2;i<=width-1;i++)

{

putch(205);

}

putch(187);

for(i=2;i<=height-1;i++)

{

gotoxy(x+width-1,y+i-1);

putch(186);

gotoxy(x,y+i-1);

putch(186);

}

gotoxy(x,y+height-1);

putch(200);

for(i=2;i<=width-1;i++)

{

putch(205);

}

putch(188);

gotoxy(x+2,y+2);

cprintf("Player:");

gotoxy(x+2,y+3);

cprintf("%s",username);

gotoxy(x+2,y+5);

cprintf("Score:%d",score);

gotoxy(x+2,y+8);

cprintf("Miss:%d",miss);

}

void PrintValue(int x,int y,int score,int miss)

{

gotoxy(x+2,y+6);

printf("%3d",score);

gotoxy(x+2,y+9);

printf("%3d",miss);

}

void PrintLine(int x,int y,int width,int height)

{

int i;

gotoxy(x,y);

textcolor(11);

putch(201);

for(i=2;i<=width-1;i++)

putch(205);

putch(187);

for(i=2;i<=height-1;i++)

{

gotoxy(x+width-1,y+i-1);

putch(186);

gotoxy(x,y+i-1);

putch(186);

}

gotoxy(x,y+height-1);

putch(200);

for(i=2;i<=width-1;i++)

putch(205);

putch(188);

}

void AlphabitColor(int index,int x,int y)

{

int i,j,c;

if(index<0 index>25 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;i<number;i++)

{

x=rand()%55+1;

y=rand()%18+1;

c=rand()%15+1;

g=rand()%5;

textcolor(c);

for(j=0;j<5;j++)

for(k=0;k<8;k++)

if(pic[g][j][k]==1)

{

gotoxy(k+x,j+y);

ScreenColor[k+x-1][j+y-1]=c;

putch(FULLBLOCK);

}

}

}

void PrintAlphabitFade(int index,int x,int y)

{ /* index 0-6 means alphabit a-f */

int i,j,l;

char c[7]={FULLBLOCK,'','-','\','/','.',' '};

if(index<0 index>25 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(count<MAXCOUNT)

{

x[count]=rand()%SCREENW+1;

y[count]=2;

c[count]=rand()%26;

p[count]=rand()%15+1;

count++;

}

}

for(i=0;i<count;i++)

RecoverArea(x[i],y[i],5,5,ScreenColor);

for(i=0;i<count;i++)

{

y[i]++;

if(y[i]>SCREENH)

{

ShowLose(x[i],y[i],c[i]);

for(j=i+1;j<count;j++)

{

x[j-1]=x[j];

y[j-1]=y[j];

c[j-1]=c[j];

score-=5;

miss++;

}

count--;

i--;

}

}

for(i=0;i<count;i++)

PrintAlphabit (c[i],x[i],y[i],p[i]);

for(t=0;t<100;t++)

{

if(bioskey(1))

{

presskey=bioskey(0);

for(i=0;i<count;i++)

{

if(presskey=='a'+c[i] presskey=='A'+c[i])

{

ShowWin(x[i],y[i],c[i]);

for(j=i+1;j<count;j++)

{

x[j-1]=x[j];

y[j-1]=y[j];

c[j-1]=c[j];

}

score+=10;

count--;

break; /* exit i-loop */

}

else

{

&n

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有