网上有关雀神广东麻将微信挂教你下载(详细开挂教程)

06-21 36阅读

网上有关“怎么用编程做贪吃蛇”话题很是火热,小编也是针对怎么用编程做贪吃蛇寻找了一些与之相关的一些信息进行分析,如果能碰巧解决你现在面临的问题,希望能够帮助到您。

您好:手机麻将有挂是真的吗这款游戏可以开挂,确实是有挂的,咨询加微信【】很多玩家在这款游戏中打牌都会发现很多用户的牌特别好,总是好牌,而且好像能看到其他人的牌一样。所以很多小伙伴就怀疑这款游戏是不是有挂,实际上这款游戏确实是有挂的
http://www.boyicom.net/sheng/1.jpg
1.手机麻将有挂是真的吗这款游戏可以开挂,确实是有挂的,通过添加客服微信 2.咨询软件加微信【】在"设置DD功能DD微信手麻工具"里.点击"开启". 3.打开工具.在"设置DD新消息提醒"里.前两个选项"设置"和"连接软件"均勾选"开启"(好多人就是这一步忘记做了) 4.打开某一个微信组.点击右上角.往下拉."消息免打扰"选项.勾选"关闭"(也就是要把"群消息的提示保持在开启"的状态.这样才能触系统发底层接口)

#include<bits/stdc++.h>

#include<stdlib.h>

#include<dos.h>

#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[N];

int y[N];

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是延迟函数*/

}

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<=600;i+=10)

{

rectangle(i,40,i+10,49); /*画出上边框*/

rectangle(i,451,i+10,460); /*画出下边框*/

}

for(i=40;i<=450;i+=10)

{

rectangle(50,i,59,i+10); /*画出左边框*/

rectangle(601,i,610,i+10); /*画出右边框*/

}

}

void GamePlay(char ch)

{

randomize(); /*随机数发生器*/

food.yes=1; /*1代表要出现食物,0表示以存在食物*/

snake.life=0;

snake.direction=1;

snake.x[0]=100;snake.y[0]=100;

snake.x[1]=110;snake.y[1]=100;

snake.node=2;

PrScore();

while(1) /*可以重复游戏*/

{

while(!kbhit()) /*在没有按键的情况下蛇自己移动*/

{

if(food.yes==1) /*需要食物*/

{

food.x=rand()%400+60;

food.y=rand()%350+60; /*使用rand函数随机产生食物坐标*/

while(food.x%10!=0)

food.x++;

while(food.y%10!=0)

food.y++; /*判断食物是否出现在整格里*/

food.yes=0; /*现在有食物了*/

}

if(food.yes==0) /*有食物了就要显示出来*/

{

setcolor(GREEN);

rectangle(food.x,food.y,food.x+10,food.y-10);

}

for(i=snake.node-1;i>0;i--) /*贪吃蛇的移动算法*/

{

snake.x[i]=snake.x[i-1];

snake.y[i]=snake.y[i-1]; /*贪吃蛇的身体移动算法*/

}

switch(snake.direction) /*贪吃蛇的头部移动算法,以此来控制移动*/

{

case 1:snake.x[0]+=10;break;

case 2:snake.x[0]-=10;break;

case 3:snake.y[0]-=10;break;

case 4:snake.y[0]+=10;break;

}

for(i=3;i<snake.node;i++) /*判断是否头部与身体相撞*/

{

if(snake.x[i]==snake.x[0]&&snake.y[i]==snake.y[0])

{

GameOver();

snake.life=1;

break;

}

}

/*下面是判断是否撞到墙壁*/

if(snake.x[0]<55||snake.x[0]>595||snake.y[0]<55||snake.y[0]>455)

{

GameOver();

snake.life=1;

}

if(snake.life==1) /*如果死亡就退出循环*/

break;

if(snake.x[0]==food.x&&snake.y[0]==food.y) /*判断蛇是否吃到食物*/

{

setcolor(0);

rectangle(food.x,food.y,food.x+10,food.y-10); /*吃的食物后用黑色将食物擦去*/

snake.x[snake.node]=-20;snake.y[snake.node]=-20; /*现把增加的一节放到看不到的地方去*/

snake.node++;

food.yes=1;

score+=10;

PrScore();

}

setcolor(4); /*每次移动后将后面的身体擦去*/

for(i=0;i<snake.node;i++)

rectangle(snake.x[i],snake.y[i],snake.x[i]+10,snake.y[i]-10);

delay(gamespeed);

DELAY(ch);

setcolor(0);

rectangle(snake.x[snake.node-1],snake.y[snake.node-1],snake.x[snake.node-1]+10,snake.y[snake.node-1]-10);

}

if(snake.life==1)

break;

key=bioskey(0); /*接受按键*/

if(key==ESC)

break;

else

if(key==UP&&snake.direction!=4)/*判断是否改变方向*/

snake.direction=3;

else

if(key==RIGHT&&snake.direction!=2)

snake.direction=1;

else

if(key==LEFT&&snake.direction!=1)

snake.direction=2;

else

if(key==DOWN&&snake.direction!=3)

snake.direction=4;

}

}

