Forgetting Tick
In this chapter we are going to explore the topic of tick (an event or process that is called every frame), why using it can cause frame-rate issues for our game projects, and two approaches to building systems without using tick, reducing the impact of systems on the CPU. We will consider the example of a guard tower in an RTS game, with a searchlight rotating back and forth. If the player’s unit is seen by the searchlight, it will stop its rotation. We will start with the Update pattern introduced in the previous chapter and iteratively improve from there, reducing our reliance on the Update pattern by using Timers, Timelines, and event-driven solutions instead. At each step, we will measure code efficiency, using execution counting to quantify our improvements.
In this chapter, we’ll cover the following topics:
- Tick events and the challenges we face when using them
- Timers and Timelines
- Event-driven systems