Custom made Entity Component System for Playdate
This is a screenshot of how the ECS system is built for the game Elf Factory, and it is a copy of what I did in Jewel Defender (though I cleaned up the code a bit from what I learned there)
The game is made up of scenes, and each scene has a function that is run to set it up when you switch to that scene.
Also that scene has an update function that runs for each frame of the game. Finally there is a draw call that happens, and this is done after playdates gfx.sprite.update() and is used to draw any extra things on top of the scene such as scoreboards and such.
A scene is also made up of objects, which usually have sprites, but also have ids (which match their keys), and their own update functions that are run after the scene's update function.
The Updater (which is really the only thing playdate.update() runs... I am trying to abstract playdate away as much as possible) handles making all these calls:
There are also DrawDelayed (images and text) which is used by object or scene updates if they want to throw some stuff up on the screen such as notifications to the user or ammo counts or other HUD things as that stuff is best done after all the sprites are done being painted.
CurrentScene is the global pointer to whatever scene is currently active. There is a function called ChangeScene(newScene) which will shut down and clean up the CurrentScene, point CurrentScene to newScene and then run it's setup.
For files, I have ctrl.lua, which has all the generic functions to control the game, main.lua where things are defined (such as Scenes and other global variables), and then a file for each of the scenes, in this case just gameScreen.lua, which contains all the functions that apply to objects in that scene.
Get Elf Factory
Elf Factory
Save christmas by building toys
Status | In development |
Author | Neverall Games |
Genre | Puzzle |
Tags | Christmas, factory, Playdate |
More posts
- Working on a PC port of Elf FactoryFeb 22, 2024
- Got a playdate, and updated a game.Dec 08, 2023
- Ops, wrong path to the gameCard imageDec 29, 2022
- Elf Factory is now available for Download!Dec 27, 2022
- Caps for the playdate is a really fun font editorDec 21, 2022
- Using two font characters to make one larger oneDec 19, 2022
- Got profile selection, level selection, and intro animation placeholder workingDec 19, 2022
- We can now pick up and drop parts in boxesDec 09, 2022
- Elf Factory coming soon on PlaydateDec 08, 2022
Leave a comment
Log in with itch.io to leave a comment.