Yes, it does run faster directly in GF. Unfortunately, even optimizing your code (if it is even possible in any way) won't really make a difference because all uploaded scenarios run slower since the conversion to JS. You can even notice a difference at speed 50 which makes playing games on the site often easier than they are in GF.
For me, one line (from one side to the other, when it is moving almost through the middle) needs a little bit less than third of a second. (Just counted 60 in 22 seconds.)
Something along these lines could work:
-------
String key = Greenfoot.getKey();
if (key != null) //any key was pressed
{
if (correctKey.equals(key))
{
//correct key was pressed
}
else
{
//any other key was pressed
}
}
-------
Well, despite the fact that the game doesn't know what to do when you actually solve all numbers. Mainly because I don't know how I should handle that in the score system.
So far your score is lost if you don't have a connection to the GF server at the time the game ends. Maybe I will make it possible to keep the score to try submitting it later. Other than this, everything should work now. (I hope.)
You are welcome :)
To fix the gray rectangles of the numbers, you can change line 32 in the Number class to:
tile.drawRect(1,1,42,42);
With (0,0,45,45), the bottom and right edge is outside the image = not visible. In theory, the same applies to line 40. In practice, drawing something in gray on an image which was filled in gray right before, doesn't have a big impact anyway though.
The alternative is to draw those rectangles on the background of the world.
2019/7/6
Tracing Bounces in Circle World
2019/7/6
Tracing Bounces in Circle World
2019/6/27
33 Seconds
2019/6/14
TenPair
2019/6/14
TenPair
2019/6/14
Match or Ten
2019/6/14
Match or Ten
2019/6/7
Swarms
2019/6/7
Swarms