亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tumbleweedgame.java

?? /* Title: J2ME Games With MIDP2 Authors: Carol Hamer Publisher: Apress ISBN: 1590593820 */
?? JAVA
?? 第 1 頁 / 共 4 頁
字號:
/*
 Title:  J2ME Games With MIDP2
 Authors:  Carol Hamer
 Publisher:  Apress
 ISBN:   1590593820
 */

import javax.microedition.media.*;
import javax.microedition.media.control.*;

import java.util.Random;

import javax.microedition.lcdui.game.*;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

/**
 * This is the main class of the tumbleweed game.
 * 
 * @author Carol Hamer
 */
public class Jump extends MIDlet implements CommandListener {

  //---------------------------------------------------------
  //   commands

  /**
   * the command to end the game.
   */
  private Command myExitCommand = new Command("Exit", Command.EXIT, 99);

  /**
   * the command to start moving when the game is paused.
   */
  private Command myGoCommand = new Command("Go", Command.SCREEN, 1);

  /**
   * the command to pause the game.
   */
  private Command myPauseCommand = new Command("Pause", Command.SCREEN, 1);

  /**
   * the command to start a new game.
   */
  private Command myNewCommand = new Command("Play Again", Command.SCREEN, 1);

  /**
   * The command to start/pause the music. (This command may appear in a menu)
   */
  private Command myMusicCommand = new Command("Music", Command.SCREEN, 2);

  //---------------------------------------------------------
  //   game object fields

  /**
   * the the canvas that all of the game will be drawn on.
   */
  private JumpCanvas myCanvas;

  //---------------------------------------------------------
  //   thread fields

  /**
   * the thread that advances the cowboy.
   */
  private GameThread myGameThread;

  /**
   * The class that plays music if the user wants.
   */
  //private MusicMaker myMusicMaker;
  private ToneControlMusicMaker myMusicMaker;

  /**
   * The thread tha sets tumbleweeds in motion at random intervals.
   */
  private TumbleweedThread myTumbleweedThread;

  /**
   * if the user has paused the game.
   */
  private boolean myGamePause;

  /**
   * if the game is paused because it is hidden.
   */
  private boolean myHiddenPause;

  //-----------------------------------------------------
  //    initialization and game state changes

  /**
   * Initialize the canvas and the commands.
   */
  public Jump() {
    try {
      myCanvas = new JumpCanvas(this);
      myCanvas.addCommand(myExitCommand);
      myCanvas.addCommand(myMusicCommand);
      myCanvas.addCommand(myPauseCommand);
      myCanvas.setCommandListener(this);
    } catch (Exception e) {
      errorMsg(e);
    }
  }

  /**
   * Switch the command to the play again command.
   */
  void setNewCommand() {
    myCanvas.removeCommand(myPauseCommand);
    myCanvas.removeCommand(myGoCommand);
    myCanvas.addCommand(myNewCommand);
  }

  /**
   * Switch the command to the go command.
   */
  private void setGoCommand() {
    myCanvas.removeCommand(myPauseCommand);
    myCanvas.removeCommand(myNewCommand);
    myCanvas.addCommand(myGoCommand);
  }

  /**
   * Switch the command to the pause command.
   */
  private void setPauseCommand() {
    myCanvas.removeCommand(myNewCommand);
    myCanvas.removeCommand(myGoCommand);
    myCanvas.addCommand(myPauseCommand);
  }

  //----------------------------------------------------------------
  //  implementation of MIDlet
  // these methods may be called by the application management
  // software at any time, so we always check fields for null
  // before calling methods on them.

  /**
   * Start the application.
   */
  public void startApp() throws MIDletStateChangeException {
    try {
      if (myCanvas != null) {
        myCanvas.start();
        myCanvas.flushKeys();
        systemStartThreads();
      }
    } catch (Exception e) {
      errorMsg(e);
    }
  }

  /**
   * stop and throw out the garbage.
   */
  public void destroyApp(boolean unconditional)
      throws MIDletStateChangeException {
    try {
      stopThreads();
      myCanvas = null;
      System.gc();
    } catch (Exception e) {
      errorMsg(e);
    }
  }

  /**
   * request the game to pause. This method is called by the application
   * management software, not in response to a user pausing the game.
   */
  public void pauseApp() {
    try {
      if (myCanvas != null) {
        setGoCommand();
        systemPauseThreads();
      }
    } catch (Exception e) {
      errorMsg(e);
    }
  }

  //----------------------------------------------------------------
  //  implementation of CommandListener

