I created this as a proof of concept for a game that could potentially change gravity. That being the case, there are some known bugs in the scenario (mostly collision detection). The instructions are in the game.
Wouldn't it be better to use the arrow keys instead of the number keys? You just type "left" and similar. So something like.
[code]
if (Greenfoot.isKeyDown("left"))//Whatever changes gravity here.
[code/]
I made an entire scenario on this mechanic actually. It's hit detection doesn't allow the object to glitch into the walls too. It alligns itself into the object it's hitting so it doesn't move into it.
http://www.greenfoot.org/scenarios/9172
2013/11/15