void GameOver(void)

{

cleardevice();

setcolor(RED);

settextstyle(0,0,4);

outtextxy(200,200,"GAME OVER");

getch();

}

void PrScore(void)

{

char str[10];

setfillstyle(SOLID_FILL,YELLOW);

bar(50,15,220,35);

setcolor(6);

settextstyle(0,0,2);

sprintf(str,"scord:%d",score);

outtextxy(55,20,str);

}

void Close(void)

{

getch();

closegraph();

}

c语言编贪吃蛇,用什么编译环境,怎么显示贪吃蛇和水果,怎么键盘响应?我菜鸟都不算,求指教。

单纯学C你是写不出图形程序的,你可以看到,C标准库支持的是dos程序,就是那个黑不溜秋的东西。

如果想知道你离小游戏还多远,咱们可以这么算一下,下面给出几个假设条件:

提供给你图形绘制函数,你只需要传相应的参数,就能画出图形,点,线,圆,颜色填充之类。

给出线程函数,让你可以创建系统线程,或者使用定时器等控制贪吃蛇身体的移动。具体的方式可以变,你需要一个按照固定时间间隔来移动蛇身的函数。

那你觉着,你该怎样写一个贪吃蛇?

思路是:

使用链表等结构,存储蛇的身体,好处就是,可以任意长度。你要想好链表中存储什么属性可以更好地描述蛇的状态,它超哪个方向走,它的身体各个节点处于哪个位置。

划分屏幕坐标系,将贪吃蛇映射为坐标系中的点。

写出碰撞检测函数,贪吃蛇碰到了一个食物,就在链表头部添加一个节点并将头结点更新为这个结点。

使用碰撞检测函数检测贪吃蛇是否撞到了自己。

检测蛇是否撞到了屏幕边界。

使用线程或定时器沿着一个方向移动你的贪吃蛇,移动规律是朝着当前链表头部冲的方向匀速移动,你可以设定0.5s对表头的x/y坐标进行加,减。时间间隔影响了蛇的速度,如果允许长度超过一个程度升级加速,你就要设置下这里的参数。

根据表头的移动,设计算法计算蛇的身体各个点的移动轨迹。这个是关键,这个算法想错了,你的蛇就会乱跑。一个比较直接的做法是,将蛇身体的每个节点依次前移,不是坐标的移动,是填充,让后面节点填充它前面节点移动前的位置。

大致是这样,我只是给出个思路,如果我有写错的地方,欢迎指正,又或者是你可以按照你的思路来进行,学习,思路是很重要的,代码是死的,人是活的。

分析问题,你要将实际的问题抽象出编程用的模型。抽象的过程就是,先假设你已经有了你想要的函数,你可以先给出函数的声明,比如碰撞检测函数,线程函数等等。这些函数你不会写,先空着,想象它们已经完成了。