  /*
   * Respond to a command issued on the Canvas. (either reset or exit).
   */
  public void commandAction(Command c, Displayable s) {
    try {
      if (c == myGoCommand) {
        myCanvas.removeCommand(myGoCommand);
        myCanvas.addCommand(myPauseCommand);
        myCanvas.flushKeys();
        userStartThreads();
      } else if (c == myPauseCommand) {
        myCanvas.removeCommand(myPauseCommand);
        myCanvas.addCommand(myGoCommand);
        userPauseThreads();
      } else if (c == myNewCommand) {
        myCanvas.removeCommand(myNewCommand);
        myCanvas.addCommand(myPauseCommand);
        System.gc();
        myCanvas.reset();
        myCanvas.flushKeys();
        myHiddenPause = false;
        myGamePause = false;
        startThreads();
      } else if (c == myMusicCommand) {
        if (myMusicMaker != null) {
          myMusicMaker.toggle();
          myCanvas.repaint();
          myCanvas.serviceRepaints();
        }
      } else if ((c == myExitCommand)/* || (c == Alert.DISMISS_COMMAND)*/) {
        try {
          destroyApp(false);
          notifyDestroyed();
        } catch (MIDletStateChangeException ex) {
        }
      }
    } catch (Exception e) {
      errorMsg(e);
    }
  }

  //-------------------------------------------------------
  //  thread methods

  /**
   * start up all of the game's threads. Creates them if necessary. to be
   * called when the user hits the go command.
   */
  private synchronized void userStartThreads() throws Exception {
    myGamePause = false;
    if (!myHiddenPause) {
      startThreads();
    }
  }

  /**
   * start up all of the game's threads. Creates them if necessary. used by
   * showNotify
   */
  synchronized void systemStartThreads() throws Exception {
    myHiddenPause = false;
    if (!myGamePause) {
      startThreads();
    }
  }

  /**
   * start up all of the game's threads. Creates them if necessary. internal
   * version. note: if this were synchronized, whould it cause deadlock?
   */
  private void startThreads() throws Exception {
    if (myGameThread == null) {
      myGameThread = new GameThread(myCanvas);
      myGameThread.start();
    } else {
      myGameThread.resumeGame();
    }
    if (myTumbleweedThread == null) {
      myTumbleweedThread = new TumbleweedThread(myCanvas);
      myTumbleweedThread.start();
    } else {
      myTumbleweedThread.resumeGame();
    }
    if (myMusicMaker == null) {
      myMusicMaker = new ToneControlMusicMaker();
      //myMusicMaker = new MusicMaker();
      myMusicMaker.start();
    } else {
      myMusicMaker.resumeGame();
    }
  }

  /**
   * Pause all of the threads started by this game. to be called when the user
   * hits the pause command.
   */
  synchronized void userPauseThreads() {
    myGamePause = true;
    pauseThreads();
  }

  /**
   * Pause all of the threads started by this game. used by hideNotify
   */
  void systemPauseThreads() {
    myHiddenPause = true;
    pauseThreads();
  }

  /**
   * start up all of the game's threads. Creates them if necessary. internal
   * version. note: if this were synchronized, whould it cause deadlock?
   */
  private void pauseThreads() {
    if (myGameThread != null) {
      myGameThread.pauseGame();
    }
    if (myTumbleweedThread != null) {
      myTumbleweedThread.pauseGame();
    }
    if (myMusicMaker != null) {
      myMusicMaker.pauseGame();
    }
  }

  /**
   * Stop all of the threads started by this game and delete them as they are
   * no longer usable.
   */
  private synchronized void stopThreads() {
    if (myGameThread != null) {
      myGameThread.requestStop();
    }
    if (myTumbleweedThread != null) {
      myTumbleweedThread.requestStop();
    }
    if (myMusicMaker != null) {
      myMusicMaker.requestStop();
    }
    myGameThread = null;
    myTumbleweedThread = null;
    myMusicMaker = null;
  }

  //-------------------------------------------------------
  //  error methods

  /**
   * Converts an exception to a message and displays the message..
   */
  void errorMsg(Exception e) {
    if (e.getMessage() == null) {
      errorMsg(e.getClass().getName());
    } else {
      errorMsg(e.getClass().getName() + ":" + e.getMessage());
    }
  }

  /**
   * Displays an error message alert if something goes wrong.
   */
  void errorMsg(String msg) {
    Alert errorAlert = new Alert("error", msg, null, AlertType.ERROR);
    errorAlert.setCommandListener(this);
    errorAlert.setTimeout(Alert.FOREVER);
    Display.getDisplay(this).setCurrent(errorAlert);
  }

}

