Jump to content


Member Since 07 May 2005
Offline Last Active Apr 22 2017 05:04 AM

Posts I've Made

In Topic: Mono or Lua - Scripting

05 January 2014 - 07:38 AM

I like Lua since the simple nature of it forces you to think carefully what to do with scripts and what to do with c/c++ for example. as mentioned Lua tables are very flexible and pretty fast so you can do a lot of crazy things with them.


In my current project I do all the per frame update stuff with c++ and Lua just take care of callbacks and define objects

In Topic: Entity component system: efficient component retrieval?

04 January 2014 - 06:08 PM

Does your PositionBehavior have a list of all Positions components? if so then it can update them without getting them from the object itself.


This is how I do my component updates.

In Topic: C++ Entity/Component System Setup Assistance

15 April 2013 - 07:14 AM

I'm surprised no one linked to Understanding Component-Entity-Systems.


I am surprised by the emphasis on messaging. The system I am using has

  • no implicit messaging: I couldn't figure out a proper behavior that would make sense in general
  • no parent-child relationships, admittedly for the lack of time in implementing those
  • no need to poll for components: I operate on them directly instead


Object name (a pointer to a template that keep tracks of the name it was instanced with)

A pointer to a template... of the name... it was instanced with. So it's variable name or not?


Yea that was kind of badly worded, what I meant is that each object in the scene was created using something like

local inst = instance_create("ObjectName")

-- where this could be an object
ObjectName =
   on_created = function(self)



So the object holds a pointer to an ObjectTemplate that has the string name and a connection to the Lua table.


My messaging system operates by components binding a callback to a message name on the object, whenever a component posts something the object calls all the other components that subscribed to that particular message. This is mostly used to hook stuff when components gets added or removed.

In Topic: C++ Entity/Component System Setup Assistance

10 April 2013 - 08:06 AM

Yea that is the charm of the component/entity system, there is so many variations of it. My version integrates nicely with my lua implementation and allows me to do what I need, in the end the requirements you have on your engine/game will decide how sometime as important as the object management will be done.


You can also do really easy and slimmed component implementations, and actually I am using something similar to your technique Juliean when creating particle systems.

In Topic: C++ Entity/Component System Setup Assistance

10 April 2013 - 05:51 AM

Hey taurusrow 


I have been experimenting with component based object system now for a couple of years and the results have been getting better and better each time, currently I am actually streaming my current programming project live on http://www.twitch.tv/devmoon


I am using a very decoupled component/subsystem approach where each subsystem is completely independent and currently I have these systems but it will be more later

  • Transform
  • Physics
  • Collision
  • Timer
  • Editable
  • Render

To answer your questions


An object consists of the following

  • Unique ID
  • Object name (a pointer to a template that keep tracks of the name it was instanced with)
  • Array or component pointers
  • Internal messaging system (being able to communicate with the components)

A component consists of

  • Pointer to the object its attached to (so it can communicate)
  • Custom data its working on (position in the transform component etc..)
  • Pointer to the subsystem

A subsystem consists of

  • A vector of components (that is pre allocated)
  • Updates the components that have been used by any object


From my experience component based object systems is not some kind of "solve all your problems" but just another way to manage your game objects. You still need to craft it to fit your needs.


To update everything I have an ordered list of all my subsystems and call their update method


Here is also a script example of how it can be used (lua script)


sample_object =
	on_created = function(self)
		self:add_component("Collision", {width = 10, height = 10})
		self:add_component("Timer", {[70] = instance_destroy})
	on_collision_enter = function(self, other)
		if (other.solid) then
        -- if there is no render method there is no overhead of trying to call one
	on_render = function(self, x, y, z)

                -- some custom draw code here if needed



I do stream programming almost every day and you can ask me anything and I might make all the code available for public at a later date


Good luck with the component systems it is really fun to work with smile.png