Game App!
Modifying the game
Here are some tweaks you can apply to this code:
-
lower the update rate to see how it slows down the movement of the whole game. Put it back to 60 when you're done;
-
change the numbers after Cls. They're currently 0, 0, 0, which are red, green and blue colour values respectively; we can mix these values together to form any colour imaginable.
Using zero for all three means there is no red, no green and no blue in the colour, which is why we have a black screen! You can give each number a value from 0 to 255. For example, Cls 255, 0, 0 will give you a bright red screen, Cls 0, 255, 0 a green screen and Cls 0, 0, 255 a blue screen; Cls 255, 255, 255 is pure white.
Mix and match all three values as you see fit: Cls 96, 128, 255 gives a pale blue, for example.
-
change the movement speed; it's currently 2; try making it 1 for all movement directions. Any ideas as to how you might change the speed to a non-whole number; 2.5, for example? Hint: look at the type of the x and y fields!
-
invert the up/down controls; you can either change the keycodes used in OnUpdate (KEYUP and KEYDOWN) or the plus/minus signs used to change the value of y.
If you're feeling adventurous, refer to the Monkey docs (in Monk, go to the Docs tab, click Module Reference, then mojo.input), you'll find a list of 'key codes'. You can change the key codes used in OnUpdate and thereby change which keys the game uses.
The key code in the excerpt below is KEYLEFT, so that's the part you would replace with a different key code chosen from the docs:
If KeyDown (KEYLEFT) ...