Startplattform (nicht in MyWorld)

This commit is contained in:
2026-09-16 17:16:52 +02:00
parent bfada2dbc2
commit a0de2fb58d
16 changed files with 287 additions and 75 deletions
+59
View File
@@ -0,0 +1,59 @@
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class TemporaryGround here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class TemporaryGround extends Plattform
{
private int Lebensdauer;
boolean warningHasHappend=false;
boolean deWarningHasHappend=true;
public TemporaryGround(int pLebensdauer)
{
Lebensdauer=pLebensdauer;
}
/**
* Act - do whatever the TemporaryGround wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
// Add your action code here.
Lebensdauer--;
if(Lebensdauer==0)
{
this.loescheMich();
}
if(Lebensdauer<60*3 && warningHasHappend==false) //3 Sekunden
{
this.warning();
}
if(Lebensdauer>=60*3 && deWarningHasHappend==false)
{
this.noMoreWarning();
}
}
public void warning()
{
this.setImage("TemporaryIsBreaking.png");
warningHasHappend=true;
deWarningHasHappend=false;
}
public void noMoreWarning()
{
this.setImage("TemporaryGround.png");
warningHasHappend=false;
deWarningHasHappend=true;
}
public void RefreshLifeToDuration(int pDuration)
{
Lebensdauer=pDuration;
}
}