Now that we have a small scrolling tile engine set up, how do I implement it into a game?
It's relatively simple. To get the world scrolling you'd have to do something like this:
if (keypress_right)
{
world_camerax += 8;
}
if (keypress_up)
{
world_cameray += 8;
}
Now the player can press a key and have the tiled world scroll. Of course, a lot more goes into the workings of the world/player movement in a game, but I'm sure you can all figure it out : )
Note: I just made up keypress_right, etc. You'd have to set up DirectInput or use the Win32 API input functions to get player input.
What is that ugly stuff that's happening around the edges of the tiles when I scroll the world?
That "ugly stuff" is BltFast() not being able to blit objects past the edges of the screen. What you are actually seeing is the drawing of a tile until the top/right/bottom/left of it hits the edge of the screen, and then nothing will be drawn in its place.
You can fix it by:
Converting all this stuff to use Blt() instead of BltFast().
Doing some fancy calculations with the tile_src RECTs for the appropriate rows or columns.
Cheating and clearing the area around the ugly part with a black section so that it all looks fine and dandy : )
What about all that other stuff like collision detection, multi-layers, etc.?
I'll really try to get to it. I promise.
"I thought this article was pretty cool!" OR "I hated this @%*^%!$ article!"