/**
 * This class is the display of the game.
 * 
 * @author Carol Hamer
 */

class JumpCanvas extends javax.microedition.lcdui.game.GameCanvas {

  //---------------------------------------------------------
  //   dimension fields
  //  (constant after initialization)

  /**
   * the height of the green region below the ground.
   */
  static final int GROUND_HEIGHT = 32;

  /**
   * a screen dimension.
   */
  static final int CORNER_X = 0;

  /**
   * a screen dimension.
   */
  static final int CORNER_Y = 0;

  /**
   * a screen dimension.
   */
  static int DISP_WIDTH;

  /**
   * a screen dimension.
   */
  static int DISP_HEIGHT;

  /**
   * a font dimension.
   */
  static int FONT_HEIGHT;

  /**
   * the default font.
   */
  static Font FONT;

  /**
   * a font dimension.
   */
  static int SCORE_WIDTH;

  /**
   * The width of the string that displays the time, saved for placement of
   * time display.
   */
  static int TIME_WIDTH;

  /**
   * color constant
   */
  public static final int BLACK = 0;

  /**
   * color constant
   */
  public static final int WHITE = 0xffffff;

  //---------------------------------------------------------
  //   game object fields

  /**
   * a handle to the display.
   */
  private Display myDisplay;

  /**
   * a handle to the MIDlet object (to keep track of buttons).
   */
  private Jump myJump;

  /**
   * the LayerManager that handles the game graphics.
   */
  private JumpManager myManager;

  /**
   * whether or not the game has ended.
   */
  private boolean myGameOver;

  /**
   * the player's score.
   */
  private int myScore = 0;

  /**
   * How many ticks we start with.
   */
  private int myInitialGameTicks = 950;

  /**
   * this is saved to determine if the time string needs to be recomputed.
   */
  private int myOldGameTicks = myInitialGameTicks;

  /**
   * the number of game ticks that have passed.
   */
  private int myGameTicks = myOldGameTicks;

  /**
   * we save the time string to avoid recreating it unnecessarily.
   */
  private static String myInitialString = "1:00";

  /**
   * we save the time string to avoid recreating it unnecessarily.
   */
  private String myTimeString = myInitialString;

  //-----------------------------------------------------
  //    gets/sets

  /**
   * This is called when the game ends.
   */
  void setGameOver() {
    myGameOver = true;
    myJump.userPauseThreads();
  }

