Hey there,
I'm not very experienced in greenfoot so please excuse me if it's a very easy fault.
In my program I wanted the actor to start off in a random direction (but not directly north, west, east and south), but it came out quite strange.
Every value between 0 - 31 on int newRotation is making my Object visually turn, but anyway it still moves straight to the right side when I call this.move(1) . As soon as the value of newRotation is between 32 - xx (Haven't tried any further) the object moves with a 45 degree angle.
So did I forget to import any class or anything else, or are there only 8 directions?
This is a part of my code:
public void act()
{
if(i==0){
int newRotation;
newRotation = Greenfoot.getRandomNumber(360);
while( (newRotation >= 85 && newRotation <= 95)
|| (newRotation >= 265 && newRotation <= 275)
|| (newRotation >= 355 || newRotation <= 5)
|| (newRotation >= 175 && newRotation <= 185))
{
newRotation = Greenfoot.getRandomNumber(360);
}
i=1;
this.setRotation(newRotation);
}
this.move(1);
}
Cheers & Thanks for your help.