コード例 #1
0
ファイル: JackPanel.java プロジェクト: hustbill/bounce
  private void gameUpdate() {
    if (!isPaused && !gameOver) {
      if (jack.willHitBrick()) { // collision checking first
        jack.stayStill(); // stop jack and scenery
        bricksMan.stayStill();
        ribsMan.stayStill();
      }
      ribsMan.update(); // update background and sprites
      bricksMan.update();
      jack.updateSprite();
      fireball.updateSprite();

      if (showExplosion) explosionPlayer.updateTick(); // update the animation
    }
  } // end of gameUpdate()
コード例 #2
0
ファイル: JackPanel.java プロジェクト: hustbill/bounce
  private void processKey(KeyEvent e)
        // handles termination, help, and game-play keys
      {
    int keyCode = e.getKeyCode();

    // termination keys
    // listen for esc, q, end, ctrl-c on the canvas to
    // allow a convenient exit from the full screen configuration
    if ((keyCode == KeyEvent.VK_ESCAPE)
        || (keyCode == KeyEvent.VK_Q)
        || (keyCode == KeyEvent.VK_END)
        || ((keyCode == KeyEvent.VK_C) && e.isControlDown())) running = false;

    // help controls
    if (keyCode == KeyEvent.VK_H) {
      if (showHelp) { // help being shown
        showHelp = false; // switch off
        isPaused = false;
      } else { // help not being shown
        showHelp = true; // show it
        isPaused = true; // isPaused may already be true
      }
    }

    // game-play keys
    if (!isPaused && !gameOver) {
      // move the sprite and ribbons based on the arrow key pressed
      if (keyCode == KeyEvent.VK_LEFT) {
        jack.moveLeft();
        bricksMan.moveRight(); // bricks and ribbons move the other way
        ribsMan.moveRight();
      } else if (keyCode == KeyEvent.VK_RIGHT) {
        jack.moveRight();
        bricksMan.moveLeft();
        ribsMan.moveLeft();
      } else if (keyCode == KeyEvent.VK_UP)
        jack.jump(); // jumping has no effect on the bricks/ribbons
      else if (keyCode == KeyEvent.VK_DOWN) {
        jack.stayStill();
        bricksMan.stayStill();
        ribsMan.stayStill();
      }
    }
  } // end of processKey()