用C语言实现的打字游戏,C语言实现的打字游戏(模块化)

#include

#include

#include

#include //insert a counter for the game times(Not done)

#include

int mode2(double n);

int mode3();

int randome();

int start(double n);

int honor(int n);

int title();

int title1();

int title2();

int title3();

int titleend();

double rank(double n);

int judge = 0; //choose the rank of game difficulty (I recommend you the '10' to start)

int count = 0;

int main(void)

{

int mode;

int letter_number;

int Readscanf=0;

char chs;

double grank;

title();

title1();

title2();

title3();

titleend();

printf("This is a game to train your typing ability!\n");

flag1:

if (judge == 2)

{

title();

title1();

title2();

title3();

titleend();

}

printf("Please select the mode of game(1 , 2 or 3)\n");

if (Readscanf == 1)

{

while ('\n' != getchar())

{

continue;

}

}

Readscanf = scanf("%d", &mode);

switch (mode)

{

case 1: //mode1

while (judge != 1)

{

system("cls");

title();

title1();

titleend();

printf("Please select your game difficulty.\n(Enter a positive number,and i recommend you the \"10\" to start)\n");

Readscanf = (scanf("%lf", &grank));

flag3:

if (Readscanf == 1 && grank > 0)

{

grank = start(grank); //倒计时

title();

title1();

titleend();

//一个字符的下落

for ( letter_number = 0; letter_number < 10; letter_number++) //下落10个字母

{

int alphas, space, t, i;

srand((unsigned)time(NULL));

alphas = 1 + rand() % 26;

Sleep(1000);

srand((unsigned)time(NULL));

space = 1 + rand() % 26;

char ch;

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

{

if (kbhit())

{

ch = getch();

if (ch == alphas + 96) //判断对错的语句,不然输错误的字母也会跳到下一个字母

{

count++; //计数

break;

}

}

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

{

printf(" ");

}

printf("%c", alphas + 96);

printf(" ");

Sleep(grank);

printf("\b\b\b\b\b\b\b\b\b\b\b \n");

}

system("cls");

title();

title1();

titleend();

}

}

else

{

while ('\n' != getchar())

{

continue;

}

printf("Please enter a positive number!\n");

Readscanf = (scanf("%lf", &grank));

goto flag3; //flag3:用户输入难度

}

judge = 1;

}

break;

case 2: //mode2

printf("Please select your game difficulty.\n(Enter a positive number,and i recommend you the \"10\" to start)\n");

Readscanf = (scanf("%lf", &grank));

grank = start(grank);

title();

title2();

titleend();

count = mode2(grank);

break;

case 3:

mode3();

goto flag2;

break;

defau

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值