推箱子小游戏源代码

在一个狭小的仓库中要求把木箱放到指定的位置稍不小心就会出现箱子无法移动或者通道被堵住的情况所以需要巧妙的利用有限的空间和通道合理安排移动的次序和位置才能顺利的完成,这篇文章主要为大家详细介绍了C++实现推箱子小游戏源码文中示例代码介绍的非常详细具有一定的参考价值感兴趣的小伙伴们可以参考一下本文实例为大家了C++实现推箱子小游戏的,设置窗口大小system(modeconcols26lines11)。希望《推箱子小游戏源代码》一文对您能有所帮助!

推箱子游戏代码python实现

娟,给你提个构思吧:你先做个箱子的类,类中要有箱子移动的方法,还要有个小人儿的类,类中要有推箱子AND GAMEOVER的方法。最后就是布局了。如果要做简单的就随即生成了。难点的好像就是考虑这个游戏是不是有可能过关,然后掉方法就行吧。(不知道对不对,仅供参考哈!)你也可以找游戏代码啊,上网收下!

推箱子小游戏源代码微信小程序

已经发到了。忘记改邮件主题了,它默认了第一个文件名:6款小游戏。
挺多的,主要有以下小游戏的源代码
rpg游戏圣剑2(这个游戏做的很强大,不过要用到DirectX的Lib和include,我也给你发过去了,放到C++安装目录相应的文件夹下面就可以了。)
冒险rpg 魔塔
六款经典小游戏:推箱子 贪吃蛇 俄罗斯方块 扫雷 拼图 连连看
全部是完整源代码,希望对你有所帮助。
snowtea的qq邮箱就是我。

推箱子小游戏源代码java

..................................................................................................................................................................................................................
(*^__^*) 嘻嘻……

推箱子小游戏java代码

