導航:首頁 > 源碼編譯 > 推箱子源碼

推箱子源碼

發布時間: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海綿 瀏覽:290
命令一加一 瀏覽:391
linuxutf8bom 瀏覽:135
3d導航軟體源碼 瀏覽:66
惠州雙月灣那邊用什麼買菜app 瀏覽:936
反編譯優化java軟體 瀏覽:541
鴻蒙如何離線編譯 瀏覽:361
日輕PDF 瀏覽:602
m的命令 瀏覽:397
mate9什麼時候升級安卓10 瀏覽:577
java集合的原理 瀏覽:561
軟體如何掛雲伺服器 瀏覽:542
未來警察日劇解壓密碼 瀏覽:424
用手機看pdf用什麼app 瀏覽:97
android拍照水印 瀏覽:34
廢紙壓縮站效果怎麼樣 瀏覽:864
伺服器埠怎麼分享文件 瀏覽:894
貓餅安裝文件夾 瀏覽:1002
qq私發能發文件夾嗎 瀏覽:631
什麼小說剛上架伺服器崩了 瀏覽:158