⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mapelement.java

📁 a java game code for java
💻 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; }
	/** 此对象的位置描述方式有待改进 */
	public Rect getRect() { return new Rect(x, y, width, height); }	//有待改进
	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);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -