?? room.java
字號:
/** * Title: 吃豆子<p> * Description: 小游戲<p> * Copyright: Copyright (c) Nothing<p> * Company: Raindrop<p> * @author Nothing * @version 1.0 */package eatbean;import eatbean.util.ImageTool;//import java.awt.*;import java.util.Hashtable;public class Room extends MapElement { public static final int BASE_NUM = 20; public static final int STYLE_DEFAULT = BASE_NUM + 1; public static final int STYLE_EMPTY = BASE_NUM + 2; public static final int STYLE_SPRITE_BORN = BASE_NUM + 3; public static final int STYLE_FAIRY_BORN = BASE_NUM + 4; private static Hashtable styleTable = new Hashtable(); static { styleTable.put(new Integer(STYLE_DEFAULT), "r1.gif"); styleTable.put(new Integer(STYLE_EMPTY), "r0.gif"); styleTable.put(new Integer(STYLE_SPRITE_BORN), "r0.gif"); styleTable.put(new Integer(STYLE_FAIRY_BORN), "r0.gif"); } public static final int POINT = 10; private Image img = null; private static Hashtable imgBuffTable = new Hashtable(); public Room(int style, int x, int y) { super(style, x, y); img = getImage(style); } public void parseWidthAndHeight() { width = ELEMENT_MAX_SIZE; height = ELEMENT_MAX_SIZE; } public void draw(OffScreen offScreen) { offScreen.drawImage(img, x, y); } public void setEmpty() { if(style == STYLE_EMPTY) return; style = STYLE_EMPTY; img = getImage(style); } public boolean isEmpty() { return !(style == STYLE_DEFAULT); } private Image getImage(int imgIndex) { Image result = null; synchronized(imgBuffTable) { // 同步,保證同一個Image不被調入內存兩次 result = super.getImage(imgBuffTable, styleTable, imgIndex); } return result; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -