SpikedPlattforms1
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
|
||||
|
||||
/**
|
||||
* Write a description of class Spike here.
|
||||
*
|
||||
* @author (your name)
|
||||
* @version (a version number or a date)
|
||||
*/
|
||||
public class Spike extends Actor
|
||||
{
|
||||
int speed;
|
||||
public Spike(int pSpeed)
|
||||
{
|
||||
speed=pSpeed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Act - do whatever the Spike 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.setLocation(this.getX(), this.getY()+speed);
|
||||
if(this.isTouching(Player.class))
|
||||
{
|
||||
Greenfoot.setWorld(new GameOverWorld());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user