问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

求:c++ 打字游戏源代码

发布网友 发布时间:2024-03-25 13:08

我来回答

3个回答

热心网友 时间:2024-03-31 21:21

#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

热心网友 时间:2024-03-31 21:16

到csdn找找看

热心网友 时间:2024-03-31 21:19

晕死了,这个代码很长的,以前同学还编出来,可惜自己没记。回去问问看
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
怀孕四个月补钙可以吗 孕妇吃什么时候钙片好 孕妇吃什么钙片最好 怀孕补钙是必须的吗?孕妇钙片品牌哪个好? ...在长高的黄金发育时期,会影响容貌五官的变化吗,不仅没有发育到变... 冬至吃饺子的诗词 立冬吃饺子的暖心诗词 宁波全封闭学校有哪些 宁波市北仑区小港镇会计学校在那? 或红联镇也可以 江南教育集团小港中心幼儿园园况介绍 红联哪里有报暑假班 烟草专卖局不给予办理烟证,要用什么办法才能办理 烟草公司说我没有地民办的证明不给办烟草证怎么办 在父母面前飙了脏话,该如何自我拯救 安徽省阜阳市阜南县联通营业厅几点下班啊 家里有只比熊在养一只什么犬好相处 安徽省阜阳市颍州区九龙镇联通营业厅1 12月23日流星雨几点2 今年4月23日有流星雨吗??8 23号还有流星雨吗?6 2019年12月23日是下雨天,会不会有流星雨? 声音是由物体___产生的,日常生活中,我们常说的“震耳欲聋”,是指声音... 怎么用younger造一个句子? oppo手表怎么和手机配对 FC忍者神龟对打出招表1810 四边形对角一定互补吗 求&lt;超人前传&gt;里所有的插曲??5 工会组织应当什么用人单位开展职业卫生宣传教育和培训 接订阅号给单人发消息和群发消息有不一样的显示吗 一部外国电影,是讲监狱足球比赛的。速求??1 zippo黑兔子怎么样 福州六中分数线是多少? 标题 首次途中导游与参观游览服务中的沿途导游有什么不同? 冬天水养观音竹叶子都黄了什么原因 你永远不懂我这首歌是什么时候写的? WOW 变身牛头人是怎么弄得啊,变身的时候还会叫一句:“你们几个,去看看... 为什么语音通话时间和现实时间查那么多 英国,法国,德国,西班牙,意大利,军事实力排个名~谢谢? 你不懂我对你的爱句子 12123可以处理首违免罚吗 12123首次违章免罚怎么操作 扁桃体发炎,引起感冒了,一直流鼻涕,现在感冒要好了,可是体内的火气很重... 怎么分辨和田玉是不是翡翠分辨和田玉是不是翡翠方法 中国联通(颍河西路营业厅)在哪,怎么走 安徽省阜阳市颍泉去胜利南路二轻局家属院的宽带是光纤吗 安徽 阜阳 临沂商城 属于哪一个街道? 邮编多少?6 我家是阜阳颍泉的,谁知道我家有哪家运营商的3G网络覆盖? 阜阳颍泉区泉颖小学附近,想要办个10兆的宽带。。有没有什么宽... 阜阳市颍州区有多少个乡镇?1 过氧化氢是一种很弱的酸,酸性比碳酸还要弱,为了验证其酸性,请选择一种... 为什么H2O2被还原一定转移2mol电子?