import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class Player here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Player extends Actor
{
/**
* Act - do whatever the Player wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act() {
getWorld().setBackground(new GreenfootImage("bg.png"));
getWorld().setBackground("bg");
moveAround();
move(1);
lookForGoal();
}
public void moveAround()
{
int Ycord = getY();
if (Greenfoot.isKeyDown("up") == true) {
setRotation(0);
Ycord = getY() -10;
}
if (Greenfoot.isKeyDown("down") == true) {
setRotation(180);
Ycord = getY() + 10;
}
if (Greenfoot.isKeyDown("left") == true) {
setRotation(270);
}
if (Greenfoot.isKeyDown("right") == true) {
setRotation(90);
}
}
public void lookForGoal() {
if (isTouching(Goal.class) == true) {
removeTouching(Goal.class);
}
}
}