Fügt Leben zum Spieler, ein HealthItem und eine Healthbar hinzu.

This commit is contained in:
2026-09-16 15:57:46 +02:00
parent da0a97adfe
commit 8477d63e51
13 changed files with 111 additions and 30 deletions
+20
View File
@@ -0,0 +1,20 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Healthbar here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Healthbar extends Actor
{
public void act()
{
draw_health();
}
public void draw_health(){
Player player = getWorld().getObjects(Player.class).get(0);
setImage(new GreenfootImage("Health:" + player.health, 24, Color.WHITE, Color.BLACK));
}
}