July 2018
Beginner to intermediate
374 pages
8h 54m
English
At this point, we’re done with the code outline and we have the basics for a solid 2D game. We have the playing area, the avatar (including controls), and a way to keep score. To make the game interesting, we still need to do a bit more work. Next, we’ll add gameplay. We’re going to roll out some fruit and challenge the player to make the avatar eat as much as possible without touching the ground.
First, to create fruit, add a function below the reset() function.
| | function makeFruit() { |
| | var shape = new THREE.SphereGeometry(40, 16, 24); |
| | var cover = new THREE.MeshBasicMaterial({visible: false}); |
| | var fruit = new Physijs.SphereMesh(shape, cover); |
| | fruit.position.set(w, 40, 0); |
| | scene.add(fruit); ... |
Read now
Unlock full access