Use the arrow keys to move the spaceship, space button for a little boost.
All comments are welcome, especially suggestions on how to make the code look more correct.
In the Space class, I saw two things that could be done to make the code look better.
(1) line 8, the int 's' is not used anywhere, so it can be removed
(2) lines 7, 9 and 10: these are only used in the 'createStars' method and should be local to it. Move line 7 to the beginning of the 'createStars' method (you may have to assign zero to it) and remove 9 and 10 (there are already local variables for these, so those declared in lines 9 and 10 are not being used).
In the Star class: the constructor uses 'if (size == 2)...if(size == 3)...if(size == 4)'. Better would be a 'switch' statement. Also 'size' has a range from one to five; you are not doing anything for when it is one or five. Actually those with sizes of one and five are invisible (black on a black background) since the default drawing color for them was never changed.
In the Spaceship class: You are calling the 'hyper' method every act cycle (which is OK), but the method is updating the image each time it is called, whether the image needs changed or not. You can add a boolean field to the class, 'private boolean spaceDown;' and change the 'if's in the method to:
if (!spaceDown && Greenfoot.isKeyDown("space"))
and
if (spaceDown && !Greenfoot.isKeyDown("space"))
With that, the image will only be updated when there is a change in state of the "space" key.
2012/11/4
2012/11/4
2012/11/5