What is the best practice to use when events happen in a game? For example:
- You have a sensor. When a particular game actor is near that sensor, a sound must be played and a door must be closed.
- When a collision between characters
Awith animationiand characterBwith animationjhappens, a special graphical effect, a sound effect and a decrease of life points ofAandBshould come into effect. Furthermore,AandBmust be forced to return to some specific animation. - The user presses the left-key, so actor
Amust be moved.
What I would like to know is: do you play sound, move the player, close the door (calling the relevant methods, like PlaySound(..), CloseDoor() or MovePlayerLeft()) directly in the event handler or do you use some sort of message based system, so that when the actor manager code is called, it sees that the player must be moved to the left and moves it to the left. Also, when the sound manager code is called, it sees that a particular sound must be played and plays it and so on...
Ps. I would really be happy to see some reference to books/papers/articles to read something related.