然后你要做的就是,用这些已经被假设存在的构造快,来实现你的逻辑。这个逻辑是什么,就要看你怎么抽象一个具体的问题。就像贪吃蛇,通用的思路是把它抽象为坐标和链表结构。如果你用了另外一种思路,整个过程可能截然不同。

整个过程写完了,你需要知道,那些被你假设了的函数,到底怎么实现。

给个思路:

界面显示用MFC来做,线程,定时器什么的,有相应的windowsAPI,这些图形和线程功能,都需要操作系统做支持,所以你要用到一些windows的API。这些资料都是有的,你可以去找。

以上。再次声明,如有疏漏,请见谅。

如何用卡西欧fx991cnx编程玩贪吃蛇,求详细按键顺序

你如果用TC

#include<graphics.h>

#include<stdlib.h>

#define N 200

#define up 0x4800

#define down 0x5000

#define left 0x4b00

#define right 0x4d00

#define esc 0x011b

#define Y 0x1579

#define n 0x316e

int gamespeed; /* 游戏速度 */

int i,key,color;

int score=0; /* 游戏分数 */

char cai48H[]={

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x04,0x00,0x18,0x00,0x00,0x00,0x0E,0x00,

0x1C,0x00,0x00,0x00,0x1C,0x00,0x1C,0x00,

0x00,0x00,0x20,0x00,0x38,0x00,0x00,0x00,

0x40,0x00,0x78,0x00,0x00,0x01,0x80,0x40,

0x70,0x00,0x00,0x03,0x80,0xC0,0xE0,0x00,

0x00,0x07,0x80,0x80,0xC0,0x00,0x00,0x0E,

0x11,0x81,0xC0,0x00,0x00,0x08,0x61,0x01,

0x80,0x00,0x00,0x00,0x23,0x03,0x04,0x00,

0x00,0x02,0x02,0x00,0x06,0x00,0x00,0x1E,

0x04,0x00,0x0F,0x00,0x00,0x1C,0x1F,0x80,

0x1E,0x00,0x00,0x08,0x3F,0x80,0x3C,0x00,

0x00,0x00,0xFF,0x80,0x38,0x00,0x00,0x03,

0xFF,0x80,0x78,0x00,0x00,0x0F,0xF8,0x00,

0xF0,0x00,0x00,0x7F,0xF0,0x00,0xE0,0x00,

0x03,0xFF,0xFC,0x01,0x80,0x00,0x03,0xC0,

0xFF,0x01,0x03,0x80,0x01,0x01,0xFF,0x00,

0x03,0x80,0x00,0x01,0x3F,0x00,0x07,0x80,

0x00,0x02,0x11,0x00,0x07,0x00,0x00,0x00,

0x10,0x00,0x07,0x00,0x00,0x00,0x10,0x00,

0x0E,0x00,0x00,0x08,0x10,0x00,0x1C,0x00,

0x00,0x30,0x10,0x00,0x18,0x00,0x00,0x70,

0x10,0x00,0x30,0x00,0x01,0xE0,0x10,0x00,

0x70,0x00,0x03,0x80,0x10,0x00,0x60,0x00,

0x00,0x00,0x30,0x00,0xE0,0x00,0x00,0x00,

0xF0,0x01,0xC0,0x00,0x00,0x00,0x70,0x03,

0xC0,0x00,0x00,0x00,0x10,0x07,0x80,0x00,

0x00,0x00,0x00,0x0F,0x00,0x00,0x00,0x00,

0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x3C,

0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x00,

0x00,0x00,0x01,0xC0,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

};

