Eat to Grow Sample Project
StudioBasic set up and logic for eat-to-grow game mechanic, extracted from Balloon Pop (https://eleanoredwards.8thwall.app/balloon)
Basic set up and logic for eat-to-grow game mechanic, extracted from Balloon Pop (https://eleanoredwards.8thwall.app/balloon)
EAT TO GROW : SAMPLE PROJECT
Features
- Food Spawner and State Controller
- Collision Detection
- Player Controller
- Keyboard Input
Description
This sample project is extracted from the Balloon Pop project. It provides the set up for an eat to grow game mechanic that can be used to help you develop your own game.
Game play
Experience uses arrow or WASD to navigate Player cube, Food (spheres) are generate in a contained space, as Player and Food collide the scales of each will be compared.
If the Food is smaller than the Player, the Player will increase in size and the Food will be marked as eaten & collided triggering it to 'die' (scale down) and respawn (reposition & scale up) in .
If the Food is larger than the Player, the Player will decrease in size by half its current size (this maintains the sample experience but is where you might put 'Game Over'/'Life Loss' logic).
Structure
- food-scripts /
- food-spawner.js
- food-state-controller.js
- food-state.js
- food.js
- utils /
- config.js
- setup-collider.js
- player-controller.js
- README.md
HOW IT WORKS
food-scripts / food-spawner.js
Script to dynamically generate food entities when the experience is first run, imports food.js and food-state.js.
Sample project generates spherical food at random positions with a random scale within a range.
food-scripts / food-state-controller.js
Main Food control script. Releases Food at an interval (set in config) and monitors current state and triggers changes based upon collisions and events.
food-scripts / food-state.js
Sets up the Food State Component that is applied to each Food Entity. Used to store current state and changes.
food-scripts / food.js
Exported and called by . Imports and applies to Food Entity. Sets , , , & . Logic for monitoring collisions.
utils / config.js
Project wide variables
utils / setup-collider.js
To aid collider setup depending on what Geometry or model you may be using. Check docs for default/required parameters. Collider shape determined by String value e.g. , , .
player-controller.js
Central player controller, control via keyboard input. Listens for and checks against to determine what kind of collision has happened. Updates player scale.
README.md
You're looking at it.
Other Work by Eleanor Edwards