Milestone 7 – Entities, Components, Systems (ECS)
ECS, which stands for Entities, Components, and Systems, is a game framework that allows for a game loop to iterate over a group of game objects(entities), of which these objects have associated properties and characteristics (Components), that are linked to chunks of code that changes those respective properties (systems).
An example of this is Goomba enemy from Mario Bros. The actual entity is the Goomba object, which has these components: Sprite texture, Size and Position, Collision Boundary, Velocity, and so on. The game has these systems that interact with those components: sprite animation, physics, collisions, and more. The movement of the Goomba is tied to changing its position, which is changed by its velocity, and its velocity controlled by the physics system. Each entity will have its associated components, and the components link the entity to the systems.
So, in Asteroids, the player’s entity will be the ship. The players entity needs these components: Sprite texture, position and rotation, velocity, collision box, combat (health, attack, ammo), and bump map. The bump map is going to be used for lighting. The systems that will be needed for the game will be rendering (Sprite, size, position, rotation), animations (changing sprite), physics (velocity), lighting (bump map), collisions (collision detection/resolution, combat), and keyboard input (combat, physics, and rotation).
The asteroids will be similar, but without keyboard input. They will have predefined velocity values, and collisions change their velocities. Ammo collisions will reduce their health.
An enemy ship will be the same as the player except for an AI system controlling the enemy object instead of the input system controlling it. It needs to make decisions regarding what it’s trying to do: attack, flee, defend, idle…. That system needs created.
This will all be done by creating the class blueprints for an entity, a component, and a system.
This is a rough box proto where I’m using Peasy-UI to render my current entities. Nothing fancy, just divs on a page.
So my ECS is going to be in a unique format, different than what I set out to do initially. I will have my array of entities, index 0 being our player… then the asteroids, bullets, enemies, et all be appended and spliced in and out of that array as we go. The Player and Asteroids are roughed in, but need work.
All entities are classes. And the properties of these classes make up the ‘components’ portion of this framework. No… I did not get there through composition as I intended, but I don’t’ think I need to overcomplicate the either. Each entity has an update() method, and in this method, the different systems tied to each entity will get their chance to execute each tik of the game loop. That’s All for now.
Asteroids Plus 2.0
next gen space shooter
More posts
- Asteroids Plus 2.0 - Milestone 19– Updating to Peasy-physicsMay 17, 2023
- Asteroids Plus 2.0 - Milestone 18– Adding the enemy AIMay 12, 2023
- Asteroids Plus 2.0 - Milestone 17 dynamic background Part 2May 06, 2023
- Asteroids Plus 2.0 - Milestone 17 - Dynamic Background Part 1May 06, 2023
- Asteroids Plus 2.0 - Milestone 16 - AudioMay 01, 2023
- Asteroids Plus 2.0 - Milestone 15 - Mobile DebuggingApr 25, 2023
- Asteroids Plus 2.0 - Milestone 14 - Heads Up DisplayApr 20, 2023
- Asteroids Plus 2.0 - Milestone 13, light housekeeping, spawning, HUD data, healt...Apr 15, 2023
- Asteroids Plus 2.0 - Milestone 12– collisions, the bane of my existenceApr 10, 2023
- Asteroids Plus 2.0 - Milestone 11– bullet hell…Apr 03, 2023
Leave a comment
Log in with itch.io to leave a comment.