Working ECS and First Model
So, I talked previously about the idea of an Entity-Component-System. Near as I can make out, ECS is intended to compensate largely for the lack of facility C/C++ has in building dynamic objects. Basically (as I understand it) an Entity can be thought of as a data structure that has components, which we might call attributes, or key/value pairs in a dictionary.
So, instead I made a triple store (see the table in the last image). It defines relations to objects with a unique identifier. So, for the Robot, we have something like:
(ent robot null) (pos robot (0 0 0)) (model robot <POINTER>)
I can search this list to get information that I need for building the display. To do that, I made up some cheapjack imitations of the more powerful Prolog operators. First `?=` to get everything in the store that matches whichever triplets are specified, and `?v` to get the first value available for the first two triplets. I.e. `(?v STORE 'pos 'robot)` returns the robot's position.
However, I'm not sure I'm going to keep on with that. Urlang is basically a thin wrapper over JavaScript, and JavaScript offers an associative array data type which allows arbitrary keys. More importantly, it keeps them all in the same bundle, so once I have something I can just use the dictionary instead of having to sort through the STORE array again.
On the other hand, STORE isn't that bad, especially for a small game like this. So, I'll probably keep it as it is for a little while.
RFK2K
Robot Finds Kitten - 2000
Status | In development |
Author | oofoe |
Genre | Adventure |
More posts
- Entity-Component-Systems (or Entity-Systems)Nov 03, 2023
- Tools Down!Oct 30, 2023
- Coming Together!Oct 29, 2023
- Robots in Motion and Import WoesOct 28, 2023
- Wheels in MotionOct 27, 2023
- Bringing it to LIFE!Oct 26, 2023
- Spinning Wheels (Not in a Good Way)Oct 25, 2023
- It Lives!Oct 24, 2023
- Handling EntitiesOct 22, 2023
Leave a comment
Log in with itch.io to leave a comment.