求一C++小游戏源代码简单点的?!!谢谢

在线等!!
匿名用户    2009-05-24 21:26    

满意回答

#include #include #include #define LEFT 0x4b00 #define RIGHT 0x4d00 #define DOWN 0x5000 #define UP 0x4800 #define ESC 0x011b int i,key; int score=0; int gamespeed=32000; struct Food /*食物的狼毫结构体*/ { int x; /*食物的横叹禁唤坐标*/ int y; /*食物的纵坐标*/ int yes; /*食物是否出现的变量*/ }food; struct Snack /*蛇的结构体*/ { int x; int y; int node; /*蛇的节数*/ int direction; /*蛇的方向*/ int life; /*蛇的生命,0活着,1死亡*/ }snake; void Init(void); /*图形驱动*/ void Close(void); /*关闭游戏函数*/ void DrawK(void); /*画图函数*/ void GameOver(void);/*输出失败函数*/ void GamePlay(); /*游戏控制函数 主要程序*/ void PrScore(void); /*分数纺肆输出函数*/ DELAY(char ch)/*调节游戏速度*/ { if(ch=='3') { delay(gamespeed); /*delay是延迟函数*/ delay(gamespeed); } else if(ch=='2') { delay(gamespeed); } } Menu()/*游戏开始菜单*/ { char ch; printf("Please choose the gamespeed:\n"); printf("1-Fast 2-Normal 3-Slow\n"); printf("\nPlease Press The numbers..\n"); do {ch=getch();} while(ch!='1'&&ch!='2'&&ch!='3'); clrscr(); return(ch); } /*主函数*/ void main(void) { int ch; ch=Menu(); Init(); DrawK(); GamePlay(ch); Close(); } void Init(void) { int gd=DETECT,gm; initgraph(&gd,&gm,"c:\\tc"); cleardevice(); } void DrawK(void) { setcolor(11); setlinestyle(SOLID_LINE,0,THICK_WIDTH); for(i=50;i

匿名用户   2009-05-24 21:36
宝宝知道提示您:回答为网友贡献,仅供参考。

为您推荐:

其他回答

四大经典游戏 贪吃蛇 俄罗斯方块 推箱子 连连看 你自己会写了 就可以写游戏了

匿名用户    2009-05-24 23:28