Пример #1
0
  private void gameRender() {
    if (dbImage == null) {
      dbImage = createImage(PWIDTH, PHEIGHT);
      if (dbImage == null) {
        System.out.println("dbImage is null");
        return;
      } else dbg = dbImage.getGraphics();
    }

    // draw a white background
    dbg.setColor(Color.white);
    dbg.fillRect(0, 0, PWIDTH, PHEIGHT);

    // draw the game elements: order is important
    ribsMan.display(dbg); // the background ribbons
    bricksMan.display(dbg); // the bricks
    jack.drawSprite(dbg); // the sprites
    fireball.drawSprite(dbg);

    if (showExplosion) // draw the explosion (in front of jack)
    dbg.drawImage(explosionPlayer.getCurrentImage(), xExpl, yExpl, null);

    reportStats(dbg);

    if (gameOver) gameOverMessage(dbg);

    if (showHelp) // draw the help at the very front (if switched on)
    dbg.drawImage(
          helpIm, (PWIDTH - helpIm.getWidth()) / 2, (PHEIGHT - helpIm.getHeight()) / 2, null);
  } // end of gameRender()
Пример #2
0
  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()