k adjusted it....
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class Schip extends Actor
{
private Platform platform = null;
private int speed = 3;
public void act()
{
if(Greenfoot.isKeyDown("left"))
{
moveLeft();
}
if(Greenfoot.isKeyDown("right"))
{
moveRight();
}
if(Greenfoot.isKeyDown("up"))
{
moveUp();
}
if(Greenfoot.isKeyDown("down"))
{
moveDown();
}
}
public void moveRight()
{
setLocation(getX() + speed, getY());
setRotation(180);
if (platform != null)
{
platform.setSchip(null);
platform = null;
}
Platform p = (Platform)getOneIntersectingObject(Platform.class);
if (p != null)
{
moveLeft();
turn(180);
platform = p;
p.setSchip(this);
}
}
public void moveLeft()
{
setLocation(getX() - speed, getY());
setRotation(0);
if (platform != null)
{
platform.setSchip(null);
platform = null;
}
Platform p = (Platform)getOneIntersectingObject(Platform.class);
if (p != null)
{
moveRight();
turn(180);
platform = p;
p.setSchip(this);
}
}
public void moveUp()
{
setLocation(getX(), getY() - speed);
setRotation(90);
if (platform != null)
{
platform.setSchip(null);
platform = null;
}
Platform p = (Platform)getOneIntersectingObject(Platform.class);
if (p != null)
{
moveDown();
turn(180);
platform = p;
p.setSchip(this);
}
}
public void moveDown()
{
setLocation(getX(), getY() + speed);
setRotation(270);
if (platform != null)
{
platform.setSchip(null);
platform = null;
}
Platform p = (Platform)getOneIntersectingObject(Platform.class);
if (p != null)
{
moveUp();
turn(180);
platform = p;
p.setSchip(this);
}
}
public Kratten kratten = null;
public void setKratten(Kratten k)
{
kratten = k;
}
public Kratten getKratten()
{
return kratten;
}
}
