在linuxapp上实现贪吃蛇.rar


操作系统课设
资源截图
代码片段和文件信息
#include
#include
#include
#include
#include

/*玩家1控制键: */   
#define up ‘w‘
#define down ‘s‘
#define left ‘a‘
#define right ‘d‘
#define stop ‘q‘
/*玩家2控制键: */
#define 上 72
#define 下 80
#define 左 75
#define 右 77
/*全局变量 + 预处理:*/
typedef struct Snakes
{
int x;
int y;
struct Snakes *next;
}snake;
 
snake *head1*tail1;
snake *head2*tail2;
char a[100]={0}b[100]={0};
struct Food
{
int x;
int y;
}food;
char name[20]ch;
int score1 = 0 score2 = 0 ;
char click1 = ‘d‘ click2 = 75;
char click;
int speed1=300speed2=300speeda=0speedb=0;
int flag=1;   //标识打印墙还是打印蛇身  1 打印墙  0 打印蛇身
/*********************************************************************/
void welcome();               //55开始界面
void Finish();                //291结束界面
void creatgraph();            //69围墙打印
void gotoxy(int x int y);    //111光标跳转,横为X 012..
void gotoprint(int x int y); //121跳转打印
void headgotoprint(int xint y); // 打印蛇头
void gotodelete(int x int y);//127跳转删除
void creatfood();             //133食物产生
int ClickControl();           //157获取键盘信号
int Judge(snake*head);                  //270游戏结束判断  穿墙判断
int Bite(snake*head1snake*head2);       //两条蛇互咬
void MovingBody(snake*head1snake*head2);
void MovingBody1(snake*head1);      //172蛇的移动 
void MovingBody2(snake*head2);      //172
//void ThroughWall();     //穿墙函数
void Eating(snake*head1snake*head2);                //223蛇吃到东西后的操作(伸长)
void ChangeBody(int aint bint num); //245蛇的坐标变换后一个复制前一个STRUCTab为head之前坐标  num记录第几条蛇
/************************************************************/
 
int main()
{
system(“color 0B“);
welcome();
creatgraph();
creatfood();
if (ClickControl() == 0) return 0;
return 0;
}
 
/**********************************************************/
void welcome()
{
gotoxy(1510);
printf(“/**********************************************/“);
gotoxy(15 22);
printf(“/**********************************************/“);
gotoxy(20 13);
printf(“WELCOME TO THE GAME OF RETRO SNAKE“);
gotoxy(14 16);
printf(“请在英文输入法中操作,反向移动等同于吃到自己,wasd控制p暂停“);
gotoxy(20 18);
printf(“PLEASE ENTER YOUR NAME:“);
scanf_s(“%s“ &name10);
if (strcmp(“zhc“ name) == 0) strcpy_s(name “小天才“);
gotoxy(2020);
printf(“请输入 q 启动游戏:“);
while(1)
{
ch = _getch();
if(ch==‘q‘) break;
}
system(“cls“);
}
/**********************************************************/
void creatgraph()             
{
int i;
for (i = 0; i<58; i += 2)//打印上下边框
{
gotoprint(i 0);
gotoprint(i 26);
}
for (i = 1; i < 26; i++)
{
gotoprint(0 i);
gotoprint(56 i);
}
flag=0;   //标识变为0,打印蛇身
gotoxy(63 10);
printf(“hello %sWelcome To Play“name);
gotoxy(63 15);
printf(“Your Score Is:%d  = ̄ω ̄= “score1);
gotoxy(63 20);
printf(“Your Score Is:%d  = ̄ω ̄= “score2);
gotoxy(6325);
printf(“This Game Is Created By JOKER“);
//*************************************初始化蛇1
head1 = (snake*)

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      35840  2018-09-12 17:52  贪吃蛇蛇1Debug蛇1.exe

     文件     528724  2018-09-12 17:52  贪吃蛇蛇1Debug蛇1.ilk

     文件     625664  2018-09-12 17:52  贪吃蛇蛇1Debug蛇1.pdb

     文件   33030144  2018-09-14 10:17  贪吃蛇蛇1ipch蛇1-766c290e蛇1-a5025b64.ipch

     文件      12480  2018-09-14 10:31  贪吃蛇蛇1蛇11.cpp

     文件      65001  2018-09-12 17:52  贪吃蛇蛇1蛇1Debug1.obj

     文件        574  2018-09-12 17:52  贪吃蛇蛇1蛇1Debugcl.command.1.tlog

     文件      24782  2018-09-12 17:52  贪吃蛇蛇1蛇1DebugCL.read.1.tlog

     文件        228  2018-09-12 17:52  贪吃蛇蛇1蛇1DebugCL.write.1.tlog

     文件          2  2018-09-12 17:52  贪吃蛇蛇1蛇1Debuglink-cvtres.read.1.tlog

     文件          2  2018-09-12 17:52  贪吃蛇蛇1蛇1Debuglink-cvtres.write.1.tlog

     文件          2  2018-09-12 17:52  贪吃蛇蛇1蛇1Debuglink.12664-cvtres.read.1.tlog

     文件          2  2018-09-12 17:52  贪吃蛇蛇1蛇1Debuglink.12664-cvtres.write.1.tlog

     文件          2  2018-09-12 17:52  贪吃蛇蛇1蛇1Debuglink.12664.read.1.tlog

     文件          2  2018-09-12 17:52  贪吃蛇蛇1蛇1Debuglink.12664.write.1.tlog

     文件          2  2018-09-12 17:52  贪吃蛇蛇1蛇1Debuglink.20680-cvtres.read.1.tlog

     文件          2  2018-09-12 17:52  贪吃蛇蛇1蛇1Debuglink.20680-cvtres.write.1.tlog

     文件          2  2018-09-12 17:52  贪吃蛇蛇1蛇1Debuglink.20680.read.1.tlog

     文件          2  2018-09-12 17:52  贪吃蛇蛇1蛇1Debuglink.20680.write.1.tlog

     文件       1276  2018-09-12 17:52  贪吃蛇蛇1蛇1Debuglink.command.1.tlog

     文件       2850  2018-09-12 17:52  贪吃蛇蛇1蛇1Debuglink.read.1.tlog

     文件        532  2018-09-12 17:52  贪吃蛇蛇1蛇1Debuglink.write.1.tlog

     文件        326  2018-09-12 17:52  贪吃蛇蛇1蛇1Debugmt.command.1.tlog

     文件        234  2018-09-12 17:52  贪吃蛇蛇1蛇1Debugmt.read.1.tlog

     文件        234  2018-09-12 17:52  贪吃蛇蛇1蛇1Debugmt.write.1.tlog

     文件        418  2018-09-06 16:00  贪吃蛇蛇1蛇1Debug
c.command.1.tlog

     文件        206  2018-09-06 16:00  贪吃蛇蛇1蛇1Debug
c.read.1.tlog

     文件        214  2018-09-06 16:00  贪吃蛇蛇1蛇1Debug
c.write.1.tlog

     文件     543744  2018-09-12 17:52  贪吃蛇蛇1蛇1Debugvc100.idb

     文件     184320  2018-09-12 17:52  贪吃蛇蛇1蛇1Debugvc100.pdb

............此处省略24个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)