?? mapelement.java
字號:
/**
* Title: 吃豆子<p>
* Description: 小游戲<p>
* Copyright: Copyright (c) Nothing<p>
* Company: Raindrop<p>
* @author Nothing
* @version 1.0
*/
package eatbean;
import eatbean.util.*;
//
import java.awt.Image;
import java.util.Hashtable;
public abstract class MapElement {
protected static final int ELEMENT_MAX_SIZE = 16;
protected static final int ELEMENT_MIN_SIZE = 16;
protected int x, y;
protected int style;
protected int width, height;
public MapElement(int style, int x, int y) {
this.style = style;
this.x = x;
this.y = y;
parseWidthAndHeight();
}
abstract public void parseWidthAndHeight();
//public int getX() { return x; }
//public int getY() { return y; }
public int getWidth() { return width; }
public int getHeight() { return height; }
//protected int getOffsetX() { return (ELEMENT_MAX_SIZE-width)/2; }
//protected int getOffsetY() { return (ELEMENT_MAX_SIZE-height)/2; }
public int getTop() { return y; }
public int getLeft() { return x; }
public int getRight() { return x+width; }
public int getBottom() { return y+height; }
/** 此對象的位置描述方式有待改進(jìn) */
public Rect getRect() { return new Rect(x, y, width, height); } //有待改進(jìn)
protected Image getImage(Hashtable imgBuffTable, Hashtable styleTable, int imgIndex) {
Integer key = new Integer(imgIndex);
Image result = (Image)imgBuffTable.get(key);
if(result == null) {
String fileName = styleTable.get(key).toString();
result = ImageTool.getMapImage(fileName);
if(result != null) imgBuffTable.put(key, result);
}
return result;
}
abstract public void draw(OffScreen offScreen);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -