How would I make the map move with the character (so the character is always centered)
The way that I did this with the rpg I'm working on is to have the player have standard coords (x,y) and also have a set of screen coords (screenx,screeny). This is done in two easy steps. First you determine screenx and screeny using the players coords and the width/height of the map (assuming that the player's coords are the upper left corner of the bmp):
Code:
if (player.x < SCREEN_W/2 - player.width/2)
screenx = 0;
else if (player.x > map.width - SCREEN_W/2 - player.width/2)
screenx = map.width - SCREEN_W;
else
screenx = player.x + player.width/2 - SCREEN_W/2;
You repeat this for y with *.height and SCREEN_H, then you use these values when you're rendering:
Code:
for (i = 0; i < map.tilew; ++i)
for (j = 0; j < map.tileh; ++j)
draw_sprite(buffer,tiles[map[i][j]],i*tilew-screenx,j*tileh-screenh);
draw_sprite(buffer,player.bmp,player.x-screenx,player.y-screeny);
I'm not on my computer so I'm not sure if that's the way draw_sprite() works, but you get the idea, right? Subtract screenx and screeny from coords when rendering? I'm not sure if this is what you were looking for, but I hope it helps.