//贪吃蛇游戏,可以运行,我测试过
#include<stdio.h>
#include<dos.h>
#include<graphics.h>
#include<stdlib.h>
#define UP 0x48
#define DOWN 0x50
#define LEFT 0x4b
#define RIGHT 0x4d
#define SPACE 0x39
#define ENTER 0x1c
#define ESC 0x1
#define SW 60
#define SL 20
#define Gsize 20
#define S 0
#define X 1
#define Z 2
#define Y 3
typedef struct SN{
int x;
int y;
int direction;
struct SN *next;
}SNAKE;
SNAKE *tail;
int rank=0;
int grilled[21][16]={0};
unsigned size,size1;
void *buffer,*buffer1;
void interrupt (*oldtime)();
void interrupt newtime();
void install(void interrupt (*haddr)());
int timer=0;
int getkey()
{
union REGS rg;
rg.h.ah=0;
int86(0x16,&rg,&rg);
return rg.h.ah;
}
SNAKE *initmainwindow()
{
int i,j,k;
SNAKE *p,*w;
for(i=0;i<20;i++)
{
grilled[0]=1;
grilled[15]=1;
}
for(j=0;j<16;j++)
{
grilled[0][j]=1;
grilled[20][j]=1;
}
rectangle(SW+20,SL+20,SW+300,SL+400);
rectangle(SW+19,SL+19,SW+299,SL+399);
rectangle(SW+Gsize*6,SL+Gsize*6,SW+Gsize*6+20,SL+Gsize*6+20);
bar(SW+Gsize*6+2,SL+Gsize*6+2,SW+Gsize*6+18,SL+Gsize*6+18);
size=imagesize(SW+Gsize*6,SL+Gsize*6,SW+Gsize*6+20,SL+Gsize*6+20);
buffer=malloc(size);
getimage(SW+Gsize*6,SL+Gsize*6,SW+Gsize*6+20,SL+Gsize*6+20,buffer);
for(k=1;k<3;k++)
{
putimage(SW+Gsize*6,SL+Gsize*(6+k),buffer,XOR_PUT);
grilled[6+k][6]=1;
}
w=NULL;
for(k=2;k>=0;k--)
{
p=(SNAKE *)malloc(sizeof(SNAKE));
p->x=6;p->y=6+k;
p->direction=S;
p->next=w;
w=p;
}
rectangle(SW+Gsize*2,SL+Gsize*4,SW+Gsize*2+15,SL+Gsize*4+15);
rectangle(SW+Gsize*2+2,SL+Gsize*4+2,SW+Gsize*2+13,SL+Gsize*4+13);
grilled[4][2]=2;
size1=imagesize(SW+Gsize*2,SL+Gsize*4,SW+Gsize*2+15,SL+Gsize*4+15);
buffer1=malloc(size1);
getimage(SW+Gsize*2,SL+Gsize*4,SW+Gsize*2+15,SL+Gsize*4+15,buffer1);
return w;
}
int main()
{
int driver=VGA,mode=VGAHI;
char key;
tail=NULL;
initgraph(&driver,&mode,"");
randomize();
tail=initmainwindow();
oldtime=getvect(0x1c);
while(1)
{
key=getkey();
switch(key)
{
case UP :
tail->direction=S;break;
case DOWN:
tail->direction=X;break;
case LEFT:
tail->direction=Z;break;
case RIGHT:
tail->direction=Y;break;
case ESC: closegraph();exit(1);
case SPACE :install(oldtime);break;
case ENTER :install(newtime);break;
}
}
}
void interrupt newtime()
{
int xx=1,yy=1;
char s[4];
SNAKE *p,*pend,*pp;
p=(SNAKE *)malloc(sizeof(SNAKE));
p->next=NULL;
if(timer++==3)
{
timer=0;
switch(tail->direction)
{
case S: if(grilled[tail->y-1][tail->x]==1) exit(1);
p->x=tail->x;p->y=tail->y-1;p->direction=tail->direction;p->next=NULL;
break;
case X: if(grilled[tail->y+1][tail->x]==1) exit(1);
p->x=tail->x;p->y=tail->y+1;p->direction=tail->direction;p->next=NULL;
break;
case Z: if(grilled[tail->y][tail->x-1]==1) exit(1);
p->x=tail->x-1;p->y=tail->y;p->direction=tail->direction;p->next=NULL;
break;
case Y: if(grilled[tail->y][tail->x+1]==1) exit(1);
p->x=tail->x+1;p->y=tail->y;p->direction=tail->direction;p->next=NULL;
break;
}
if(grilled[p->y][p->x]==2)
{
putimage(SW+Gsize*(p->x),SL+Gsize*(p->y),buffer1,XOR_PUT);
putimage(SW+Gsize*(p->x),SL+Gsize*(p->y),buffer,XOR_PUT);
grilled[p->y][p->x]=1;
p->next=tail;
tail=p;
rank++;
bar(375,390,400,420);
sprintf(s,"%d",rank);
setcolor(GREEN);
outtextxy(380,400,s);
do{
xx=random(14)+1;yy=random(19)+1;
}while((grilled[yy][xx]==1)||grilled[yy][xx]==2);
grilled[yy][xx]=2;
putimage(SW+Gsize*xx,SL+Gsize*yy,buffer1,XOR_PUT);
}
else
{
putimage(SW+Gsize*(p->x),SL+Gsize*(p->y),buffer,XOR_PUT);
grilled[p->y][p->x]=1;
p->next=tail;
tail=p;
pend=tail;
while(pend->next) {pp=pend;pend=pend->next;}
putimage(SW+Gsize*(pend->x),SL+Gsize*(pend->y),buffer,XOR_PUT);
grilled[pend->y][pend->x]=0;
pp->next=NULL;
}
}
}
void install(void interrupt (*hadder)())
{
disable();
setvect(0x1c,hadder);
enable();
}

相关文章

最新问题

热线 热线
400-118-6638
QQ QQ
QQ在线咨询
微信 微信
微信
关注 关注
关注
返回顶部

微信扫一扫

微信扫一扫