char she48H[]={

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,

0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x00,

0x00,0x00,0x00,0x0E,0x00,0x00,0x00,0x00,

0x00,0x0E,0x00,0x00,0x00,0x03,0x00,0x07,

0x00,0x00,0x00,0x02,0x00,0x03,0x00,0x00,

0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x02,

0x00,0x00,0xF8,0x00,0x00,0x02,0x00,0x07,

0x86,0x00,0x00,0x02,0x00,0x18,0x03,0x00,

0x00,0x02,0x00,0x00,0x07,0x80,0x00,0x03,

0xF0,0x00,0x07,0x80,0x00,0x0F,0xFC,0x00,

0x0C,0x00,0x00,0x7E,0x3F,0x80,0x00,0x00,

0x01,0xFE,0x1F,0x80,0x00,0x00,0x01,0xE2,

0x39,0x8C,0x00,0x00,0x00,0xC2,0x30,0x08,

0x00,0x00,0x00,0xC2,0x60,0x08,0x00,0x00,

0x00,0xC3,0xE0,0x08,0x60,0x00,0x00,0x7F,

0xE0,0x01,0xE0,0x00,0x00,0x3F,0x80,0x1F,

0xE0,0x00,0x00,0x1E,0x00,0x1F,0x80,0x00,

0x00,0x1E,0x00,0x1F,0x00,0x00,0x00,0x02,

0x38,0x1E,0x00,0x00,0x00,0x07,0xFC,0x1C,

0x00,0x20,0x00,0x07,0xFC,0x18,0x00,0x20,

0x00,0x1F,0x0C,0x10,0x00,0x20,0x00,0x7C,

0x04,0x10,0x00,0x60,0x01,0xF0,0x00,0x10,

0x00,0x60,0x01,0xE0,0x00,0x08,0x00,0xF0,

0x00,0x80,0x00,0x08,0x03,0xF0,0x00,0x00,

0x00,0x07,0xFF,0xF0,0x00,0x00,0x00,0x07,

0xFF,0xF0,0x00,0x00,0x00,0x03,0xFF,0xE0,

0x00,0x00,0x00,0x01,0xFF,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

};

char tun48H[]={

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x3E,

0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,

0x00,0x00,0x00,0xE0,0x00,0x00,0x00,0x00,

0x03,0xC0,0x00,0x00,0x00,0x00,0x1F,0x00,

0x00,0x00,0x00,0x00,0x7C,0x00,0x00,0x00,

0x00,0x01,0xF8,0x00,0x00,0x00,0x00,0x03,

0xF8,0x00,0x40,0x00,0x00,0x00,0x06,0x07,

0xC0,0x00,0x00,0x00,0x07,0xFF,0xE0,0x00,

0x00,0x00,0x07,0xFF,0xE0,0x00,0x00,0x00,

0x0F,0xFF,0x80,0x00,0x00,0x00,0x7F,0xF8,

0x00,0x00,0x00,0x1F,0xFF,0xF8,0x00,0x00,

0x00,0x1F,0xFF,0xF8,0x00,0x00,0x00,0x1F,

0xFC,0x3C,0x00,0x00,0x00,0x0F,0xF8,0x0E,

0x00,0x00,0x00,0x04,0x70,0x07,0x00,0x00,

0x00,0x00,0x60,0x03,0x80,0x00,0x00,0x00,

0xC0,0x00,0xC0,0x00,0x00,0x01,0x80,0x00,

0x30,0x00,0x00,0x01,0x00,0x3C,0x18,0x00,

0x00,0x02,0x03,0xFF,0x0C,0x00,0x00,0x0C,

0x7F,0xFF,0x8E,0x00,0x00,0x18,0xFF,0xFF,

0xC7,0x80,0x00,0x78,0xFE,0x07,0x87,0xE0,

0x01,0xF0,0x70,0x07,0x03,0xF8,0x07,0xE0,

0x70,0x0E,0x03,0xFE,0x00,0x00,0x38,0x1E,

0x01,0xFE,0x00,0x00,0x3F,0xFE,0x00,0x0C,

0x00,0x00,0x1F,0xFE,0x00,0x00,0x00,0x00,

0x1F,0xFE,0x00,0x00,0x00,0x00,0x0F,0xFE,

0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

};

