Exemplo n.º 1
0
  public JackPanel(JumpingJack jj, long period) {
    jackTop = jj;
    this.period = period;

    setDoubleBuffered(false);
    setBackground(Color.white);
    setPreferredSize(new Dimension(PWIDTH, PHEIGHT));

    setFocusable(true);
    requestFocus(); // the JPanel now has focus, so receives key events

    addKeyListener(
        new KeyAdapter() {
          public void keyPressed(KeyEvent e) {
            processKey(e);
          }
        });

    // initialise the loaders
    ImagesLoader imsLoader = new ImagesLoader(IMS_INFO);
    clipsLoader = new ClipsLoader(SNDS_FILE);

    // initialise the game entities
    bricksMan = new BricksManager(PWIDTH, PHEIGHT, BRICKS_INFO, imsLoader);
    int brickMoveSize = bricksMan.getMoveSize();

    ribsMan = new RibbonsManager(PWIDTH, PHEIGHT, brickMoveSize, imsLoader);

    jack =
        new JumperSprite(
            PWIDTH,
            PHEIGHT,
            brickMoveSize,
            bricksMan,
            imsLoader,
            (int) (period / 1000000L)); // in ms

    fireball = new FireBallSprite(PWIDTH, PHEIGHT, imsLoader, this, jack);

    // prepare the explosion animation
    explosionPlayer =
        new ImagesPlayer("explosion", (int) (period / 1000000L), 0.5, false, imsLoader);
    BufferedImage explosionIm = imsLoader.getImage("explosion");
    explWidth = explosionIm.getWidth();
    explHeight = explosionIm.getHeight();
    explosionPlayer.setWatcher(this); // report animation's end back here

    // prepare title/help screen
    helpIm = imsLoader.getImage("title");
    showHelp = true; // show at start-up
    isPaused = true;

    // set up message font
    msgsFont = new Font("SansSerif", Font.BOLD, 24);
    metrics = this.getFontMetrics(msgsFont);
  } // end of JackPanel()
Exemplo n.º 2
0
 public void draw(Graphics g, ImagesLoader imLoad) {
   for (int i = 0; i < pickupList.size(); i++) {
     Pickup p = pickupList.get(i);
     BufferedImage img = imLoad.getImage(p.type);
     g.drawImage(img, (int) p.x, (int) p.y, null);
   } // end for
 } // end draw