Nomad Game Engine: Part 2 — ECS

Three entities
Our 7 components
Entities and their components
Changing how the game works is as easy as adding or removing a component!
struct Entity {
unsigned int id;
struct HealthComponent {
int currentHealth;
int maxHealth;
Data oriented components
Component Managers hold all the components (the number below each component is the entity associated with it)
Memory layout for our two possibilities
The bomb reduces maximum health by 20%
foreach(entity hit by bomb):
HealthComponent hp = entity.getHealth();
hp.maxHealth = hp.maxHealth * 0.8;
Memory accesses for updating a single component
struct Transform {
int x;
int y;
struct Motion {
Vec2 velocity;
Vec2 acceleration;
void update(int dt){
for(entity in m_entities){
TransformComponent position = entity.getTransform();
MotionComponent motion = entity.getMotion();
position.x += motion.velocity.x;
position.y += motion.velocity.y;
motion.velocity.x += motion.acceleration.x;
motion.velocity.y += motion.acceleration.y;
Movement System memory accesses
The systems we would need to create our game.
Current progress of Nomad.


-- —

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store