导航:首页 > 源码编译 > 推箱子源码

推箱子源码

发布时间:2022-02-16 13:39:58

A. 求助!!!哪个好心人有c语言推箱子源代码,发下,谢谢。(在vc++6.0里实现的哦,网上那些就不要

这个 太麻烦了,你要源码估计很少会有人静下心来 给你做这个东西的。既然是学习,那就自己好好构思,一点一点去设计、编码、调试,路都是这么走过来的。

B. 谁给个VB 推箱子的源代码啊,急求

VB推箱子游戏(完整源代码)

VB推箱子游戏完整源代码,带声音、画面清淅,如codefans.net截图演示,本游戏最大的亮点是可以自动寻找路径,可以选定关卡、设计关卡、打开、关闭声音特效,总体来说是非常不错的小游戏,对学习用VB编写小游戏的朋友很有一定帮助。

下载地址:

http://www.codefans.net/soft/4648.shtml

C. 求VC下的C++推箱子游戏源代码,300行至1000行,画面不用太花哨,有基本结构就行。[email protected]

已发送,请查收。
346211.。。。@qq.com

D. 有C语言课程设计案例精编(第二版)里推箱子的源代码吗

这个是有源码的,你去搜一下就好了

E. 求vc++6.0c语言推箱子或贪吃蛇源代码带图库的

#include<stdio.h>
#include<process.h>
#include<windows.h>
#include<conio.h>
#include<time.h>
#include<stdlib.h>
#define WIDTH 40
#define HEIGH 12
enum direction{//方向
LEFT,
RIGHT,
UP,
DOWN
};
struct Food{//食物
int x;
int y;
};
struct Node{//画蛇身
int x;
int y;
struct Node *next;
};
struct Snake{//蛇属性
int lenth;//长度
enum direction dir;//方向
};
struct Food *food; //食物
struct Snake *snake;//蛇属性
struct Node *snode,*tail;//蛇身
int SPEECH=200;
int score=0;//分数
int smark=0;//吃食物标记
int times=0;
int STOP=0;
void Initfood();//产生食物
void Initsnake();//构造snake
void Eatfood();//头部前进
void Addnode(int x, int y);//增加蛇身
void display(struct Node *shead);//显示蛇身坐标
void move();//蛇移动
void draw();//画蛇
void Homepage();//主页
void keybordhit();//监控键盘按键
void Addtail();//吃到食物
void gotoxy(int x, int y)//定位光标
{
COORD pos;
pos.X = x - 1;
pos.Y = y - 1;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
void Initsnake()//构造snake
{
int i;
snake=(struct Snake*)malloc(sizeof(struct Snake));
tail=(struct Node*)malloc(sizeof(struct Node));
food = (struct Food*)malloc(sizeof(struct Food));
snake->lenth=5;//初始长度 5
snake->dir=RIGHT;//初始蛇头方向 右
for(i=2;i<=snake->lenth+2;i++)//增加 5 个结点
{
Addnode(i,2);
}
}
void Initfood()//产生食物
{
struct Node *p=snode;
int mark=1;
srand((unsigned)time(NULL));//以时间为种子产生随机数
while(1)
{
food->x=rand()%(WIDTH-2)+2;//食物X坐标
food->y=rand()%(HEIGH-2)+2;//食物Y坐标
while(p!=NULL)
{
if((food->x==p->x)&&(food->y==p->y))//如果食物产生在蛇身上
{//则重新生成食物
mark=0;//食物生成无效
break;
}
p=p->next;
}
if(mark==1)//如果食物不在蛇身上,生成食物,否则重新生成食物
{
gotoxy(food->x,food->y);
printf("%c",3);
break;
}
mark=1;
p=snode;
}
}
void move()//移动
{
struct Node *q, *p=snode;
if(snake->dir==RIGHT)
{
Addnode(p->x+1,p->y);
if(smark==0)
{
while(p->next!=NULL)
{
q=p;
p=p->next;
}
q->next=NULL;
free(p);
}
}
if(snake->dir==LEFT)
{
Addnode(p->x-1,p->y);
if(smark==0)
{
while(p->next!=NULL)
{
q=p;
p=p->next;
}
q->next=NULL;
free(p);
}
}
if(snake->dir==UP)
{
Addnode(p->x,p->y-1);
if(smark==0)
{
while(p->next!=NULL)
{
q=p;
p=p->next;
}
q->next=NULL;
free(p);
}
}
if(snake->dir==DOWN)
{
Addnode(p->x,p->y+1);
if(smark==0)
{
while(p->next!=NULL)
{
q=p;
p=p->next;
}
q->next=NULL;
free(p);
}
}
}
void Addnode(int x, int y)//增加蛇身
{
struct Node *newnode=(struct Node *)malloc(sizeof(struct Node));
struct Node *p=snode;
newnode->next=snode;
newnode->x=x;
newnode->y=y;
snode=newnode;//结点加到蛇头
if(x<2||x>=WIDTH||y<2||y>=HEIGH)//碰到边界
{
STOP=1;
gotoxy(10,19);
printf("撞墙,游戏结束,任意键退出!\n");//失败
_getch();
free(snode);//释放内存
free(snake);
exit(0);
}
while(p!=NULL)//碰到自身
{
if(p->next!=NULL)
if((p->x==x)&&(p->y==y))
{
STOP=1;
gotoxy(10,19);
printf("撞到自身,游戏结束,任意键退出!\n");//失败
_getch();
free(snode);//释放内存
free(snake);
exit(0);
}
p=p->next;
}
}
void Eatfood()//吃到食物
{
Addtail();
score++;
}
void Addtail()//增加蛇尾
{
struct Node *newnode=(struct Node *)malloc(sizeof(struct Node));
struct Node *p=snode;
tail->next=newnode;
newnode->x=50;
newnode->y=20;
newnode->next=NULL;//结点加到蛇头
tail=newnode;//新的蛇尾
}
void draw()//画蛇
{
struct Node *p=snode;
int i,j;
while(p!=NULL)
{
gotoxy(p->x,p->y);
printf("%c",2);
tail=p;
p=p->next;
}
if(snode->x==food->x&&snode->y==food->y)//蛇头坐标等于食物坐标
{
smark=1;
Eatfood();//增加结点
Initfood();//产生食物
}
if(smark==0)
{
gotoxy(tail->x,tail->y);//没吃到食物清除之前的尾结点
printf("%c",' ');//如果吃到食物,不清楚尾结点
}
else
{
times=1;
}
if((smark==1)&&(times==1))
{
gotoxy(tail->x,tail->y);//没吃到食物清除之前的尾结点
printf("%c",' ');//如果吃到食物,不清楚尾结点
smark=0;
}
gotoxy(50,12);
printf("食物: %d,%d",food->x,food->y);
gotoxy(50,5);
printf("分数: %d",score);
gotoxy(50,7);
printf("速度: %d",SPEECH);
gotoxy(15,14);
printf("按o键加速");
gotoxy(15,15);
printf("按p键减速");
gotoxy(15,16);
printf("按空格键暂停");
}
void HideCursor()//隐藏光标
{
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}
void Homepage()//绘主页
{
int x,y;
HideCursor();//隐藏光标
printf("----------------------------------------\n");
printf("|\t\t\t\t |\n");
printf("|\t\t\t\t |\n");
printf("|\t\t\t\t |\n");
printf("|\t\t\t\t |\n");
printf("|\t\t\t\t |\n");
printf("|\t\t\t\t |\n");
printf("|\t\t\t\t |\n");
printf("|\t\t\t\t |\n");
printf("|\t\t\t\t |\n");
printf("|\t\t\t\t |\n");
printf("----------------------------------------\n");
gotoxy(5,13);
printf("任意键开始游戏!按W.A.S.D控制方向");
_getch();
Initsnake();
Initfood();
gotoxy(5,13);
printf(" ");
}
void keybordhit()//监控键盘
{
char ch;
if(_kbhit())
{
ch=getch();
switch(ch)
{
case 'W':
case 'w':if(snake->dir==DOWN)//如果本来方向是下,而按相反方向无效
{
break;
}
else
snake->dir=UP;break;
case 'A':
case 'a':if(snake->dir==RIGHT)//如果本来方向是右,而按相反方向无效
{
break;
}
else
snake->dir=LEFT;break;
case 'S':
case 's':if(snake->dir==UP)//如果本来方向是上,而按相反方向无效
{
break;
}
else
snake->dir=DOWN;break;
case 'D':
case 'd':if(snake->dir==LEFT)//如果本来方向是左,而按相反方向无效
{
break;
}
else
snake->dir=RIGHT;break;
case 'O':
case 'o':
if(SPEECH>=150)//速度加快
{
SPEECH=SPEECH-50;
}
break;
case 'P':
case 'p':
if(SPEECH<=400)//速度减慢
{
SPEECH=SPEECH+50;
}
break;
case ' '://暂停
gotoxy(15,18);
printf("游戏已暂停,按任意键恢复游戏");
system("pause>nul");
gotoxy(15,18);
printf(" ");
break;
default:break;
}
}
}
int main(void)//程序入口
{
Homepage();
while(!STOP)
{
keybordhit();//监控键盘按键
move();//蛇的坐标变化
draw();//蛇的重绘
Sleep(SPEECH);//暂时挂起线程
}
return 0;
}

F. 求助!!哪个大神有C语言推箱子源代码,求发下。(要直接在vc++6.0下能运行的,不需要太好,简单

你好!

推箱子游戏,共有 131 关,这是效果

G. 本人需要用java编写一个推箱子的小游戏 源代码有了 但是缺少做推箱子这小游戏的图片

package com.txz1;
import java.awt.Color;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class Txz {
public static void main(String[] args) {
JFrame frame = new JFrame("������1.0");//����
frame.setBounds(100, 20, 20 * 48 + 16, 14 * 48 + 38);//���ý���λ�úʹ�С

JPanel panel = new JPanel();//��壬�൱������
panel.setBackground(Color.red);//������ɫ
frame.setContentPane(panel);
panel.setLayout(null);//�Զ��壬���λ��
//�������
ImageIcon boxImg = new ImageIcon("box2.PNG");
JLabel box = new JLabel(boxImg);//��ǩ���൱������
panel.add(box);
box.setBounds(5 * 48, 3 * 48, 48, 48);
//��ӹ���
ImageIcon workerImg = new ImageIcon("workerDown2.png");
JLabel worker = new JLabel(workerImg);
panel.add(worker);
worker.setBounds(8 * 48, 8 * 48, 48, 48);
//����ϰ���
ImageIcon goalImg = new ImageIcon("goal2.png");
JLabel goal = new JLabel(goalImg);
panel.add(goal);
goal.setBounds(7 * 48, 6 * 48, 48, 48);
//���Χǽ
ImageIcon wallImg = new ImageIcon("wall2.PNG");
JLabel[] walls = new JLabel[100];

for (int i = 0; i < walls.length; i++) {
walls[i] = new JLabel(wallImg);
}
int index = 0;//������������ͳ��Χǽ����
for (int i = 0; i < 20; i++) {
panel.add(walls[index]);
walls[index].setBounds(i * 48, 0, 48, 48);
index++;
panel.add(walls[index]);
walls[index].setBounds(i * 48, 13 * 48, 48, 48);
index++;
}
for (int i = 0; i < 12; i++) {
panel.add(walls[index]);
walls[index].setBounds(0, (i + 1) * 48, 48, 48);
index++;
panel.add(walls[index]);
walls[index].setBounds(19 * 48, (i + 1) * 48, 48, 48);
index++;
}
for (int i = 0, j = 0; i < 5; i++, j += 2) {
panel.add(walls[index]);
walls[index].setBounds((i + 2) * 48, j * 48, 48, 48);
index++;
}
for (int i = 0, j = 10; i < 5; i++, j--) {
panel.add(walls[index]);
walls[index].setBounds((i + 12) * 48, j * 48, 48, 48);
index++;
}
//����Ϊ�ɼ��
frame.setVisible(true);
}
}

H. 谁有推箱子C语言源代码

/* 推箱子游戏 */
#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <conio.h>
#include <bios.h>
#include <alloc.h>
/* 定义二维数组ghouse来记录屏幕上各点的状态,
其中:0表示什么都没有,'b'表示箱子,'w'表示墙壁,'m'表示目的地,'i'表示箱子在目的地。 */
char ghouse[20][20];

/* 以下函数为直接写屏函数,很酷的函数哦!是我朋友告诉我的。 */
char far *screen=(char far* )0xb8000000;
void putchxy(int y,int x,char ch,char fc,char bc)
{
screen[(x*160)+(y<<1)+0]=ch;
screen[(x*160)+(y<<1)+1]=(bc*16)+fc;
}

/* 定义判断是否胜利的数据结构 */
typedef struct winer {
int x,y;
struct winer *p;
}winer;

/* 箱子位置的数据结构 */
typedef struct boxs {
int x,y;
struct boxs *next;
}boxs;

/* 在特定的坐标上画墙壁并用数组记录状态的函数 */
void printwall(int x,int y)
{
putchxy(y-1,x-1,219,MAGENTA,BLACK);
ghouse[x][y]='w';
}

/* 在特定的坐标上画箱子并用数组记录状态的函数 */
void printbox(int x,int y)
{
putchxy(y-1,x-1,10,WHITE,BLACK);
ghouse[x][y]='b';
}

/* 在特定的坐标上画目的地并用数组记录状态的函数 */
void printwhither1(int x,int y,winer **win,winer **pw)
{
winer *qw;
putchxy(y-1,x-1,'*',YELLOW,BLACK);
ghouse[x][y]='m';
if(*win==NULL)
{
*win=*pw=qw=(winer* )malloc(sizeof(winer));
(*pw)->x=x;(*pw)->y=y;(*pw)->p=NULL;
}
else
{
qw=(winer* )malloc(sizeof(winer));
qw->x=x;qw->y=y;(*pw)->p=qw;(*pw)=qw;qw->p=NULL;
}
}

/* 在特定的坐标上画目的地并用数组记录状态的函数 */
void printwhither(int x,int y)
{
putchxy(y-1,x-1,'*',YELLOW,BLACK);
ghouse[x][y]='m';
}
/* 在特定的坐标上画人的函数 */
void printman(int x,int y)
{
gotoxy(y,x);
_AL=02;_CX=01;_AH=0xa;
geninterrupt(0x10);
}

/* 在特定的坐标上画箱子在目的地上并用数组记录状态的函数 */
void printboxin(int x,int y)
{
putchxy(y-1,x-1,10,YELLOW,BLACK);
ghouse[x][y]='i';
}

/* 初始化函数,初始化数组和屏幕 */
void init()
{
int i,j;
system("cls");
for(i=0;i<20;i++)
for(j=0;j<20;j++)
ghouse[i][j]=0;
_AL=3;
_AH=0;
geninterrupt(0x10);
gotoxy(40,4);
printf("Welcome to push box world!");
gotoxy(40,6);
printf("Press up,down,left,right to play.");
gotoxy(40,8);
printf("Press Esc to quit it.");
gotoxy(40,10);
printf("Press space to reset the game.");
gotoxy(40,12);
printf("April 30th 2004.");
}

/* 第一关的图象初始化 */
winer *inithouse1()
{
int x,y;
winer *win=NULL,*pw;
gotoxy(8,2);
printf("Level No.1");
for(x=1,y=5;y<=9;y++)
printwall(x+4,y+10);
for(y=5,x=2;x<=5;x++)
printwall(x+4,y+10);
for(y=9,x=2;x<=5;x++)
printwall(x+4,y+10);
for(y=1,x=3;x<=8;x++)
printwall(x+4,y+10);
for(x=3,y=3;x<=5;x++)
printwall(x+4,y+10);
for(x=5,y=8;x<=9;x++)
printwall(x+4,y+10);
for(x=7,y=4;x<=9;x++)
printwall(x+4,y+10);
for(x=9,y=5;y<=7;y++)
printwall(x+4,y+10);
for(x=8,y=2;y<=3;y++)
printwall(x+4,y+10);
printwall(5+4,4+10);
printwall(5+4,7+10);
printwall(3+4,2+10);
printbox(3+4,6+10);
printbox(3+4,7+10);
printbox(4+4,7+10);
printwhither1(4+4,2+10,&win,&pw);
printwhither1(5+4,2+10,&win,&pw);
printwhither1(6+4,2+10,&win,&pw);
printman(2+4,8+10);
return win;
}

/* 第三关的图象初始化 */
winer *inithouse3()
{int x,y;
winer *win=NULL,*pw;
gotoxy(8,3);
printf("Level No.3");
for(x=1,y=2;y<=8;y++)
printwall(x+4,y+10);
for(x=2,y=2;x<=4;x++)
printwall(x+4,y+10);
for(x=4,y=1;y<=3;y++)
printwall(x+4,y+10);
for(x=5,y=1;x<=8;x++)
printwall(x+4,y+10);
for(x=8,y=2;y<=5;y++)
printwall(x+4,y+10);
for(x=5,y=5;x<=7;x++)
printwall(x+4,y+10);
for(x=7,y=6;y<=9;y++)
printwall(x+4,y+10);
for(x=3,y=9;x<=6;x++)
printwall(x+4,y+10);
for(x=3,y=6;y<=8;y++)
printwall(x+4,y+10);
printwall(2+4,8+10);
printwall(5+4,7+10);
printbox(6+4,3+10);
printbox(4+4,4+10);
printbox(5+4,6+10);
printwhither1(2+4,5+10,&win,&pw);
printwhither1(2+4,6+10,&win,&pw);
printwhither1(2+4,7+10,&win,&pw);
printman(2+4,4+10);
return win;
}

/* 第二关的图象初始化 */
winer *inithouse2()
{int x,y;
winer *win=NULL,*pw;
gotoxy(8,2);
printf("Level No.2");
for(x=1,y=4;y<=7;y++)
printwall(x+4,y+10);
for(x=2,y=2;y<=4;y++)
printwall(x+4,y+10);
for(x=2,y=7;x<=4;x++)
printwall(x+4,y+10);
for(x=4,y=1;x<=8;x++)
printwall(x+4,y+10);
for(x=8,y=2;y<=8;y++)
printwall(x+4,y+10);
for(x=4,y=8;x<=8;x++)
printwall(x+4,y+10);
for(x=4,y=6;x<=5;x++)
printwall(x+4,y+10);
for(x=3,y=2;x<=4;x++)
printwall(x+4,y+10);
for(x=4,y=4;x<=5;x++)
printwall(x+4,y+10);
printwall(6+4,3+10);
printbox(3+4,5+10);
printbox(6+4,6+10);
printbox(7+4,3+10);
printwhither1(5+4,7+10,&win,&pw);
printwhither1(6+4,7+10,&win,&pw);
printwhither1(7+4,7+10,&win,&pw);
printman(2+4,6+10);
return win;
}

/* 第四关的图象初始化 */
winer *inithouse4()
{int x,y;
winer *win=NULL,*pw;
gotoxy(8,2);
printf("Level No.4");
for(x=1,y=1;y<=6;y++)
printwall(x+4,y+10);
for(x=2,y=7;y<=8;y++)
printwall(x+4,y+10);
for(x=2,y=1;x<=7;x++)
printwall(x+4,y+10);
for(x=7,y=2;y<=4;y++)
printwall(x+4,y+10);
for(x=6,y=4;y<=9;y++)
printwall(x+4,y+10);
for(x=3,y=9;x<=5;x++)
printwall(x+4,y+10);
for(x=3,y=3;y<=4;y++)
printwall(x+4,y+10);
printwall(3+4,8+10);
printbox(3+4,5+10);
printbox(4+4,4+10);
printbox(4+4,6+10);
printbox(5+4,5+10);
printbox(5+4,3+10);
printwhither1(3+4,7+10,&win,&pw);
printwhither1(4+4,7+10,&win,&pw);
printwhither1(5+4,7+10,&win,&pw);
printwhither1(4+4,8+10,&win,&pw);
printwhither1(5+4,8+10,&win,&pw);
printman(2+4,2+10);
return win;
}

/* 移动在空地上的箱子到空地上 */
movebox(int x,int y,char a)
{switch(a)
{
case 'u':ghouse[x-1][y]=0;printf(" ");
printbox(x-2,y);printman(x-1,y);
ghouse[x-2][y]='b';break;
case 'd':ghouse[x+1][y]=0;printf(" ");
printbox(x+2,y);printman(x+1,y);
ghouse[x+2][y]='b';break;
case 'l':ghouse[x][y-1]=0;printf(" ");
printbox(x,y-2);printman(x,y-1);
ghouse[x][y-2]='b';break;
case 'r':ghouse[x][y+1]=0;printf(" ");
printbox(x,y+2);printman(x,y+1);
ghouse[x][y+2]='b';break;
default: break;
}
}

/* 移动在目的地上的箱子到空地上 */
moveinbox(int x,int y,char a)
{switch(a)
{
case 'u':ghouse[x-1][y]='m';printf(" ");
printbox(x-2,y);printman(x-1,y);
ghouse[x-2][y]='b';break;
case 'd':ghouse[x+1][y]='m';printf(" ");
printbox(x+2,y);printman(x+1,y);
ghouse[x+2][y]='b';break;
case 'l':ghouse[x][y-1]='m';printf(" ");
printbox(x,y-2);printman(x,y-1);
ghouse[x][y-2]='b';break;
case 'r':ghouse[x][y+1]='m';printf(" ");
printbox(x,y+2);printman(x,y+1);
ghouse[x][y+2]='b';break;
default: break;
}
}

/* 移动在空地上的箱子到目的地上 */
moveboxin(int x,int y,char a)
{switch(a)
{
case 'u':ghouse[x-1][y]=0;printf(" ");
printboxin(x-2,y);printman(x-1,y);
ghouse[x-2][y]='i';break;
case 'd':ghouse[x+1][y]=0;printf(" ");
printboxin(x+2,y);printman(x+1,y);
ghouse[x+2][y]='i';break;
case 'l':ghouse[x][y-1]=0;printf(" ");
printboxin(x,y-2);printman(x,y-1);
ghouse[x][y-2]='i';break;
case 'r':ghouse[x][y+1]=0;printf(" ");
printboxin(x,y+2);printman(x,y+1);
ghouse[x][y+2]='i';break;
default: break;
}
}

/* 移动在目的地上的箱子到目的地 */
moveinboxin(int x,int y,char a)
{switch(a)
{
case 'u':ghouse[x-1][y]='m';printf(" ");
printboxin(x-2,y);printman(x-1,y);
ghouse[x-2][y]='i';break;
case 'd':ghouse[x+1][y]='m';printf(" ");
printboxin(x+2,y);printman(x+1,y);
ghouse[x+2][y]='i';break;
case 'l':ghouse[x][y-1]='m';printf(" ");
printboxin(x,y-2);printman(x,y-1);
ghouse[x][y-2]='i';break;
case 'r':ghouse[x][y+1]='m';printf(" ");
printboxin(x,y+2);printman(x,y+1);
ghouse[x][y+2]='i';break;
default: break;
}
}

/* 判断特定的坐标上的状态 */
int judge(int x,int y)
{int i;
switch(ghouse[x][y])
{
case 0: i=1;break;
case 'w': i=0;break;
case 'b': i=2;break;
case 'i': i=4;break;
case 'm': i=3;break;
default: break;
}
return i;
}

/* 处理按下键盘后,人物移动的主函数 */
move(int x,int y,char a)
{switch(a)
{
case 'u':if(!judge(x-1,y)) {gotoxy(y,x);break;}
else if(judge(x-1,y)==1||judge(x-1,y)==3)
{if(judge(x,y)==3)
{ printwhither(x,y);printman(x-1,y);break;}
else
{printf(" ");printman(x-1,y);break;}
}
else if(judge(x-1,y)==2)
{ if(judge(x-2,y)==1)
{movebox(x,y,'u');
if(judge(x,y)==3) printwhither(x,y); gotoxy(y,x-1);
}
else if(judge(x-2,y)==3)
{ moveboxin(x,y,'u');
if(judge(x,y)==3) printwhither(x,y); gotoxy(y,x-1);
}
else gotoxy(y,x);
break;
}
else if(judge(x-1,y)==4)
{ if(judge(x-2,y)==1)
{moveinbox(x,y,'u');
if(judge(x,y)==3) printwhither(x,y);gotoxy(y,x-1);
}
else if(judge(x-2,y)==3)
{ moveinboxin(x,y,'u');
if(judge(x,y)==3) printwhither(x,y);gotoxy(y,x-1);
}
else gotoxy(y,x);
break;
}
case 'd':if(!judge(x+1,y)) {gotoxy(y,x);break;}
else if(judge(x+1,y)==1||judge(x+1,y)==3)
{if(judge(x,y)==3)
{ printwhither(x,y);printman(x+1,y);break;}
else
{printf(" ");printman(x+1,y);break;}
}
else if(judge(x+1,y)==2)
{ if(judge(x+2,y)==1)
{movebox(x,y,'d');
if(judge(x,y)==3) printwhither(x,y);gotoxy(y,x+1);
}
else if(judge(x+2,y)==3)
{moveboxin(x,y,'d');
if(judge(x,y)==3) printwhither(x,y);gotoxy(y,x+1);
}
else gotoxy(y,x);
break;
}
else if(judge(x+1,y)==4)
{ if(judge(x+2,y)==1)
{moveinbox(x,y,'d');
if(judge(x,y)==3) printwhither(x,y);gotoxy(y,x+1);
}
else if(judge(x+2,y)==3)
{moveinboxin(x,y,'d');
if(judge(x,y)==3) printwhither(x,y);gotoxy(y,x+1);
}
else gotoxy(y,x);
break;
}

case 'l':if(!judge(x,y-1)) {gotoxy(y,x);break;}
else if(judge(x,y-1)==1||judge(x,y-1)==3)
{if(judge(x,y)==3)
{ printwhither(x,y);printman(x,y-1);break;}
else
{printf(" ");printman(x,y-1);break;}
}
else if(judge(x,y-1)==2)
{ if(judge(x,y-2)==1)
{movebox(x,y,'l');
if(judge(x,y)==3) printwhither(x,y); gotoxy(y-1,x);
}
else if(judge(x,y-2)==3)
{moveboxin(x,y,'l');
if(judge(x,y)==3) printwhither(x,y); gotoxy(y-1,x);
}
else gotoxy(y,x);
break;
}
else if(judge(x,y-1)==4)
{ if(judge(x,y-2)==1)
{moveinbox(x,y,'l');
if(judge(x,y)==3) printwhither(x,y); gotoxy(y-1,x);
}
else if(judge(x,y-2)==3)
{moveinboxin(x,y,'l');
if(judge(x,y)==3) printwhither(x,y); gotoxy(y-1,x);
}
else gotoxy(y,x);
break;
}
case 'r':if(!judge(x,y+1)) {gotoxy(y,x);break;}
else if(judge(x,y+1)==1||judge(x,y+1)==3)
{if(judge(x,y)==3)
{printwhither(x,y);printman(x,y+1);break;}
else
{printf(" ");printman(x,y+1);break;}
}
else if(judge(x,y+1)==2)
{ if(judge(x,y+2)==1)
{movebox(x,y,'r');
if(judge(x,y)==3) printwhither(x,y); gotoxy(y+1,x);
}
else if(judge(x,y+2)==3)
{moveboxin(x,y,'r');
if(judge(x,y)==3) printwhither(x,y); gotoxy(y+1,x);
}
else gotoxy(y,x);
break;
}
else if(judge(x,y+1)==4)
{ if(judge(x,y+2)==1)
{moveinbox(x,y,'r');
if(judge(x,y)==3) printwhither(x,y); gotoxy(y+1,x);
}
else if(judge(x,y+2)==3)
{moveinboxin(x,y,'r');
if(judge(x,y)==3) printwhither(x,y); gotoxy(y+1,x);
}
else gotoxy(y,x);
break;
}
default: break;
}
}

/* 按下空格键后,回到本关开头的函数 */
void reset(int i)
{switch(i)
{
case 0: init();
inithouse1();break;
case 1: init();
inithouse2();break;
case 2: init();
inithouse3();break;
case 3: init();
inithouse4();break;
default:break;
}
}

/* 主函数main */
main()
{int key,x,y,s,i=0;
winer *win,*pw;
_AL=3;_AH=0;
geninterrupt(0x10);
init();
win=inithouse1();
do{
_AH=3;
geninterrupt(0x10);
x=_DH+1;y=_DL+1;
while(bioskey(1)==0);
key=bioskey(0);
switch(key)
{
case 0x4800:move(x,y,'u');break; /* 按下向上键后 */
case 0x5000:move(x,y,'d');break; /* 按下向下键后 */
case 0x4b00:move(x,y,'l');break; /* 按下向左键后 */
case 0x4d00:move(x,y,'r');break; /* 按下向右键后 */
case 0x3920:reset(i);break; /* 按下空格键后 */
default:break;
}
s=0;
pw=win;
while(pw)
{
if(ghouse[pw->x][pw->y]=='m') s++;
pw=pw->p;
}
if(s==0)
{
free(win);
gotoxy(25,2);
printf("Congratulate! You have passed Level %d!",i+1);
getch();
i++;
switch(i)
{
case 1: init();
win=inithouse2();break;
case 2: init();
win=inithouse3();break;
case 3: init();
win=inithouse4();break;
case 4: gotoxy(8,14);
printf("Great! You have passed all the levels! Press any key to quit!");
key=0x011b;getch();break;
default: break;
}
}
}while(key!=0x011b);
_AL=3;
_AH=0;
geninterrupt(0x10);
}

I. 程序设计用WIN32编的游戏运行程序,最好是推箱子的源代码和运行。

你最好网络一下看看

J. 如何将推箱子源代码导入到Ecilpse

我当时做地图时用到一些语句: data 1//表示关卡关数 data 00000000000000//地图第一行 data 00011111111100//地图第二行 data 00012223222100 data 00012224222100 data 00012225222100 data 00011111111100 data 00000000000000 (数字是随便编的)作为地图时这样理解: 0表示墙外空地,1表示墙,2表示墙内空地,3表示箱子指定地,4表示箱子,5表示小人初始位置。 那么当你设计好地图时,只需在data内对应的写好地图信息编号,那么就能直接读出地图来了,我想文本文档应该是同样的道理,你可以改成: map 1 line 00000000000000 line line 00011111111100 line line 00012223222100 line line 00012224222100 line line 00012225222100 line line 00011111111100 line line 00000000000000 line 读取关键字进行讨论。 或者用xml之类的语言解析下就好了。 希望对你有帮助。

阅读全文

与推箱子源码相关的资料

热点内容
混凝土结构中册pdf 浏览:928
永劫无间解压不了怎么回事 浏览:806
php如何开启curl 浏览:671
红黄文件夹 浏览:122
违背皇帝的命令是死罪吗 浏览:66
phpcurl处理错误 浏览:459
linuxftp防火墙端口设置 浏览:788
java面板图片 浏览:482
泰拉瑞亚14安卓版怎么操作 浏览:718
安卓手机相册加密软件 浏览:51
免费云服务器能永久使用吗 浏览:703
吉利配件大全吉利压缩机 浏览:817
人类怎么能听出小猫的叫声app 浏览:904
大众安卓大屏如何显示原车信息 浏览:551
纸质电话数据加密法 浏览:178
linux弹出光盘命令 浏览:273
java加密jar包防止反编译 浏览:403
redhatlinux安装mysql 浏览:695
怎么把word和ppt放在一个文件夹 浏览:143
pdf优化器 浏览:135