Loops can be found in any video game running in real-time. Small incremental steps generally characterize gameplay simulation code. With each of these steps occurs a minimal frame-by-frame change of object transformations, creating the illusion of smooth movement.
Panda3D has its own way of handling code that needs to be called time and time again while the game is running. This recipe's topic is Panda3D's task system.
Please complete the tasks found in Setting up the game structure found in Chapter 1 to get ready for this recipe.
Let's implement an application that uses the task system to execute a piece of code in every frame: