I would just have a lot of the map already loaded and show a small portion of it. Wherever the character is in the center you can subtract some to x and y for a corner of the screen. A lot of small subtractions and updates would make the screen move.
This is one such problem where if you know how to do the prerequisites to it (drawing a map, moving player on the map), you should already understand how to do it.
To draw a [tile based] map you just loop through each tile and if it's "on screen" (which can be determined by its position+size compared to the screen size), draw it at its position.
To draw a "scrolling" tile based map, you simply offset the position of all tiles by a 'scroll' variable (ie, a value you add to each tile position). This changes which tiles are "on screen" as well as where they're drawn.
Then to "move the map" you simply have to change this scroll value and redraw the screen.
Note that this process is somewhat simplified in more modern graphic libs as you can apply a 'global' effect to shift everything over and therefore do not have to adjust each tile individually. SDL 1.x however has no such mechanism as it only does plain rect->rect copies so you're stuck having to do it yourself.
If you have done the tutorial then you should be able to do this. Like Disch said:
This is one such problem where if you know how to do the prerequisites to it (drawing a map, moving player on the map), you should already understand how to do it.
Specifically I would look at lesson 6 for clip blitting and sprite sheets
Once you have a sprite sheet of tiles, you could make a map array that holds different sprite tokens. Then output a section of the array to the screen, by traversing the array and outputting the correct sprite tile.
I'm not going to write complete map code and comment it just to explain a concept ;P However I will refer you to some posts I've made in the past which go over this topic in more detail:
Have different tiles for the walls
1: Upper left corner
2: Upper wall
3: Upper right corner
4: Right wall
5: Lower right corner
6: Lower wall
etc.
The easiest quickest way I can think of having a map programmed would be to have an integer array that contained a number corresponding to a tile.
Then you would just iterate over a section of the map to output a section of it.
Lets say the character is at x and the 9x9 tile map looks like this:
/-------\
| |
| x |
| |
\-------/
But the screen only has enough space for 3x3 tiles because I am programming for something with a tiny screen in this example.
So the output on the screen would be:
x
The current section of the map would be the rectangle from (1, 3) to (3, 5) inclusive and zero-based (also x and y is swapped because that usually how matrices are indexed)
Then to shift the view 1 to the right you would output the rectange (1, 4) to (3, 6)
You need to define the type TileProperties then I think.
Edit:
1 2 3 4 5 6
struct TileProperties
{
bool bWall; // true if the tile is a solid wall
int nGfxX; // X coord of the graphic
int nGfxY; // Y coord of the graphic
};
Try this definition instead
1 2 3 4 5 6
typedefstruct TileProperties
{
bool bWall; // true if the tile is a solid wall
int nGfxX; // X coord of the graphic
int nGfxY; // Y coord of the graphic
}TileProperties;
Or another solution would be to type out struct TileProperties everywhere.