Skip to content

Instantly share code, notes, and snippets.

@LearnCocos2D
Last active December 16, 2016 18:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LearnCocos2D/d541d9905d1320ad6d2e to your computer and use it in GitHub Desktop.
Save LearnCocos2D/d541d9905d1320ad6d2e to your computer and use it in GitHub Desktop.
Entity Component Systems compared with pseudo-code (variants: GameplayKit, Adam Martin, Scott Bilas)

Full ECS discussion gist: https://gist.github.com/LearnCocos2D/77f0ced228292676689f

ECS by Scott Bilas (GDC 2002, Dungeon Siege)

foreach entity in allEntities do
    foreach component in entity.components do
	    component.update()
	end
end

ECS by Scott Bilas (fixed-order component update)

foreach componentSystem in allComponentSystems do
	foreach component in componentSystem.components do
		component.update()
	end
end

ECS by Apple's GameplayKit

foreach componentSystem in allComponentSystems do
	componentSystem.update() // inner loop encapsulated by GKComponentSystem
end

ECS by Adam Martin

foreach componentSystem in allComponentSystems do
	foreach component in componentSystem.components do
		// component (data) processing logic inlined here ...
	end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment