SpikedPlattforms2

This commit is contained in:
2026-09-16 11:48:19 +02:00
parent 6127510ec8
commit 56b755b3d6
17 changed files with 244 additions and 79 deletions
+40 -1
View File
@@ -8,12 +8,51 @@ import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
*/
public class UnactiveSpike extends Actor
{
int countdown;
int speed;
boolean geloescht=false;
public UnactiveSpike(int pSpeed, int pCoundown, SpikedPlattform pPlattform)
{
speed=pSpeed;
countdown=pCoundown;
}
/**
* Act - do whatever the UnactiveSpike 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.
this.bewege();
countdown--;
if(countdown==0)
{
MyWorld theWorld= (MyWorld) this.getWorld();
Spike BeispielSpike=new Spike(1);
GreenfootImage SpikeImage= BeispielSpike.getImage();
theWorld.addObject(new Spike(speed), this.getX(), (this.getY()- this.getImage().getHeight()/2)-10); //die Zahl Minus damit ist endlich passt
geloescht=true;
}
if(geloescht)
{
this.loescheMich();
}
}
public void loescheMich()
{
MyWorld theWorld= (MyWorld) this.getWorld();
theWorld.removeObject(this);
}
public void bewege()
{
this.setLocation(this.getX(), this.getY()+speed);
MyWorld theWorld= (MyWorld) this.getWorld();
if(this.getY()>=theWorld.getHeight()-5)
{
geloescht=true;
}
}
}