#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