Skip to content

(Deprecated - use Eskimo) A simple entity system written in Haxe - Round 2

License

Notifications You must be signed in to change notification settings

PDeveloper/hxE2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deprecated - use Eskimo

hxE2

An entity system that is evolved from hxE. This does not deprecate hxE, but rather offers a different approach to entity systems that is more in line with my own views on how one should be implemented. Short post about hxE2, which also compares some differences to hxE.

Install

haxelib git hxE2 https://github.com/PDeveloper/hxE2.git

Usage

var world = new EntityWorld();

var e = world.create();

e.setComponent(new PositionComponent());
e.setComponent(new DisplayComponent());

var view = new View2(world, PositionComponent, DisplayComponent);

while (true)
{
  view.update();
  
  for (e in view.removedEntities) remove(e); // do something with removed entities if needed
  for (e in view.addedEntities) add(e); // do something with added entities if needed
  for (e in view.updatedEntities) update(e); // do something with only updated entities if needed
  
  for (e in view.entities) func(e); // do something with all entities in the view if needed
}

function update(e:Entity):Void
{
  var position = view.get1(e);
  var display = view.get2(e);
  
  position.x += 5.0;
  view.set1(e, position); // update component
}

view.dispose(); // dispose views when they are no longer relevant / don't need to receive updates

About

(Deprecated - use Eskimo) A simple entity system written in Haxe - Round 2

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages