A moving example

The code that we created until this point creates a basic scene with our robot and a background. Now, it's time to bring our robot to life using the power of animation.

Animation actually has two components. First, the sprite itself will appear to animate because we will play each frame of the sprite in sequence. If you use the stock files that were made for this book, you will see the robot's eyes and arms move.

The second component is movement across the screen. It is the combination of the robot's horizontal movement and body movements that will make a convincing animation.

Adding update to the game loop

As with rendering, we start by adding an Update call to the GameLoop function. Modify the GameLoop function in RoboRacer.cpp ...

Get OpenGL Game Development By Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.