Exemple #1
0
  @Override
  public void draw(Graphics2D g) {

    try {
      //			g.drawImage(bg.getScaledInstance(GamePanel.WIDTH * GamePanel.SCALE, GamePanel.HEIGHT *
      // GamePanel.SCALE, 0),
      //					0,
      //					0,
      //					null
      //					);
      if (paused) {
        pauseMenu.draw(g);
      } else {
        if (tileMap != null && player != null) {
          if (textEventListener != null && textEventListener.isPlaying()) {
            textEventListener.draw(g);
          } else {

            g.drawImage(
                bg.getScaledInstance(
                    GamePanel.WIDTH * GamePanel.SCALE, GamePanel.HEIGHT * GamePanel.SCALE, 0),
                0,
                0,
                null);
            player.draw(g);
            tileMap.draw(g);
          }

          g.setColor(Color.BLACK);
          g.setFont(new Font("Times New Roman", Font.BOLD, 10));
          g.drawString("Health", 60, 10);
          g.setColor(Color.RED);
          g.drawRect(75, 15, player.getMaxHealth() * 10, 10);
          g.fillRect(75, 15, player.getHealth() * 10, 10);

          g.drawImage(amulet, 0, 0, null);
          if (gsm.getFire()) g.drawImage(firePendant, 0, 0, null);
          if (gsm.getAir()) g.drawImage(airPendant, 0, 0, null);
          if (gsm.getWater()) g.drawImage(waterPendant, 0, 0, null);
          if (gsm.getEarth()) g.drawImage(earthPendant, 0, 0, null);
        }
      }
      if (player.isDead()) {
        g.setFont(new Font("Times New Roman", Font.BOLD, 30));
        g.setColor(Color.RED);
        g.drawString("You are dead", 50, 50);
      }

    } catch (NullPointerException e) {
      System.out.println("Shit be null");
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  public void draw(Graphics2D g) {
    bg.draw(g);

    tileMap.draw(g);

    finish.draw(g);

    player.draw(g);

    for (int i = 0; i < enemies.size(); i++) {

      enemies.get(i).draw(g);
    }

    hud.draw(g);
  }