问题描述
- 求大神vs2015 环境下纯c语言编程推箱子游戏,QQ或微信红包重谢
-
本人c语言初学者,求推向资源代码。我已写了部分,但不会将其联系起来,将其显示出来,刷屏出来。。。就是将地图呈现出。希望看到大神的源代码有所感悟#ifndef _DITEM
#define _DITEM
#define X 8
#define Y 8
enum Kind{nul=0,wall,human,box,well,finish,empty,qiu};
typedef struct _item {
enum Kind kind;
enum Dic dic;
enum Kind get;
struct _item *last;
struct _item *next;
}item;
enum Dic{up=-1,down=-2,left=-3,right=-4,null=0};void deal(item *);
void link(item *, int);
void deal_wall(item *);
void deal_human(item *);
void deal_box(item *);
void deal_well(item *);
void deal_finish(item *);
void deal_empty(item *);#endif
#include "Ditem.h"
void deal(item *p)
{
if(p->dic!=null)
link(p, p->dic);
while (p->next != NULL)
{switch (p->kind)
{
case qiu:deal_human(p); p->kind = well; break;
case wall:deal_wall(p); break;
case human:deal_human(p); break;
case finish:deal_finish(p); break;
case box:deal_box(p); break;
case well:deal_well(p); break;
case empty:deal_empty(p); break;
}
p = p->next;
}
while (p->last != NULL)
{
switch (p->kind)
{
case wall:deal_wall(p); break;
case human:deal_human(p); break;
case finish:
case box:deal_box(p); break;
case well:deal_well(p); break;
case empty:deal_empty(p); break;
}
p = p->last;
}}
void link(item *p,enum Dic d)
{
switch (d)
{
case up:p->next = p - X; break;
case down:p->next = p + X; break;
case left:p->next = p - 1; break;
case right:p->next = p + 1; break;
default:p->next = NULL;
}
}
void deal_wall(item *p)
{
p->last->get = wall;
p->get = nul;
}
void deal_human(item *);
void deal_box(item *p)
{
switch (p->get)
{
case wall:
case box:p->last->get = wall; break;
case well:
case empty:p->kind = human; p->last->get = empty; break;
case human:link(p, p->dic); p->dic = null;p->next->get=box; break;
}
p->get = nul;
}
void deal_well(item *p)
{
if (p->get == box)
{
p->get = finish;
p->last->get = well;
}
else
{
p->kind = qiu;
p->last->get = well;
}
p->get = nul;
}void deal_empty(item *p)
{
p->kind = p->get;
p->last->get = empty;
p->get = nul;
}
解决方案
写C用什么工具倒无所谓,可以把代码逻辑写到函数里,再在main函数里调用
解决方案二:
推箱子算是一个比较大点的游戏了,肯定是要分层的 你先把业务逻辑层写好 可以在找一个c语言的桌面框架,来写表现层