@nelson@shrimp.starlightnet.work
2026-05-18 02:31 UTC
I've been experimenting with a concept as of late, something which I've decided to brand as Strand-Oriented Entity Design
In short, instead of keeping the actual state of the entities somewhere within the actual entity object or struct, you have a stackful coroutine that's attached to the entity and controls it like a puppet, with the stack BEING the state
The point is that it makes my life easier as I don't really have to make a new datatype per entity or internal property, just a new function that represents the entity's behaviour AND internal state, which also has the neat side effect of making your entities extremely easy to script for stuff like RPG games, for example...walk_up(entity, 10)
walk_right(entity, 10)
say("Cowabunga!")
if ask("Is that right?", {"yes", "no"}) == "yes" then
say("hell yes!")
sound("badass.ogg")
end
Or, if you're doing enemy AI or a player entity of sorts...while true do
vx, vy = input.getAxis(1)
entity.velocity_x = vx * 5
entity.velocity_y = vy * 5
yield()
end
Stuff like getting hit, such as in an action game, could also be done with some lightweight message system from which each entity can read from and write to
Yes, this is less efficient than ECS, but it's also much simpler and has a lot less mental baggage, plus you could mix them both and have a hybrid system with a script that controls the properties, and properties that morph over N amount of ticks
Replies (0)
No replies.