蛇吃蛋
2008-03-08 12:26:19 来源:WEB开发网核心提示:#include "graphics.h"#include "stdio.h"#define MAX 200#define MAXX 30#define MAXY 30#define UP 18432#define DOWN 20480#define LEFT 1920
} setfillstyle(1,4); bar(babyx*15+1,babyy*10+1,babyx*15+14,babyy*10+9); setcolor(8); setfillstyle(1,8); bar(place[head].x*15+1,place[head].y*10+1,place[head].x*15+14,place[head].y*10+9); /* for( i = 0; i <= MAXX; i++ ) line( i*15,0, i*15, 10*MAXY); for( j = 0; j <= MAXY; j++ ) line( 0, j*10, 15*MAXX, j*10); */ rectangle(0,0,15*MAXX,10*MAXY); sPRintf(temp,"Count: %d",count); settextstyle(1,0,2); setcolor(8); outtextxy(512,142,temp); setcolor(11); outtextxy(510,140,temp); sprintf(temp,"1P: %d",score); settextstyle(1,0,2); setcolor(8); outtextxy(512,102,temp); setcolor(12); outtextxy(510,100,temp); sprintf(temp,"Class: %d",class); setcolor(8); outtextxy(512,182,temp); setcolor(11); outtextxy(510,180,temp); } main() { int pause = 0; char temp[50]; int d,m; int key; int p; static int keydown = FALSE; int exit = FALSE; int stchange = 0; d = VGA; m = VGAMED; initgraph( &d, &m, "" ); setbkcolor(3); class = 3; init(); p = 1; while(!exit) { if (kbhit()) { key = bioskey(0); switch(key) { case UP: if( (control != 2)&& !keydown) control = 1; keydown = TRUE; break; case DOWN: if( (control != 1)&& !keydown) control = 2; keydown = TRUE; break; case LEFT: if( (control != 4)&& !keydown) control = 3; keydown = TRUE; break; case RIGHT: if( (control != 3)&& !keydown) control = 4; keydown = TRUE; break; case ESC: exit = TRUE;break; case ENTER: init();break; case PAGEUP: class --; if (class<0) class = 0; break; case PAGEDOWN: class ++;if (class>7) class = 7; break; case KEY_U: if( ( (control ==1) (control ==2))&& !keydown) control = 3; else if(( (control == 3) (control == 4))&& !keydown) control = 1; keydown = TRUE; break; case KEY_K: if( ( (control ==1) (control ==2))&& !keydown) control = 4; else if(( (control == 3) (control == 4))&& !keydown) control = 2; keydown = TRUE; break; case CTRL_P:pause = 1 - pause; break; } } stchange ++ ; putpixel(0,0,0); if (stchange > gamedelay[class] + gamedelay2[hit]) { stchange = 0; keydown = FALSE; p = 1 - p; setactivepage(p); cleardevice(); if (!pause) nextstatus(); else { settextstyle(1,0,4); setcolor(12); outtextxy(250,100,"PAUSE"); } draw(); if(game==GAMEOVER) { settextstyle(0,0,6); setcolor(8); outtextxy(101,101,"GAME OVER"); setcolor(15); outtextxy(99,99,"GAME OVER"); setcolor(12); outtextxy(100,100,"GAME OVER"); sprintf(temp,"Last Count: %d",count); settextstyle(0,0,2); outtextxy(200,200,temp); } if(game==GAMEHAPPY) { settextstyle(0,0,6); setcolor(12); outtextxy(100,300,"YOU WIN"); sprintf(temp,"Last Count: %d",count); settextstyle(0,0,2); outtextxy(200,200,temp);
} setvisualpage(p); } } closegraph(); }
- ››蛇吃蛋
- 中查找“蛇吃蛋”更多相关内容
- 中查找“蛇吃蛋”更多相关内容
- 上一篇:如何学好C
- 下一篇:骑士漫游和八皇后
更多精彩
赞助商链接