网上有关“贪吃蛇的编程程序”话题很是火热,小编也是针对贪吃蛇的编程程序寻找了一些与之相关的一些信息进行分析,如果能碰巧解决你现在面临的问题,希望能够帮助到您。
您好:手机麻将有挂是真的吗这款游戏可以开挂,确实是有挂的,咨询加微信【】很多玩家在这款游戏中打牌都会发现很多用户的牌特别好,总是好牌,而且好像能看到其他人的牌一样。所以很多小伙伴就怀疑这款游戏是不是有挂,实际上这款游戏确实是有挂的
1.手机麻将有挂是真的吗这款游戏可以开挂,确实是有挂的,通过添加客服微信
2.咨询软件加微信【】在"设置DD功能DD微信手麻工具"里.点击"开启".
3.打开工具.在"设置DD新消息提醒"里.前两个选项"设置"和"连接软件"均勾选"开启"(好多人就是这一步忘记做了)
4.打开某一个微信组.点击右上角.往下拉."消息免打扰"选项.勾选"关闭"(也就是要把"群消息的提示保持在开启"的状态.这样才能触系统发底层接口)
以下是代码
/* 贪吃蛇程序 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 0x011b
int i,key;
int score = 0;/*得分*/
int gamespeed = 100000;/*游戏速度自己调整*/
struct Food
{
? int x;/*食物的横坐标*/
? int y;/*食物的纵坐标*/
? int yes;/*判断是否要出现食物的变量*/
}food;/*食物的结构体*/
struct Snake
{
? 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);/*玩游戏具体过程*/
void PrScore(void);/*输出成绩*/
/*主函数*/
void main(void)
{
? Init();/*图形驱动*/
? DrawK();/*开始画面*/
? GamePlay();/*玩游戏具体过程*/
? Close();/*图形结束*/
}
/*图形驱动*/
void Init(void)
{
? int gd = DETECT, gm;
? 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)/*画围墙*/
{
?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(void)
{
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)/*可以重复玩游戏,压ESC键结束*/
{
?while(!kbhit())/*在没有按键的情况下,蛇自己移动身体*/
?{
? if(food.yes == 1)/*需要出现新食物*/
? {
food.x = rand() % 400 + 60;
food.y = rand() % 350 + 60;
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];
? }
?
? /*1,2,3,4表示右,左,上,下四个方向,通过这个判断来移动蛇头*/
? 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);
? 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);
?} ?/*endwhile(!kbhit)*/
?
?if(snake.life == 1)/*如果蛇死就跳出循环*/
? break;
?
?key = bioskey(0);/*接收按键*/
?
?if(key == ESC)/*按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;
}/*endwhile(1)*/
}
/*游戏结束*/
void GameOver(void)
{
cleardevice();
PrScore();
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, "score:%d", score);
outtextxy(55, 20, str);
}
/*图形结束*/
void Close(void)
{ ?
getch();
closegraph();
}
//?ConsoleApplication1.cpp:?定义控制台应用程序的入口点。
//
#include?"stdafx.h"
#include?<stdio.h>
#include?<windows.h>
#include?<time.h>
#include?<conio.h>
#define?frame_height?20?//define?map?size
#define?frame_width?40
#define?UP?'w'?//define?operate?key
#define?DOWN?'s'
#define?LEFT?'a'
#define?RIGHT?'d'
int?i,?j,?k;
char?ch?=?UP;?//initial?direction
int?grow?=?0;?//flag:?if?snake?grow
struct?Food?{
int?x;
int?y;
}food;
struct?Snake?{
int?x[50];
int?y[50];
int?len;
int?speed;
}snake;?//snake[0]?is?head
void?init_map(void);
void?update_food(void);
void?move_snake(void);
int?is_alive(void);
void?get_speed(void);
void?gotoxy(int?x,?int?y);
int?main()
{
init_map();?//初始化地图
while?(1)
{
update_food();
//是否产生食物
get_speed();?//获取速度
move_snake();?//移动蛇身
Sleep(snake.speed);
//移动速度
if?(!(is_alive()))
//蛇的死活(撞墙或自食)
break;
}
printf("Game?Over!");
_getch();
return?0;
}
//initialize
void?init_map(void)
{
//initial?food
srand(time(NULL));
food.x?=?rand()?%?(frame_height?-?2)?+?1;
food.y?=?rand()?%?(frame_width?-?2)?+?1;
gotoxy(food.x,?food.y);
printf("!");
//initial?snake
snake.x[0]?=?frame_height?/?2;
snake.y[0]?=?frame_width?/?2;
gotoxy(snake.x[0],?snake.y[0]);
printf("@");
snake.len?=?3;
snake.speed?=?200;
for?(k?=?1;?k<snake.len;?k++)
{
snake.x[k]?=?snake.x[k?-?1]?+?1;
snake.y[k]?=?snake.y[k?-?1];
gotoxy(snake.x[k],?snake.y[k]);
printf("@");
}
//initial?bar
for?(j?=?0;?j<frame_width;?j++)
{
gotoxy(0,?j);
printf("#");
gotoxy(frame_height?-?1,?j);
printf("#");
}
for?(i?=?1;?i<frame_height?-?1;?i++)
{
gotoxy(i,?0);
printf("#");
gotoxy(i,?frame_width?-?1);
printf("#");
}
}
//generate?food
void?update_food()
{
if?(snake.x[0]?==?food.x&&snake.y[0]?==?food.y)
{
srand(time(NULL));
food.x?=?rand()?%?(frame_height?-?2)?+?1;
food.y?=?rand()?%?(frame_width?-?2)?+?1;
gotoxy(food.x,?food.y);
printf("!");
snake.len++;
grow?=?1;
}
}
//move?snake
void?move_snake()
{
if?(_kbhit())
ch?=?_getch();
if?(!grow)
{
gotoxy(snake.x[snake.len?-?1],?snake.y[snake.len?-?1]);
printf("?");
}
for?(k?=?snake.len?-?1;?k>0;?k--)
{
snake.x[k]?=?snake.x[k?-?1];
snake.y[k]?=?snake.y[k?-?1];
}
switch?(ch)
{
case?UP:?snake.x[0]--;?break;
case?DOWN:?snake.x[0]++;?break;
case?LEFT:?snake.y[0]--;?break;
case?RIGHT:?snake.y[0]++;?break;
default:?break;
}
gotoxy(snake.x[0],?snake.y[0]);
printf("@");
grow?=?0;
gotoxy(frame_height,?0);
}
//is?alive
int?is_alive(void)
{
if?(snake.x[0]?==?0?||?snake.x[0]?==?frame_height?-?1?||?snake.y[0]?==?frame_width?-?1?||?snake.y[0]?==?0)
return?0;
for?(k?=?1;?k<snake.len;?k++)
if?(snake.x[k]?==?snake.x[0]?&&?snake.y[k]?==?snake.y[0])
return?0;
return?1;
}
//speed?up
void?get_speed(void)
{
if?(snake.len?<=?6)
snake.speed?=?200;
else?if?(snake.len?<=?10)
snake.speed?=?100;
else?if?(snake.len?<=?20)
snake.speed?=?50;
else?if?(snake.len?<=?30)
snake.speed?=?30;
else?snake.speed?=?20;
}
//move?cursor
void?gotoxy(int?x,?int?y)
{
HANDLE?hout;
COORD?cor;
hout?=?GetStdHandle(STD_OUTPUT_HANDLE);
cor.X?=?y;
cor.Y?=?x;
SetConsoleCursorPosition(hout,?cor);
}
关于“贪吃蛇的编程程序”这个话题的介绍,今天小编就给大家分享完了,如果对你有所帮助请保持对本站的关注!