Creating a real scene
At the moment, RHB can move anywhere he wants, in an empty void, such as the one in The Matrix. It's progress; all that animation was real work, but it's not a game. It's time we put RHB in a setting – a background, platforms, maybe something to jump over. Let's start with a background.
Adding the background
Right now, our game can only render images from a sprite sheet, which we can use for a background, but that's overkill for one image. Instead, we'll add a new struct
that draws a simple image from a .png
file. Then, we'll add that to the draw
and initialize
functions in WalkTheDog
:
- Create an
Image
struct.
We can work bottom-up for these changes, adding code to the engine and then integrating it into the game. Our Image
struct
will use a lot of the same code that we wrote in Chapter 2, Drawing Sprites, but with a simpler setup because we won't be using a sheet. All of this code should go into...