当前位置:   article > 正文

biteself在c语言,dev-c++中的c语言游戏代码是什么?

dvec++游戏代码最少

满意答案

00e27ab806e4881f8254fe7ae8741834.png

leemcuypil

推荐于 2019.10.16

00e27ab806e4881f8254fe7ae8741834.png

采纳率:45%    等级:12

已帮助:4660人

#include

#include

#include

#include

#define U 1

#define D 2

#define L 3

#define R 4 //蛇的状态,U:上 ;D:下;L:左 R:右

typedef struct SNAKE { //蛇身的一个节点

int x;

int y;

struct SNAKE *next;

} snake;

//全局变量//

int score=0,add=10;//总得分与每次吃食物得分。

int status,sleeptime=200;//每次运行的时间间隔

snake *head, *food;//蛇头指针,食物指针

snake *q;//遍历蛇的时候用到的指针

int endgamestatus=0; //游戏结束的情况,1:撞到墙;2:咬到自己;3:主动退出游戏。

//声明全部函数//

void Pos();

void creatMap();

void initsnake();

int biteself();

void createfood();

void cantcrosswall();

void snakemove();

void pause();

void gamecircle();

void welcometogame();

void endgame();

void gamestart();

void Pos(int x,int y)//设置光标位置

{

COORD pos;

HANDLE hOutput;

pos.X=x;

pos.Y=y;

hOutput=GetStdHandle(STD_OUTPUT_HANDLE);

SetConsoleCursorPosition(hOutput,pos);

}

void creatMap()//创建地图

{

int i;

for(i=0; i<58; i+=2) { //打印上下边框

Pos(i,0);

printf("■");

Pos(i,26);

printf("■");

}

for(i=1; i<26; i++) { //打印左右边框

Pos(0,i);

printf("■");

Pos(56,i);

printf("■");

}

}

void initsnake()//初始化蛇身

{

snake *tail;

int i;

tail=(snake*)malloc(sizeof(snake));//从蛇尾开始,头插法ÿ

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/繁依Fanyi0/article/detail/396519
推荐阅读
相关标签
  

闽ICP备14008679号