import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.List;
/**
* Write a description of class Sled here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Sled extends Actor
{
private int Walk = (0);
private static final String IMAGES = {"BobSled1000.png", "BobSledRight2000.png"};
private static final int RATE = 3;
private static GreenfootImage backgroundarray = new GreenfootImage;
private static GreenfootSound soundSound = new GreenfootSound("crack.mp3");
private boolean soundPlayed;
// public int getVariableValue()
// {
// return variable;
// }
public Sled()
{
if(backgroundarray == null)
{
backgroundarray = new GreenfootImage("Blinklala1.png");
backgroundarray = new GreenfootImage("Blinklala2.png");
// Boat boat = new Boat();
// addObject(boat, 1800,300);
// getWorld().addObject(new Boat(), 1800, 300);
}
}
/**
* Act - do whatever the Sled wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
doStuff();
}
public void doStuff()
{
move(15);
Walk = (Walk+1)%(RATE*IMAGES.length);
if (Walk%RATE==0)
{
setImage(IMAGES);
}
if (getX() == 115 && getY() == 330)
{
turn(1);
}
if (getX() == 520 && getY() == 330)
{
turn(-7);
}
if (getX() == 820 && getY() == 290)
{
turn(6);
}
if (getX() == 1210 && getY() == 300)
{
turn(8);
}
if (getX() == 1030 && getY() == 290)
{
turn(2);
}
if (getX() == 1225 && getY() == 303)
{
turn(1);
}
if (getX() == 1420 && getY() == 316)
{
turn(-4);
}
// Actor boaty = getOneObjectAtOffset(-615,-30, Boat.class);
// if ((getX() >1800) && boaty!= null)
if (getX() == 1800)
// && !soundPlayed)
{
// soundSound.play();
// soundPlayed = true;
getWorld().removeObjects(getWorld().getObjects(Boat.class));
getWorld().setBackground(new GreenfootImage("Blinklala1.png"));
Greenfoot.delay(20);
getWorld().setBackground(new GreenfootImage("Blinklala2.png"));
Greenfoot.delay(20);
getWorld().setBackground(new GreenfootImage("Blinklala1.png"));
Greenfoot.delay(30);
getWorld().setBackground(new GreenfootImage("BackgroundImage.png"));
// getWorld().addObject(boat, 1185, 300);
getWorld().addObject(new Boat(), 1184,300);
Greenfoot.delay(10);
FWorld.label1.setText("What was that?");
Greenfoot.delay(30);
FWorld.label1.setText("...");
getWorld().addObject (new Victor(), 1800, 565);
}
}
}

