Hello Guys
im experiencing a weird bug, i am trying to get Keyboard input from Greenfoot.isKeyDown and then turn. The interessting thing is, that it just ignores the turn(); , but just when its in a while loop. When i put in the act method and pressed play, wich allso loops the code, it works fine. The Issue seems to appear a second time in my programming class. Is it just a mistake by me?
Help would be much appreciated.
Thanks
public class schiff extends Wind
{
int WindW;
int WindS;
int SegelW = 0;
boolean segeln = true;
int x;
int y;
/**
* Act - do whatever the schiff wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
WindS = getwinds();
WindW = getwindw();
System.out.println(3);
while(x <= 400){
int Rotate = getRotation();
x = x+1;
try{
wait(1000);
}
catch(Exception e){};
System.out.println(1);
if(Greenfoot.isKeyDown("left")){
turn (-10);
System.out.println("left");
y = y+1;
}
if(Greenfoot.isKeyDown("right")){
//turn(10);
Rotate = getRotation();
setRotation(Rotate+10);
System.out.println("right");
y = y+1;
}
}
System.out.println(2);
}
}
