I used to make small online games using Macromedia Director and the scripting language Lingo about two decades ago. Now I'm back trying to make a game for the Playdate and I've made some progress but I need to get some pointers about how to think about this in general.
How to structure a powerbar?
I'm making a game where different cars will have different characteristics. One of them number of gears. I want to illustrate which gear is active by having a power meter withthree to five distinct lights that turn on or off.
After a lot of trial and error I managed to set up one Sprite that is called GearIndicator, and that in turn sets up any number of sprites called SingleLight.
The main thread can call on GearIndicator:changeGear(WhatGear) and GearIndicator will loop through a table of SingleLights that it sets up on its init function.
Everything works the way I want, but it feels as if I'm trying to do things in the way that I did back in the day, and it feels as if that way isn't what I'm supposed to do things.
I don't like that I can't fin a way to have a specific reference to the GearIndicator but that I rather just call GearIndicator:changeGear(whatGear) in general. Like I said, it works, but it feels messy. What If I want a second indicator for something else that could use a second instance of the GearIndicator?
I would also like to add the instances of SingleLight to the Sprite GearIndicator, so that I move the GearIndicator sprite to a location and the Single Light Sprites are added from (0,0) being the top left of the GearIndicator Sprite, but I couldn't figure out how.
Am I going at things in an unnecessary complicated way? Is there a best practice, and if so, what?
Any ideas pointers would help a lot.