Skip to content

aabanakhtar/custom-ecs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CustomECS

Toy ECS that improves performance by optimizing cache lines and preventing cache misses. Based on the framework by Austin Molan.

Example

// define a component
struct pos_component : ECS::ComponentBase {
  float x, y; 
};

// make the game scene and register components
ECS::Scene scene;
scene.registerComponent<pos_component>();

// create an entity
ECS::EntityID entity = scene.createEntity();
scene.addComponent<pos_component>(entity) = {
  .x = 0, .y = 10
};

// "system"
SceneView<pos_component> view(scene);
for (auto ID : view.getEntities()) {
  auto& pos = scene.getComponent<pos_component>(ID);

  // do some operations
  pos.x += 3;
  pos.y += 5; 
}

About

Toy ECS that improves performance by optimizing cache lines to not miss.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages