OK! You’re actually really, really close here.
One bit of advice is to start small. In this case, cut back on the trees from 1,000 to 10, then bump them up from there once everything else is working.
Another bit of advice is to go back and re-read chapter 2 about debugging. Using the tools described in there – especially the JavaScript console – I think you could figure out nearly all of this. It’s totally cool to ask when you run into problems! But it’s all sorts of fun when you can solve these mysteries on your own
If you check the JavaScript console, you’ll find a bunch of errors that isMovingLeft is not defined
. That’s because there is a little typo near line 120:
var clock = new THREE.Clock();
var isCartwheeling = false;
var isFlipping = false;
var isMovingRight = false;
var isMovingLesf = false;
var isMovingForward = false;
var isMovingBack = false;
Change isMovingLesf
to isMovingLeft
and that error should go away.
There is another small type with the acrobatics()
function on line 172. It creates a function names function acrobatoics()
instead of function acrobatics()
.
Also, inside the walk()
function near line 150, the “get” in clock.getElapsedTime()
should start with a lowercase g – right now it is clock.GetElapsedTime()
(capital G), which would cause an error.
Once you fix those minor typos, the code should work. If not, or if you have any questions – don’t hesitate to ask!
-Chris
P.S. There might be one more typo in there when the avatar moves left or right. Can you find it?