#include<easyx.h>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<time.h>
#pragma comment(lib,"winmm.lib")
IMAGE img,img1;
void Welcome();
void PlayGame();
int main()
{
initgraph(700,448);
Welcome();
PlayGame();
return 0;
}
void Welcome()
{
srand((unsigned)time(NULL));
mciSendString("open attheage.mp3",0, 0, 0);
mciSendString("play attheage.mp3", 0, 0, 0);
mciSendString("repeat attheage.mp3", 0, 0, 0);
loadimage(&img, "kj.jpg",0,0);
loadimage(&img1, "mn.jpg", 0, 0);
putimage(0, 0, &img);
setbkmode(0);
settextcolor(RED);
settextstyle(50, 0,"华文彩云");
outtextxy(200, 30,"打字练习系统");
settextcolor(WHITE);
settextstyle(18, 0, "宋体");
outtextxy(100,200,"潭州教育");
outtextxy(100, 250, "vip初级案例");
outtextxy(100, 300, "版本1.0");
outtextxy(100, 350, "欢迎修改");
int colorR = 255;
int colorG = 0;
int n = 1;
while (!_kbhit())
{
settextcolor(RGB(colorR, colorG, 88));
outtextxy(350, 380, "按任意键继续...");
colorR -= n;
colorG += n;
if (colorR <= 0 || colorR >= 255)
{
n = -n;
}
Sleep(10);
}
getchar();
}
void PlayGame()
{
cleardevice();
settextstyle(28, 0, "Snap ITC");
settextcolor(GREEN);
char tagLetter;
char keyLetter;
int tagX, tagY;
while (1)
{
tagLetter = rand() % 26 + 'A';
tagX = (rand() % 670)+1;
for (tagY = 0; tagY < 480; tagY++)
{
BeginBatchDraw();
cleardevice();
outtextxy(tagX, tagY, tagLetter);
EndBatchDraw();
if (_kbhit())
{
keyLetter = _getch();
if (keyLetter == tagLetter)
{
putimage(tagX, tagY, &img1);
Sleep(100);
break;
}
}
Sleep(3);
}
}
getchar();
}