July 2018
Beginner to intermediate
374 pages
8h 54m
English
The goal of this game will be to find fruit in the trees. The fruit will be our game’s treasure. At any given time, only one tree will have treasure. To show which tree it is, we’ll give it a little shake. But first we need a list of trees.
In Chapter 10, Project: Collisions, we added a list of notAllowed boundaries above the makeTreeAt() function. Now, we add a list of treeTops in the same place.
| | var notAllowed = []; |
| » | var treeTops = []; |
Next, inside the body of the makeTreeAt() function, let’s push treetops onto this treeTops list.
| | notAllowed.push(boundary); |
| » | treeTops.push(top); |
Now that we have a list of treetops, we can hide treasure in one and shake it. After the four calls to the makeTreeAt function, ...
Read now
Unlock full access