Added class HUD + startet hp HUD
This commit is contained in:
49
Zoelda/src/main/HUD.java
Normal file
49
Zoelda/src/main/HUD.java
Normal 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
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ public class Main extends Game {
|
|||||||
public static Main instance;
|
public static Main instance;
|
||||||
|
|
||||||
private World world;
|
private World world;
|
||||||
|
private HUD hud;
|
||||||
|
|
||||||
public static final int WIDTH = 1000; // Fensterbreite
|
public static final int WIDTH = 1000; // Fensterbreite
|
||||||
public static final int HEIGHT = 800; // Fensterhöhe
|
public static final int HEIGHT = 800; // Fensterhöhe
|
||||||
@@ -20,8 +21,10 @@ public class Main extends Game {
|
|||||||
|
|
||||||
// Welt initialisieren und Spieler hinzufügen
|
// Welt initialisieren und Spieler hinzufügen
|
||||||
world = new World();
|
world = new World();
|
||||||
|
// hud = new HUD();
|
||||||
// die Welt zu EA hinzufügen
|
// die Welt zu EA hinzufügen
|
||||||
wurzel.add(world);
|
wurzel.add(world);
|
||||||
|
// wurzel.add(hud);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
BIN
Zoelda/src/res/images/icons.png
Normal file
BIN
Zoelda/src/res/images/icons.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.0 KiB |
Reference in New Issue
Block a user