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

📄 monster.java

📁 龙与地下城游戏(小型)的设计与实现。主要是随机产生地牢
💻 JAVA
字号:
package dungeonsanddragons.model.monsters;import dungeonsanddragons.model.weapons.Weapon;import dungeonsanddragons.model.*;import java.awt.Graphics;/** * Class representing a monster (super class to all types of monsters) * @author Sandra Nilsson */public class Monster extends Showable {    /**     * The power of this monster     */    protected int power;  private static String soundFileName = "sound/chewy.wav";    /**     * Create a new monster represented by the given image     * @param imgName the image file name     */    public Monster(String imgName) {        super(imgName,soundFileName);    }    /**     * Create a new monster represented by the given image     * @param imgName the image file name     * @param soundName the sound file name     */    public Monster(String imgName, String soundName) {        super(imgName, soundName);    }    /**     * Check if the monster is killed by the given weapon     * @param w the weapon     * @return true if this monster is killed by the given weapon     */    public boolean killedBy(Weapon w) {        return w.getStrenght() >= power;    }    /**     * Kill this monster (that is, remove it from its room)     */    public void kill() {        currentRoom.setItem(null);        currentRoom = null;        play();    }    /**     * Get the power of this monster     * @return the power of this monster     */    public int getPower() {        return power;    }    /**     * Draw this Monster. Calls the draw in the super class (Showable)      * then it also draws the value of itself     * @param g the graphics to draw on.     */    public void draw(Graphics g) {        if (currentRoom != null) {            super.draw(g);            g.drawString("" + power, currentRoom.getX() + 50, currentRoom.getY() + 60);        }    }}

⌨️ 快捷键说明

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