• 大小: 0.01M
    文件类型: .cpp
    金币: 1
    下载: 0 次
    发布日期: 2021-05-16
  • 语言: C/C++
  • 标签: 其他  

资源简介

sanke.cpp

资源截图

代码片段和文件信息

#include 
#include 
#include //
#include 
using namespace std;

void createWindow();//创建一个窗口
void initial();//初始化
void createObj();//随机创建目标
void getDirection();//获取方向
void eat();//吃的动作
void updateLine();//更新保存蛇的数组
void liveState();//保存状态--分数->文件 ->判断蛇是否死了
void showSnake();//显示蛇
void setXy(int x int y);//获取窗口坐标
void updateScore();//更新分数

int delay = 0;//延迟
int eatFlag = 0;//吃了目标点的标记默认为没有吃,吃了为1
int state = 1;//判断蛇状态的标记, 如果state==0,那么蛇就死了退出整个循环
int max = 0;//最高得分
int length = 1;//蛇的长度
int line[100][2];//一行就存放蛇每个点的x和y坐标
int top[2] = {4012};//蛇头始终记录最新蛇头的位置,不管吃了目标没有
int obj[2];//存放目标点的坐标
int xMin = 1 xMax = 77 yMin = 2 yMax = 23;
int tailPre[2];//存放蛇尾的坐标
char directionPre = ‘s‘;
char direction;
void createWindow(){
    setXy(0 0);//一定要先从(0,0)这个位置开始打印哦
    cout<<“|==================================================================|“<    cout<<“|                                |                                 |“<    cout<<“|==================================================================|“<    cout<<“|                                                                  |“<    cout<<“|                                                                  |“<    cout<<“|                                                                  |“<    cout<<“|                                                                  |“<    cout<<“|                                                                  |“<    cout<<“|                                                                  |“<    cout<<“|                                                                  |“<    cout<<“|                                                                  |“<    cout<<“|                                                                  |“<    cout<<“|                                                                  |“<    cout<<“|                                                                  |“<    cout<<“|                                                                  |“<    cout<<“|                                                                  |“<    cout<<“|                                                                  |“<    cout<<“|                                                                  |“<    cout<<“|                                                                  |“<    cout<<“|                                                                  |“<    cout<<“|                                                                  |“<    cout<<“|                                                                  |“<    cout<<“|                                                                  |“<    cout<<“|                                                                  |“<    cout<<“|                 

评论

共有 条评论