char dan48H[]={

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0xFC,0x00,0x00,0x00,0x00,0x07,0xFF,

0x00,0x00,0x00,0x00,0x7F,0xC0,0x80,0x00,

0x00,0x03,0xFF,0x80,0x40,0x00,0x00,0x01,

0xF1,0x80,0x40,0x00,0x00,0x01,0x81,0x80,

0xE0,0x00,0x00,0x00,0x01,0x93,0xF0,0x00,

0x00,0x00,0x01,0xFF,0xF0,0x00,0x00,0x00,

0x21,0xFF,0xF0,0x00,0x00,0x00,0x21,0xF8,

0x00,0x00,0x00,0x00,0x61,0xC0,0x00,0x00,

0x00,0x00,0x61,0x80,0x00,0x00,0x00,0x00,

0xF3,0x00,0x00,0x00,0x00,0x00,0xFF,0x00,

0x00,0x00,0x00,0x01,0xFF,0xC0,0x00,0x00,

0x00,0x03,0xFF,0xF8,0x00,0x00,0x00,0x02,

0x00,0xFC,0x00,0x00,0x00,0x04,0x02,0x1F,

0x00,0x00,0x00,0x08,0x03,0x01,0xC0,0x00,

0x00,0x38,0x03,0x00,0x7C,0x00,0x00,0xF8,

0x07,0xF8,0x3F,0xC0,0x01,0xF0,0x3F,0xFE,

0x3F,0xF8,0x03,0xC1,0xFF,0x0F,0x1F,0xF8,

0x00,0x01,0xE3,0x0F,0x0F,0xF0,0x00,0x01,

0xC3,0x0E,0x00,0x00,0x00,0x01,0x83,0xFC,

0x00,0x00,0x00,0x00,0xC7,0xF8,0x00,0x00,

0x00,0x00,0xFF,0xF8,0x00,0x00,0x00,0x00,

0x7F,0xF0,0x00,0x00,0x00,0x00,0x3F,0x03,

0x80,0x00,0x00,0x00,0x03,0x04,0x00,0x00,

0x00,0x00,0x03,0xF8,0x00,0x00,0x00,0x00,

0x1F,0xF8,0x20,0x00,0x00,0x00,0xFF,0xFF,

0xE0,0x00,0x00,0x07,0xFF,0x81,0xE0,0x00,

0x00,0x07,0xE0,0x00,0xE0,0x00,0x00,0x03,

0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

};

char zuo16H[]={

0x18,0xC0,0x18,0xC0,0x19,0x80,0x31,0xFE,

0x33,0xFE,0x76,0xC0,0xF0,0xFC,0xB0,0xFC,

0x30,0xC0,0x30,0xC0,0x30,0xFE,0x30,0xFE,

0x30,0xC0,0x30,0xC0,0x30,0xC0,0x00,0x00,

};

char zhe16H[]={

0x03,0x00,0x03,0x0C,0x1F,0xCC,0x1F,0xD8,

0x03,0x30,0xFF,0xFE,0xFF,0xFE,0x03,0x00,

0x0F,0xF8,0x3F,0xF8,0xEC,0x18,0xCF,0xF8,

0x0C,0x18,0x0F,0xF8,0x0F,0xF8,0x00,0x00,

};

char tian16H[]={

0x00,0x00,0x3F,0xFC,0x3F,0xFC,0x31,0x8C,

0x31,0x8C,0x31,0x8C,0x3F,0xFC,0x3F,0xFC,

0x31,0x8C,0x31,0x8C,0x31,0x8C,0x3F,0xFC,

0x3F,0xFC,0x30,0x0C,0x00,0x00,0x00,0x00,

};

char xue16H[]={

0x33,0x18,0x19,0x98,0x08,0xB0,0x7F,0xFC,

0x7F,0xFC,0x60,0x0C,0x1F,0xF0,0x1F,0xF0,

0x00,0xC0,0x7F,0xFC,0x7F,0xFC,0x01,0x80,

0x01,0x80,0x07,0x80,0x03,0x00,0x00,0x00,

};

char ke16H[]={

0x00,0x00,0x0C,0x18,0xFD,0x98,0xF8,0xD8,

0x18,0x58,0xFE,0x18,0xFE,0x98,0x18,0xD8,

0x3C,0x58,0x7E,0x1E,0xDB,0xFE,0x9B,0xF8,

0x18,0x18,0x18,0x18,0x18,0x18,0x00,0x00,

};

