The traditional game design, as I know it, uses polymorphism and virtual functions to update game objects states. In other words, the same set of virtual functions are called in regular(ex: per-frame) intervals on every object in the game.
Recently, I discovered, that there is another - event driven messaging system available to update states of game objects. Here, the objects usually are not updated on per-frame basis. Instead, a highly efficient event messaging system is built, and game objects get updated only after receiving valid event message.
Event Driven Game Architecture is well described in: Game Coding Complete by Mike McShaffry .
Could I kindly ask for help with the following questions:
- What are the advantages and disadvantages of the both approaches?
- Where is one better over the other?
- Is Event driven game design universal and better in all areas? Is it therefore recommended for usage even in mombile platforms?
- Which one is more efficient and which is more difficult to develop?
To clarify, my question is not about removing polymorphism completely from a game design. I simply wish to understand the difference and benefit from using event driven messaging vs regular(per-frame) calls to virtual functions to update game state.
Example: This question caused a bit of controversy here, so let me offer you example: According to MVC, the game engine is divided into three main parts:
- Application Layer (Hardware and OS communication)
- Game Logic
- Game View
In a racing game, the Game View is responsible for rendering the screen as quickly as possible, at least 30fps. Game View listens for player's input too. Now this happens:
- Player presses fuel pedal to 80%
- GameView constructs a message "Car 2 Fuel Pedal Pressed to 80%" and sends it to Game Logic.
- Game Logic gets the message, evaluates, calculates new car's position and behavior and creates the following messages for GameView: "Draw Car 2 Fuel Pedal Pressed 80%", "Car 2 Sound Acceleration", "Car 2 Coordinates X, Y" ...
- GameView receives the messages and processes them accordingly
update
on them). The second you can do with messaging for various reasons. \$\endgroup\$