Gameplay
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.
Launching Fruit
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); |
â ... |
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.