How does a game state interact with a component based component?

Iโ€™ve been doing some remaking of my flash framework lately, and when I make about one game a month, the idea of โ€‹โ€‹using reusable components to quickly create prototypes seems really attractive to me.

The factor that holds me back is how the game state extracts information from the entities themselves.

For example, centering the camera on the player is usually quite simple: camera.x = player.x; but I'm not sure how you would do something similar with component based objects.

Any ideas or links to systems where you can easily pull such data?

+4
source share
1 answer

You may have components for creating the event and interested parties to register listeners for these events. for an instance, you can listen to other components. This approach should be simple and strong enough for you.

 final Camera camera = new Camera() ; Player player = new Player() ; player.OnMove += new MovementListener() { public void onMove(Position newPosition) { camera.UpdatePositionWith(newPosition) } } 

Hope this helps.

+1
source

All Articles