打字母游戏

#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();
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值