Resetting the Game
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, ... |
Get 3D Game Programming for Kids, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.