资源简介
本人大一刚学C,主要通过此工程进行巩固知识(注:编译需要EGE图形库)
编译环境为VC6.0
代码片段和文件信息
#include
#include
#include
#include
#include
int xy;
int food_xfood_y; //食物坐标
int k=0u; //计分
int mode[35][35]; //构造界面
char str[10]; //name
enum{UPDOWNRIGHTLEFT}point; // 枚举方向
void jiemian() //开始EGE界面
{
initgraph(640480);
PIMAGE img=newimage();
getimage(img“\\images\\11.jpg“);
putimage(00img);
delimage(img);
outtext(“按空格键开始游戏界面......“);
// setfont(80 30“测试“);
//outtextxy(250150“游戏“);
setfont(-160“宋体“);
outtextxy(570440“By:WQQ“);
getch();
closegraph();
}
void weiqiang() //围墙设置
{
setfillcolor(EGERGB(0x0 0x80 0x80));
bar(04040480);
bar(60040640480);
bar(0440640480);
}
void dayin() // 打印蛇身及食物
{ int ij;
weiqiang();
for(i=0;i<24;i++)
for(j=0;j<31;j++)
{
if(mode[i][j]==2)
{
setfillcolor(hsl2rgb(float(randomf() * 360) 1.0f 0.5f));
bar(20*j20*i20*j+2020*i+20);
}
if(mode[i][j]==3)
{ setfillstyle(SOLID_FILLEGERGB(125125125));
bar(20*j20*i20*j+2020*i+20);
}
}
}
typedef struct snake //snake属性 设置头结点和尾节点
{
int xy;
struct snake *prior;
struct snake *next;
}snake;
snake *tail*head;
void addhead(int aint b) //增加头结点
{struct snake *temp;
temp=(struct snake*)malloc(sizeof(struct snake)); //开辟内存单元
temp->x=a; //横坐标
temp->y=b; //纵坐标
temp->prior=NULL;
if(NULL==head) //如果开始为空 那么temp既是头结点又是尾节点
{
head=tail=temp;
head->next=NULL;
}
else
{
head->prior=temp; //将temp设为头指针
temp->next=head; //双向链表
head=head->prior; //head设置为头指针
}
mode[a][b]=2; //将节点处设置打印记号 蛇身为2!!!!!!
}
void deletetail() //删除尾节点
{
mode[tail->x][tail->y]=0; //打印记号
tail=tail->prior; //尾节点前移
tail->next=NULL; //将尾节点下一位设为空 达到删除目的
free(tail->next); //释放内存
}
void init() //初始化 (界面及蛇身)
{
int ij;
for(i=1;i<=30;i++)
{
mode[1][i]=mode[22][i]=1;//上下
}
for(j=1;j<=22;j++)
{
mode[j][1]=mode[j][30]=1; //左右
}
head=tail;
poin 相关资源
- 猜数字游戏 c语言代码
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- LINUX下命令行界面的C语言细胞游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 用C语言实现的一个打字游戏
- C语言版3D魔方游戏源代码
- 打飞机小游戏57466
- 俄罗斯方块游戏源码(Tetris)
- c++ 猜拳小游戏
- 扫雷游戏.cpp
- 杨中科游戏开发引擎
- 智商超高的中国象棋游戏源码(C++版
- c++ 扫雷游戏源码(控制台)
- C++跑跑卡丁车
- C++“倒忌时”小游戏
- XX游戏客户端源码
- c++小游戏源码.doc
- 基于ege图形的推箱子游戏
- C语言ege贪吃蛇游戏
- C++小游戏4款(源码)
- 推箱子小游戏源码
- 五子棋游戏源码(控制台)
- 猜数字游戏.sb3
- C++贪吃蛇控制台小游戏代码
- 扫雷游戏.cpp(较简单)
- MFC五子棋游戏
- VC++ 大富翁4_大富翁游戏源码
- c++常用游戏算法及数据结构设计
- c++的飞行鸟游戏
川公网安备 51152502000135号
评论
共有 条评论