HamsterCupid: A toy component based entity system
Posted: Tue Oct 04, 2011 5:32 pm
Hi all,
It's been a long while since I touched Lua or Love, so this is my first project since then. I wrote a toy component based entity system. It's not done yet, but I figured I should just throw it out in the wild, in an attempt to get early feedback.
Right now, there are just three components to an Entity:
* View - responsible for drawing to the screen and the related transforms
* Movement - responsible for moving the entity, either over time or from player input
* Model - Holds the entity states, such as position, velocity, acceleration, etc.
Currently, it's hardcoded that you use all three, but as I add more component, one would be able to customize it.
It also has a parent-child hierarchy to compose entities (I'm not sure what the formal name is, but I've heard "frames" If anyone knows, lemme know)
The demo shows a magician wearing a helmet, carrying a wand, shield, and the shield has a cow jittering in front of it. The magician has helmet, wand, and shield as children, and the shield has the cow as a child. When you move the character around, with W,A,S,D keys, you can see that the accessories move around with the magician, even though the accessories have a local coordinate system.
The demo displays the vectors for acceleration and velocity. you can also pan and zoom the camera with the arrow keys and the square bracket keys.
I'll be posting updates as I do more.
github: https://github.com/iamwilhelm/hamstercupid
It's been a long while since I touched Lua or Love, so this is my first project since then. I wrote a toy component based entity system. It's not done yet, but I figured I should just throw it out in the wild, in an attempt to get early feedback.
Right now, there are just three components to an Entity:
* View - responsible for drawing to the screen and the related transforms
* Movement - responsible for moving the entity, either over time or from player input
* Model - Holds the entity states, such as position, velocity, acceleration, etc.
Currently, it's hardcoded that you use all three, but as I add more component, one would be able to customize it.
It also has a parent-child hierarchy to compose entities (I'm not sure what the formal name is, but I've heard "frames" If anyone knows, lemme know)
The demo shows a magician wearing a helmet, carrying a wand, shield, and the shield has a cow jittering in front of it. The magician has helmet, wand, and shield as children, and the shield has the cow as a child. When you move the character around, with W,A,S,D keys, you can see that the accessories move around with the magician, even though the accessories have a local coordinate system.
The demo displays the vectors for acceleration and velocity. you can also pan and zoom the camera with the arrow keys and the square bracket keys.
I'll be posting updates as I do more.
github: https://github.com/iamwilhelm/hamstercupid