Hello people,
I'm very new to programming, we've been getting lesson on programming in GreenFoot for about a month now at school. I have this test coming up tomorrow and suddenly my test game that I was making doesn't want to work.
I was trying to make a game in which you move your player and enemies move towards you (I know it's very basic). I tried putting in an object reference, but it keeps giving me some error. Here is the code I'm using in the enemy:
And this I used in the player:
I hope someone will be able to help me.
public void act()
{
int x = player.getX();
if (x < getX())
{
setLocation(this.getX()-2, this.getY());
}
if (x > getX())
{
setLocation(this.getX()+2, this.getY());
}
}
public void setPlayer (Player p)
{
player = p;
}BasicEnemy enemy = new BasicEnemy();
enemy.setPlayer(this);

