Added class HUD + startet hp HUD

This commit is contained in:
2021-06-24 15:03:27 +02:00
parent 3b424d4c98
commit 953aa20d83
3 changed files with 52 additions and 0 deletions

49
Zoelda/src/main/HUD.java Normal file
View File

@@ -0,0 +1,49 @@
package main;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import ea.Bild;
import ea.Knoten;
import ea.Ticker;
public class HUD extends Knoten implements Ticker {
Bild[] FULL_HEART;
Bild HALF_HEART;
Bild[] EMPTY_HEART;
BufferedImage mainImage;
public HUD() {
FULL_HEART = new Bild[3];
EMPTY_HEART = new Bild[3];
Main.instance.manager.anmelden(this, 20);
try {
mainImage = ImageIO.read(HUD.class.getResourceAsStream("/res/images/icons.png"));
} catch (IOException e) {
e.printStackTrace();
}
// FULL_HEART:
BufferedImage buff = mainImage.getSubimage(16, 0, 16, 16);
for (int i = 0; i > FULL_HEART.length; i++) {
FULL_HEART[i] = new Bild(i * 48, 0, buff);
}
// HALF_HEART:
buff = mainImage.getSubimage(32, 0, 16, 16);
HALF_HEART = new Bild(0, 0, buff);
for (int i = 0; i > EMPTY_HEART.length; i++) {
EMPTY_HEART[i] = new Bild(i * 48, 0, buff);
}
}
@Override
public void tick() {
// TODO Auto-generated method stub
}
}

View File

@@ -10,6 +10,7 @@ public class Main extends Game {
public static Main instance;
private World world;
private HUD hud;
public static final int WIDTH = 1000; // Fensterbreite
public static final int HEIGHT = 800; // Fensterhöhe
@@ -20,8 +21,10 @@ public class Main extends Game {
// Welt initialisieren und Spieler hinzufügen
world = new World();
// hud = new HUD();
// die Welt zu EA hinzufügen
wurzel.add(world);
// wurzel.add(hud);
}
@Override

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB