Game Development Reference
In-Depth Information
3.
Inside the if () then block, add change <lap> by () ; fill in the value 1 .
4.
Also add set <touchFinish> to () with the value 1 .
5.
Inside the else slot, place a set <touchFinish> to () block with the value 0 .
Let's write the condiions for the if statement next:
1. The slot in the if () then () else () block should be filled with a touching <inish>?
condiion check.
2. In the if () then block, we place a () = () operator.
3. On the let side of the equaion, we place the touchFinish variable.
4. To the right, we fill in 0 .
Crossing the finish line usually takes the kart sprite longer than one loop through the script.
With the previous check, we prevent the lap counter to increase muliple imes while the
kart is crossing the line.
We also need to do something special when the player has completed three laps to indicate
that they finished the race.
1. Place yet another if () then block inside the second if statement.
2. Put a () = () operator in the condiion slot.
3. Put the lap variable to the let of the equaion.
4. Insert 3 to the right of the equaion.
5. When the player has finished three laps, add say imer to show how long it
took the player to finish the race.
6. We also need this stack of instrucions for player2 . So, let's first drag it over the
player2 sprite to copy the script there.
7. Then drag the stack to the when <green lag> clicked script. Place it just
underneath the other if () then collision checks.
8. Click on the player2 sprite to view its Scripts tab and place the copied
script segment in the same place as we did for player1 .
9. Also make the lap variable for player2 visible by clicking on the
check box.
10. Drag the display to the top-right corner of the stage and place it underneath the
player1 lap display.
 
Search WWH ::




Custom Search