这篇文章主要介绍怎么使用c++编程实现简单的打字小游戏,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
你是否对键盘熟悉?
“qwertyuiopasdfghjklzxcvbnm”是否已经印在你的脑海里?
NO?
没有关系,今天,让我来帮你对键盘有一个更深一步的了解吧!
#include"stdio.h"
#include"stdlib.h"
#include"windows.h"
#include"conio.h"
void entry_place(int num)
{
for(int i;i<num;i++)
printf(" ");
}
void enter_line(int num)
{
int i;
for(i=0;i<num;i++)
{
printf("\n");
}
}
int main()
{
enter_line(15);
entry_place(40);
printf("press anykey to start");
getchar();
system("cls");
int levels=0,score=0,lines=0,num=0,col=0;
while(1)
{
system("cls");
for(int i=0;i<20;i++)
{
printf(" ");
}
printf("levels:%d",levels);
entry_place(10);
printf("score:%d",score);
printf("\n");
entry_place(20);
printf("1---Pause");
entry_place(9);
printf("0---Exit");
printf("\n");
for(int i=0;i<80;i++)
{
printf("_");
}
enter_line(1);
num=rand()%26;
col=rand()%80;
while(1)
{
lines++;
if(lines>25)
{
lines=0;
score-=10;
if(score<-50)
{
system("cls");
enter_line(15);
entry_place(40);
printf("sorry,you faile!");
getch();
exit(0);
}
break;
}
entry_place(col);
printf("%c",'a'+num);
Sleep(180);
printf("\b \n");
if(kbhit())
{
char c=getch();
if(c=='a'+num)
{
score+=10;
break;
}
}
}
}
return 0;
}
以上是“怎么使用c++编程实现简单的打字小游戏”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。