struct Food/*定义结构体存储食物的属性*/

{

int x; /* 食物的坐标 */

int y;

int yes; /* 值为0表示屏幕上没有食物,值为1表示屏幕上有食物 */

int color; /* 食物颜色 */

}food;

struct Snake/*定义结构体存储蛇的属性*/

{

int x[N]; /* 每一节蛇的坐标 */

int y[N];

int color[N];/*存储每一节蛇的颜色*/

int node; /* 蛇的节数 */

int direction; /* 蛇移动的方向 */

int life; /* 蛇的生命,如果为1,蛇死,游戏结束 */

}snake;

void init(void)/*图形驱动*/

{

int driver=DETECT,mode=0;

registerbgidriver(EGAVGA_driver);

initgraph(&driver,&mode,"");

}

void drawmat(char *mat,int matsize,int x,int y,int color)/*汉字点阵*/

{

int i,j,k,m;

m=(matsize-1)/8+1;

for(j=0;j<matsize;j++)

for(i=0;i<m;i++)

for(k=0;k<8;k++)

if(mat[j*m+i]&(0x80>>k))

putpixel(x+i*8+k,y+j,color);

}

void showword(void)

{/* 调用汉字点阵输出程序,显示标题和作者信息 */

drawmat(cai48H,48,249,-4,7);

drawmat(she48H,48,329,-4,7);

drawmat(tun48H,48,409,-4,7);

drawmat(dan48H,48,489,-4,7);

drawmat(cai48H,48,250,-5,4);

drawmat(she48H,48,330,-5,4);

drawmat(tun48H,48,410,-5,4);

drawmat(dan48H,48,490,-5,4);

/*作者 田学科*/

drawmat(zuo16H,16,515,465,7);

drawmat(zhe16H,16,530,465,7);

drawmat(tian16H,16,550,465,7);

drawmat(xue16H,16,565,465,7);

drawmat(ke16H,16,580,465,7);

}

void draw(void)/*画出四周的墙*/

{

if(color==15)

color=0;

setcolor(++color);

setlinestyle(SOLID_LINE,0,1);

for(i=30;i<=600;i+=10)

{

rectangle(i,40,i+10,49);

rectangle(i,451,i+10,460);

}

for(i=40;i<450;i+=10)

{

rectangle(30,i,39,i+10);

rectangle(601,i,610,i+10);

}

}

void prscore(void)

{/* 打印游戏分数 */

char str[10];

setfillstyle(SOLID_FILL,YELLOW);

bar(50,10,200,30);

setcolor(6);

settextstyle(0,0,2);

sprintf(str,"score:%d",score);

outtextxy(55,15,str);

}

void gameover(void)

{

cleardevice(); /* 清屏函数 */

for(i=0;i<snake.node;i++)/* 画出蛇死时的位置 */

{

setcolor(snake.color[i]);

rectangle(snake.x[i],snake.y[i],snake.x[i]+10,snake.y[i]+10);

}

prscore(); /* 显示分数 */

draw();

showword();

settextstyle(0,0,6);

setcolor(7);

outtextxy(103,203,"GAME OVER");

setcolor(RED);

outtextxy(100,200,"GAME OVER");

}

void gameplay(void)/* 玩游戏的具体过程 */

