Game Events & Object Communication

BlitzMax Forums/BlitzMax Programming/Game Events & Object Communication

thalamus(Posted 2010) [#1]
I'm working on some enemy AI for a game project, and I was wondering what might be a good system for handling in-game events...?

For example, I have a trigger box; when the player enters, a variable is set. How would I link this to an enemy? Or multiple enemies?

For instance, if I wanted to spawn or alert an enemy when the player entered the trigger box - how would I handle this?


zambani(Posted 2010) [#2]
One way to it is to have an TList or an array to which you can add or remove enemies that should respond to your trigger box. So once the box is triggered, as you set your variable, you would also run a function that would go through your Tlist or Array of enemies which was added earlier and run a "handler" method on each of them.


Muttley(Posted 2010) [#3]
Hi thalamus :)

Have a look at how we do the MessageService components in the RetroRemakes Framework (there are some examples too). This allows you to either subscribe objects to a message channel so that they receive any message broadcast on that channel. You can also send a message direct to objects as well.

Link should be in my sig.

Muttley