Game Development Reference
In-Depth Information
Engage thrusters
Ater adding the diver sprite to the stage, we can start scriping the player controls.
This is a fairly straighforward process, as follows:
1. Start with a when <green lag> clicked block.
2. Scale the sprite down with a set size to ()% block; enter the value 30 .
3. Then, reposiion it to the let of the screen using the go to x: () y: () block;
enter the value -190 and 0 respecively.
4. Add a forever loop.
5. Inside the loop, we will place the keyboard controls. There will be four similar
condiion checks. One for each of the arrow keys.
6. Combine an if () then block with when <up arrow> key pressed? .
7. Inside the if () statement, place a change y by () block; enter the value 4 .
8. Copy the construcion thrice.
9. Add them all together, then place them inside the forever loop.
10. Change the arrow butons checked in the copied if () statements to account
for all the four possible direcions.
11. Change the direcion that the character will face to the corresponding direcion
when the appropriate buton is pressed. Replace the change y by () blocks with
the change x by () blocks where appropriate.
12. Change the values in the change x by () and change y by () blocks as shown in the
following screenshot:
 
Search WWH ::




Custom Search