44 lines
1.2 KiB
Java
44 lines
1.2 KiB
Java
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
|
|
|
/**
|
|
* Write a description of class StarPowerUp here.
|
|
*
|
|
* @author (your name)
|
|
* @version (a version number or a date)
|
|
*/
|
|
public class Groundflower extends PowerUps
|
|
{
|
|
int duration= 60*8; //15 Sekunden
|
|
/**
|
|
* Act - do whatever the StarPowerUp wants to do. This method is called whenever
|
|
* the 'Act' or 'Run' button gets pressed in the environment.
|
|
*/
|
|
public void act()
|
|
{
|
|
this.touchedByPlayer();
|
|
this.setLocation(this.getX(), this.getY()+2);
|
|
if(this.getY()>=this.getWorld().getHeight()-5)
|
|
{
|
|
this.getWorld().removeObject(this);
|
|
return;
|
|
}
|
|
this.touchedByPlayer();
|
|
// Add your action code here.
|
|
}
|
|
|
|
@ Override void collect()
|
|
{
|
|
Player player = getIntersectingObjects(Player.class).get(0);
|
|
player.reveivePowerUp(duration, "GroundPower");
|
|
}
|
|
|
|
public void bewegeNachUnten()
|
|
{
|
|
this.setLocation(this.getX(), this.getY()+2);
|
|
if(this.getY()>=this.getWorld().getHeight()-5)
|
|
{
|
|
this.getWorld().removeObject(this);
|
|
}
|
|
}
|
|
}
|