door.java

来自「a java game code for java」· Java 代码 · 共 47 行

JAVA
47
字号
/** * 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.*;import java.util.*;/** 程序中暂未使用此类,也未完全实现 */public class Door extends MapElement {	public static final int BASE_NUM = 10;	public static final int STYLE_DEFAULT = BASE_NUM + 1;	private static Hashtable styleTable = new Hashtable();	static {	    styleTable.put(new Integer(STYLE_DEFAULT), "d0.gif");	}	private Image img = null;	private static Hashtable imgBuffTable = new Hashtable();    public Door(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);	}	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 + =
减小字号Ctrl + -
显示快捷键?