July 2018
Beginner to intermediate
374 pages
8h 54m
English
The ground, water, scoreboard, and raft are the most important pieces in our game. So after each is added, let’s reset the game to a good starting point.
| | var ground = addGround(); |
| | var water = addWater(); |
| | var scoreboard = addScoreboard(); |
| | var raft = addRaft(); |
| » | reset(); |
Below addRaft, we add the reset() function.
| | function reset() { |
| | camera.position.set(0,-1,2); |
| | camera.lookAt(new THREE.Vector3(0, 0, 0)); |
| | raft.add(camera); |
| | |
| | scoreboard.message(''); |
| | scoreboard.resetTimer(); |
| | scoreboard.score(0); |
| | |
| | raft.__dirtyPosition = true; |
| | raft.position.set(0.75, 2, -9.6); |
| | raft.setLinearVelocity(new THREE.Vector3(0, 0, 0)); |
| | } |
Don’t forget that __dirtyPosition starts with two underscore characters! ...
Read now
Unlock full access