  /**
   * @return a handle to the tumbleweed objects.
   */
  Tumbleweed[] getTumbleweeds() {
    return (myManager.getTumbleweeds());

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产sm捆绑调教视频| 日韩精品一区第一页| 国产精品亚洲综合一区在线观看| 91啪亚洲精品| 欧美日韩国产综合一区二区| xfplay精品久久| 亚洲最大成人网4388xx| 国产色爱av资源综合区| 亚洲国产精品影院| 亚洲欧洲综合另类在线| 91官网在线免费观看| 一区二区三区资源| 9191国产精品| 韩国成人在线视频| 中文字幕欧美国产| 在线观看不卡视频| 日本aⅴ精品一区二区三区| 日韩一二三四区| 国产成人在线视频网址| 国产精品成人一区二区艾草| 91黄色小视频| 日韩激情视频网站| 久久欧美中文字幕| 一本到不卡精品视频在线观看| 亚洲综合免费观看高清完整版在线 | 精品在线播放午夜| 国产精品午夜免费| 在线成人av网站| 国产精品一区免费视频| 亚洲三级免费观看| 91精品国产综合久久久久久久| 精品一区免费av| 日韩理论片一区二区| 欧美日韩成人激情| 成人avav影音| 免费在线一区观看| 国产精品网站一区| 777色狠狠一区二区三区| 粉嫩一区二区三区性色av| 一级中文字幕一区二区| 久久久久成人黄色影片| 欧美日韩国产大片| 国产福利视频一区二区三区| 亚洲国产va精品久久久不卡综合| 国产午夜精品美女毛片视频| 欧美三区在线视频| 粉嫩aⅴ一区二区三区四区五区| 亚洲v日本v欧美v久久精品| 国产欧美日韩综合| 91精品欧美久久久久久动漫| 91天堂素人约啪| 国产一区二区精品在线观看| 日韩综合一区二区| 亚洲三级电影网站| 国产日本欧美一区二区| 91精品国产一区二区三区蜜臀| 94-欧美-setu| 国产精品一区二区在线播放 | 另类综合日韩欧美亚洲| 国产偷国产偷亚洲高清人白洁| 欧美色爱综合网| 成人动漫精品一区二区| 久久精品99国产精品| 午夜影院在线观看欧美| 亚洲猫色日本管| 日本一区二区三区四区| 26uuu亚洲综合色欧美| 欧美精三区欧美精三区| 在线视频你懂得一区| 99re66热这里只有精品3直播| 国产一区三区三区| 麻豆91小视频| 喷水一区二区三区| 午夜精品123| 亚洲韩国一区二区三区| 亚洲综合在线第一页| 亚洲免费在线看| 成人欧美一区二区三区在线播放| 国产欧美一区二区精品秋霞影院| 精品对白一区国产伦| 日韩欧美国产一区在线观看| 在线播放/欧美激情| 欧美高清激情brazzers| 欧美久久久久久久久| 欧美美女激情18p| 欧美中文字幕亚洲一区二区va在线 | 欧美精品久久天天躁| 欧美猛男男办公室激情| 欧美视频一区二区三区| 欧洲精品一区二区三区在线观看| 色悠悠亚洲一区二区| 91福利在线导航| 欧美美女直播网站| 欧美一级日韩不卡播放免费| 欧美一区二区成人6969| 欧美成人国产一区二区| 久久久久久久久99精品| 国产精品色一区二区三区| 亚洲欧洲性图库| 亚洲品质自拍视频| 三级在线观看一区二区| 琪琪一区二区三区| 国产一区二区三区在线观看精品| 国产一区二区三区电影在线观看 | 丁香婷婷综合网| 成人激情图片网| 色婷婷精品大视频在线蜜桃视频| 欧美在线你懂的| 日韩精品一区二区三区视频播放| 久久综合久久综合九色| 国产精品人妖ts系列视频| 综合在线观看色| 亚洲国产综合色| 久久精品国产在热久久| 国产综合一区二区| 99精品桃花视频在线观看| 欧美日产国产精品| 久久午夜老司机| 亚洲天堂中文字幕| 琪琪久久久久日韩精品| 成人免费高清视频在线观看| 欧美日韩一卡二卡| 国产欧美日韩在线看| 亚洲国产你懂的| 国产mv日韩mv欧美| 欧美精品久久99| 国产精品久久久久精k8| 日韩不卡手机在线v区| 成人国产精品免费| 日韩一区二区不卡| 亚洲品质自拍视频网站| 久久99国产精品免费网站| 一本色道久久综合精品竹菊| 精品久久人人做人人爱| 一区二区三区毛片| 国产福利电影一区二区三区| 欧美日韩高清一区二区不卡| 国产精品视频看| 免费观看成人av| 在线观看av一区二区| 国产亚洲精品7777| 青青草国产精品97视觉盛宴| 99re热这里只有精品免费视频| 欧美精品高清视频| 亚洲曰韩产成在线| 国产精品白丝jk白祙喷水网站| 日本高清不卡一区| www国产亚洲精品久久麻豆| 一区二区三区中文字幕精品精品 | 亚洲精品一区二区三区精华液| **欧美大码日韩| 国产成人在线视频网站| 欧美美女激情18p| 中文字幕一区二区5566日韩| 日本免费在线视频不卡一不卡二| 亚洲成人免费影院| 欧美亚洲另类激情小说| 国产亚洲污的网站| 婷婷开心久久网| 99久久免费视频.com| 中文字幕高清一区| 国模无码大尺度一区二区三区 | 国产精品一二三区在线| 99精品视频在线观看免费| 欧美zozozo| 午夜国产不卡在线观看视频| 91亚洲资源网| 亚洲欧美成aⅴ人在线观看| 国产福利精品导航| 精品蜜桃在线看| 日本aⅴ免费视频一区二区三区 | 欧美亚洲高清一区二区三区不卡| 久久久99精品免费观看不卡| 秋霞影院一区二区| 色香色香欲天天天影视综合网| 国产精品久久久久久久久免费桃花 | 色婷婷久久久综合中文字幕| 久久色视频免费观看| 老汉av免费一区二区三区 | 在线不卡的av| 亚洲一区二区三区三| 色av成人天堂桃色av| 亚洲欧洲另类国产综合| 国产高清精品网站| 国产色91在线| 高清不卡在线观看av| 国产色产综合色产在线视频| 国产精选一区二区三区| 欧美电视剧在线观看完整版| 日韩精品一级二级| 欧美日韩在线观看一区二区 | 欧美一区二区观看视频| 日本aⅴ免费视频一区二区三区| 5月丁香婷婷综合| 精品一区二区影视| 久久久不卡网国产精品二区| 国产精品一二三在| 亚洲欧美乱综合| 欧美日韩久久久久久| 日本怡春院一区二区|