Hello,
i'm making a football game but i have some problems with the ball. The ball has to stay in the lines of the field and if it hits the line of the field it needs to bounce back. I have a code but the code isn't finished yet. The ball also acts weird sometimes, it stays on the line(egde of the world) of the field and its than non-stop shaking.
Can somebody help me out?
this is the code:
public class Voetbal extends Actor
{
/**
* Act - do whatever the Voetbal wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
private int moveDirection = 1;
public void act()
{
if(((Stadion) getWorld()).wereldEinde(this))
{
moveDirection *= -1;
setRotation(Greenfoot.getRandomNumber(180));
}
move(8 * moveDirection);
}
}