{

int flag,flag1;

randomize();

prscore();

gamespeed=50000;

food.yes=0;/* food.yes=0表示屏幕上没有食物 */

snake.life=1;/* snake.life=1表示蛇是活着的 */

snake.direction=4;/* 表示蛇的初始方向为向右 */

snake.node=2; /* 蛇的初始化为两节 */

snake.color[0]=2; /*两节蛇头初始化为绿色*/

snake.color[1]=2;

snake.x[0]=100;snake.y[0]=100;

snake.x[1]=110;snake.y[1]=100;

food.color=random(15)+1;

while(1)

{

while(1)

{

if(food.yes==0) /* 如果蛇活着 */

{

while(1)

{

flag=1;

food.yes=1;

food.x=random(56)*10+40;

food.y=random(40)*10+50;

for(i=0;i<snake.node;i++)

{

if(food.x==snake.x[i]&&food.y==snake.y[i])

flag=0;

}

if(flag) break;

}

}

if(food.yes)

{

setcolor(food.color);

rectangle(food.x,food.y,food.x+10,food.y+10);

}

for(i=snake.node-1;i>0;i--)

{

snake.x[i]=snake.x[i-1];

snake.y[i]=snake.y[i-1];

}

switch(snake.direction)

{

case 1: snake.y[0]-=10;break;

case 2: snake.y[0]+=10;break;

case 3: snake.x[0]-=10;break;

case 4: snake.x[0]+=10;break;

}

for(i=3;i<snake.node;i++)

{

if(snake.x[i]==snake.x[0]&&snake.y[i]==snake.y[0])

{

gameover();

snake.life=0;

break;

}

}

if(snake.x[0]<40||snake.x[0]>590||snake.y[0]<50||snake.y[0]>440)

{

gameover();

snake.life=0;

}

if(snake.life==0)

break;

if(snake.x[0]==food.x&&snake.y[0]==food.y)/*蛇吃掉食物*/

{

setcolor(0);

rectangle(food.x,food.y,food.x+10,food.y+10);

snake.x[snake.node]=-20;

snake.y[snake.node]=-20;

snake.color[snake.node]=food.color;

snake.node++;

food.yes=0;

food.color=random(15)+1;

score+=10;

prscore();

if(score%100==0&&score!=0)

{

for(i=0;i<snake.node;i++)/* 画出蛇 */

{

setcolor(snake.color[i]);

rectangle(snake.x[i],snake.y[i],snake.x[i]+10,snake.y[i]+10);

}

sound(200);

delay(50000);delay(50000);delay(50000);

delay(50000);delay(50000);delay(50000);

nosound();

gamespeed-=5000;

draw();

}

else

{

sound(500);

delay(500);

nosound();

}

}

for(i=0;i<snake.node;i++)/* 画出蛇 */

{

setcolor(snake.color[i]);

rectangle(snake.x[i],snake.y[i],snake.x[i]+10,snake.y[i]+10);

}

delay(gamespeed);

delay(gamespeed);

flag1=1;

setcolor(0);

rectangle(snake.x[snake.node-1],snake.y[snake.node-1],

snake.x[snake.node-1]+10,snake.y[snake.node-1]+10);

if(kbhit()&&flag1==1)/*如果没按有效键就重新开始循环*/

{

flag1=0;

key=bioskey(0);

if(key==esc)

exit(0);

else if(key==up&&snake.direction!=2)

snake.direction=1;

else if(key==down&&snake.direction!=1)

snake.direction=2;

else if(key==left&&snake.direction!=4)

snake.direction=3;

else if(key==right&&snake.direction!=3)

snake.direction=4;

}

}

if(snake.life==0)/*如果蛇死了就退出循环*/

break;

}

}

void main(void)

{

while(1)

{

color=0;

init();

cleardevice();

showword();

draw();

gameplay();

setcolor(15);

settextstyle(0,0,2);

outtextxy(200,400,"CONTINUE(Y/N)?");

while(1)

{

key=bioskey(0);

if(key==Y||key==n||key==esc)

break;

}

if(key==n||key==esc)

break;

}

closegraph();

}

8,shift,8,下,2,7,等于,上,左,shift,点(会显示乱码),左左右,分数线,del三下,右,根号,shift,7,2,4,(会发出?o,打四个),然后按等于,然后右,然后del,最后AC,这样你可以看到精美图案了

关于“怎么用编程做贪吃蛇”这个话题的介绍,今天小编就给大家分享完了,如果对你有所帮助请保持对本站的关注!

免责声明:由于无法甄别是否为投稿用户创作以及文章的准确性,本站尊重并保护知识产权,根据《信息网络传播权保护条例》,如我们转载的作品侵犯了您的权利,请您通知我们,请将本侵权页面网址发送邮件到qingge@88.com,深感抱歉,我们会做删除处理。