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

📄 hangmanapplet.java

📁 WebHangman a game can be play on the website contain the total code of JAVA
💻 JAVA
字号:
package com.aztsoft.games.hangman;

import com.aztsoft.games.util.ImageLoader;
import com.aztsoft.games.util.GameLogger;

import java.io.IOException;
import java.applet.Applet;
import java.awt.*;

/**
 * User: azt
 * Date: 04-Sep-2005
 * Time: 14:54:27
 * This is a Simple Hangman Applet that fetches images from search engines
 * to help the player to find the words.
 * It was developed in few hours using code that I had written before
 * for a j2me version. This is the reason why some of the implementation
 * does not make sense. i.e. defining rather than using a button class
 */
public class HangmanApplet extends Applet {

    private Image[] gpImageArray;
    private Image gpHunged;
    private HangmanPanel hangmanPanel;
    private HangmanGame hangmanGame;
    public static HangmanApplet hangmanApplet;

    public HangmanApplet() {
        GameLogger.log("applet constructed");
        hangmanApplet = this;
    }

    public void init() {
        super.init();
        initGame();
        initGraphics();
    }


    private void initGraphics() {
        setBackground(Color.black);
        loadGraphics();
        Dimension dimen = new Dimension(getWidth(), getHeight());
        GameLogger.log("width=" + getWidth() + " height=" + getHeight());
        hangmanPanel = new HangmanPanel(dimen, hangmanGame, gpImageArray, gpHunged);
        setLayout(new GridLayout(1, 1, 5, 5));
        add(hangmanPanel);
        setVisible(true);
    }

    public void start() {
        super.start();
        GameLogger.log("applet started");
        playGame();
    }

    private void initGame() {
        GameLogger.log("making the game");
        hangmanGame = new HangmanGame(getSize());
    }

    public void playGame() {
        GameLogger.log("playing the game");
        hangmanGame.startGame();
        hangmanPanel.startGame();
    }

    public void stop() {
        super.stop();
        GameLogger.log("stop called");
    }

    public void destroy() {
        super.destroy();
        GameLogger.log("destroy called");
    }

    private void loadGraphics() {
        gpImageArray = new Image[8];
        try {
            for (int i = 0; i < gpImageArray.length; i++) {
                gpImageArray[i] = ImageLoader.loadImage("resources/images/gp" + i + ".jpg", this);
            }
            gpHunged = ImageLoader.loadImage("images/gpH.jpg", this);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

⌨️ 快捷键说明

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