freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

基于swing開(kāi)發(fā)的推箱子游戲的設(shè)計(jì)與實(shí)現(xiàn)(編輯修改稿)

2025-07-24 18:44 本頁(yè)面
 

【文章內(nèi)容簡(jiǎn)介】 map。 } public GamePanel() { (600, 500)。 ()。 backImage = ()。 // 初始化背景圖片 // heroImage = ()。 //英雄的圖片 // me=()。 new D().start()。// 啟動(dòng)線程 } @Override public void paint(Graphics g) { (backImage, 0, 0, , this)。// 畫(huà)出背景圖片 (me, 0, 0, null)。 boolean yes6 = (g)。// 畫(huà)地圖 if (yes6) { // 到下一關(guān) ()。 (g)。// 畫(huà)地圖 } // 畫(huà)英雄 (g)。// 調(diào)用英雄的的畫(huà)的方法,將并將畫(huà)筆g傳遞過(guò)去,畫(huà)出英雄 } // 該 方法用于改變英雄運(yùn)行的方向 public void setHeroF(int f) { (f)。// 將方向的改傳給英雄 (true)。// 因?yàn)榘戳随I所以可以移動(dòng) } // 使用線程來(lái)完成,內(nèi)部類:寫(xiě)在類里面的類 class D extends Thread { public void run() {// 方法必須這么寫(xiě) while (true) { try { (40)。 } catch (InterruptedException e) { // TODO Autogenerated catch block ()。 } ()。 // 調(diào)用這個(gè)D對(duì)象外面的repaint() } } } public Hero getHero() { return hero。 } public void setHero(Hero hero) { = hero。 }} 圖片加載區(qū) 這個(gè)區(qū)域主要負(fù)責(zé)加載各類型的圖片,使界面變得美觀等條件。圖片加載區(qū)總代碼:package frame。import 。import 。import 。import 。public class ImageUtil { public Image getImage(String imageUrl) { Image image = null。 try { // 會(huì)將圖片加載在內(nèi)存中 image = (().getClassLoader() .getResourceAsStream(image/ + imageUrl))。 } catch (IOException e) { // TODO Autogenerated catch block ()。 } return image。 }} 英雄變化區(qū)這個(gè)區(qū)域主要負(fù)責(zé)英雄的變化,如下:: // 存放英雄起始位置的坐標(biāo) private int heroX = 200。 private int heroY = 200。: private int f = 0。// 0=向下 1=向左 2=向右 3=向上: public void draw(Graphics g) { if (isMoving) { moving()。// 移動(dòng)英雄 } // (heroImage, 0, 0, 32, 32, 200, 200, 232, 232, this)。 // 在屏幕上的左上角的X,Y和 屏幕上的右下角X,Y,之間, // 圖片的左上角X,Y,圖片上右下角 // (heroImage, heroX, heroY, heroX+32, heroY+32,0,0,32,32, // null)。//向下 (heroImage, heroX, heroY, heroX + 32, heroY + 32, 0, 32 * f, 32, 32 * (f + 1), null)。// 控制上下左右的圖片 }: public void moving() { switch (f) { case 0: if (peng()) { heroY += 32。 } break。 case 1: if (peng()) { heroX = 32。 } break。 case 2: if (peng()) { heroX += 32。 } break。 case 3: if (peng()) { heroY = 32。 } break。 } isMoving = false。 // 每移動(dòng)一次就停止 // (現(xiàn)在英雄的坐標(biāo)是:+heroX++heroY)。 },返回能走還是不能走 public boolean peng() { // 1. 得到英雄在地圖中的位置 int row = (heroY 100) / 32。 int column = (heroX 100) / 32。 // 2. 根椐英雄的位置及行進(jìn)的方向,判斷地圖上是否可以行走 switch (f) { // 0=向下 1=向左 2=向右 3=向上 case 0: // 得到地圖對(duì)象中的地圖數(shù)組 if (().getMap()[row + 1][column] == 2 || ().getMap()[row + 1][column] == 6) { return true。 } if (().getMap()[row + 1][column] == 10) { // 前面是魔王 if (().getMap()[row + 2][column] == 2) { // 前面前面是地板 ().getMap()[row + 1][column] = 2。 ().getMap()[row + 2][column] = 10。 return true。 } if (().getMap()[row + 2][column] == 6) { // 前面前面是籠子 ().getMap()[row + 1][column] = 2。 ().getMap()[row + 2][column] = 14。 return true。 } } if (().getMap()[row + 1][column] == 14) { // 前面是帶籠子魔王 if (().getMap()[row + 2][column] == 2) { // 前面前面是地板 ().getMap()[row + 1][column] = 6。 // 前面就變成籠子 ().getMap()[row + 2][column] = 10。 // 前面的前面變成了魔王 return true。 } if (().getMap()[row + 2][column] == 6) { // 前面前面是籠子 ().getMap()[row + 1][column] = 6。 // 前面變成籠子 ().getMap()[row + 2][column] = 14。 // 前面前面變成帶籠子的魔王 return true。 } } break。 case 1: if (().getMap()[row][column 1] == 2 || ().getMap()[row][column 1] == 6) { return true。 } if (().getMap()[row][column 1] == 10) { // 前面是魔王 if (().getMap()[row][column 2] == 2) { // 前面前面是地板 ().getMap()[row][column 1] = 2。 ().getMap()[row][column 2] = 10。 return true。 } if (().getMap()[row][column 2] == 6) { // 前面前面是籠子 ().getMap()[row][column 1] = 2。 ().getMap()[row][column 2] = 14。 return true。 } } if (().getMap()[row][column 1] == 14) { // 前面是帶籠子魔王 if (().getMap()[row][column 2] == 2) { // 前面前面是地板 ().getMap()[row][column 1] = 6。 // 前面就變成籠子 ().getMap()[row][column 2] = 10。 // 前面的前面變成了魔王 return true。 } if (().getMap()[row
點(diǎn)擊復(fù)制文檔內(nèi)容
語(yǔ)文相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1