initgraph(&gd,&gm,"c:\\tc");cleardevice();} /*开始画面,左上角坐标为(50,40),右下角坐标为(610,460)的围墙*/ void DrawK(void){ /*setbkcolor(LIGHTGREEN);*/ setcolor(11);setlinestyle(SOLID_LINE,0,THICK_WIDTH);/*设置线型*/ for(i=50;i<=600;i+=10)/*画围墙*/ {...
printf("%c", GameMap[i][j]);printf("\n");} printf("\n小小C语言贪吃蛇\n");printf("按任意方向键开始游戏\n");getch(); //先接受一个按键,使蛇开始往该方向走 Button(); //取出按键,并判断方向 } void Create_Food() //在地图上随机产生食物 { int fx, fy;while(1){...
以下是代码 /* 贪吃蛇程序 by champking */#define N 200#include <graphics.h>#include <stdlib.h>#include <dos.h>#define LEFT 0x4b00#define RIGHT 0x4d00#define DOWN 0x5000#define UP 0x4800#define ESC 0x011bint i,key;int score = 0;/*得分*/int gamespeed = 100000;/*游戏...
void gotoxy(int x, int y)
include <windows.h> define BEG_X2 define BEG_Y1 define WID20 define HEI20 HANDLE hout;typedef enum {UP, DOWN, LEFT, RIGHT} DIR;typedef struct Snake_body { COORD pos;//蛇身的位置 struct Snake_body *next;//下一个蛇身 struct Snake_body *prev;//前一个蛇身 }SNAKE, *PSNAKE;...
include /*引用的库函数*/ define LEFT 0x4b00 define RIGHT 0x4d00 define DOWN 0x5000 define UP 0x4800 define ESC 0x011b/*宏定义键名*/ define N 200 int i,key;int level;/*游戏等级*/ int score=0;/*得分*/ int gamespeed;/*游戏速度*/ struct Food { int x;/*食物的横...
include<conio.h> typedef struct snake { int a;int b;struct snake *u;struct snake *n;}snake,*snake1;typedef struct food { int a;int b;}food;void main(){ char c,c0 = 'd';int i,j,k,n=1,t,at;snake p,q;snake *dd,*dd0,*dd1,*dd2;food f;srand(time(NULL));...
贪吃蛇的源代码#include<stdio.h>#include<stdlib.h>#include#include<conio.h>typedef struct snake{ int a; int b; struct snake *u; struct snake *n;}snake,*snake1;typedef struct food{ int a; int b;}food;void main(){ char c,c0 = 'd'; int i,j,k,n=1,t,at; snake p,q; snake...
int line; //行数 int count; //蛇身长度 vector<vector<char> > snakeMap;//整个游戏界面 queue<Cmp> snakeBody; //蛇身 public:int GetDirections()const;char getSymbol(const Cmp& c)const //获取指定坐标点上的字符 { return snakeMap[c.lSign][c.rSign];} Csnake(int n)//初始化...