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
:
void GameLoop(const float p_deltatTime) { Update(p_deltatTime); Render(); }
We now have two new features:
- We added
p_deltaTime
as a parameter. This represents the amount of time that has passed in milliseconds since the last frame...