Hey everyone,
I'm a computer science teacher and I was running my students through how to use if statements when a very weird error happened. Oddly, it was only part of the class even though we were all using the same coding structure.
We were learning how to use the Greenfoot.isKeyDown() method as a way to make objects react to key presses using the following structure for the methods:
We had matching code for each direction. Now for most of my students this worked absolutely correctly. For about 20% of the class though, movement would be sluggish to start with and then completely die after about 10 seconds. I could sometimes reset the scenario and then it would start working again, but that didn't always work. Movement controls would then sometimes re-enable after a few seconds of holding a key down, but I couldn't figure out what was going on. I was very confused as this only hit a few students and their code was correct as far as I could tell.
Any ideas on what might be going on? Thanks for any replies!
public void moveLeft(){
if(Greenfoot.isKeyDown("d")){
setRotation(90);
move(1);
}
}
