2.5D推箱子游戏

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

import java.awt.Color;

import java.awt.Graphics;

import java.awt.Graphics2D;

import java.awt.Image;

import java.awt.Toolkit;

import java.awt.event.KeyEvent;

import java.awt.event.KeyListener;

import java.awt.geom.GeneralPath;

import javax.swing.JPanel;

public class PushBox extends JPanel implements KeyListener{ private Image pic[] = null; // 图片

int initX=200,initY=70;

//map1为第一层,map2为第二层

private int [][]map1={//第一层地图,即地板层

{-1,-1,-1,1, 0, 1, 0, 1,-1,-1,-1,-1,-1,-1},

{-1,-1,-1,0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0},

{0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 3, 0, 1},

{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0},

{0, 1, 0, 1, 0, 3, 0, 1, 0, 1, 0, 1, 0, 1},

{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0},

{0, 1, 0, 1, 0, 1, 0, 3, 0, 1, 0, 1, 0, 1},

{1, 0, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0},

{0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1},

{1, 0, 3, 0, 1, 0, 1, 0, 1, 0, 1, 2, 1, 0},

{0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1},

{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0},

{0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,-1,-1,-1},

{1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,-1,-1,-1}

};

private int [][]map2={//第二层地图,建筑物或人

{-1,-1,-1,2, 2, 2, 2, 2,-1,-1,-1,-1,-1,-1},

{-1,-1,-1,2, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2},

{2, 2, 2, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2},

{2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 2},

{2, 0, 0, 0, 1, 0, 2, 0, 0, 2, 0, 0, 0, 2},

{2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0, 2},

{2, 0, 2, 2, 0, 0, 0, 0, 0, 2, 0, 1, 0, 2},

{2, 0, 0, 0, 1, 2, 2, 0, 0, 0, 1, 0, 0, 2},

{2, 0, 0, 0, 0, 2, 2, 0, 0, 0, 2, 2, 0, 2},

{2, 0, 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 2},

{2, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 2},

{2, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2},

{2, 0, 0, 0, 0, 0, 0, 2, 0, 0, 2,-1,-1,-1},

{2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,-1,-1,-1}

};

// 定义一些常量,对应地图的元素

final byte WALL = 1, BOX = 2, BOXONEND = 3, END = 4, MANDOWN = 5, MANLEFT = 6, MANRIGHT = 7, MANUP = 8, GRASS = 9, MANDOWNONEND = 10,

MANLEFTONEND = 11, MANRIGHTONEND = 12, MANUPONEND = 13;

private int row = 7, column = 7; //int manx,many;

// 加载图片

Image box=Toolkit.getDefaultToolkit().getImage("images\\box.png");

Image wall =

Toolkit.getDefaultToolkit().getImage("images\\wall.png");

Image greenBox=

Toolkit.getDefaultToolkit().getImage("images\\greenbox.png");

Image man =

Toolkit.getDefaultToolkit().getImage("images\\a1.png");//人物Image background=

相关文档
最新文档