Sunday, April 30, 2017

architecture - What role does developing with events have in games?


Most application development is based around developing with events, but considering the game-loop style of developing games and the (often) need for high performance/throughput, what role does developing using events have and what are the trade-offs? Does the synchronization/locking that is often involved have a greater impact?


For instance: - How does the network [layer] notify the game-loop of data received? - How does the physics system notify of collisions


I ask, because I can remember a time when game development using events was a strict no-no. Has this changed?



Answer




Events system are powerful, and can be made very fast.


They also allow you to modulise sections of code in a very loose coupling structure. They let you job batch things and thread off tasks. The work well with multi-core and asynchronous functions.


Physics - Collision Callbacks, Activate or Rest Objects translate well to events. Networking - As much as possible should be an event (voice chat ect.. the exception) Game Logic - Naturally lends itself to an event model Menus & UI - Work brilliant in an event based system


Also many modern consoles, and middle-ware libraries use events.


The renderer and polling of input devices can be a bit confusing to fit in. Especially if you are using motion controls, as events can introduce a noticeable latency and be counter-intuitive to polling format.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...