I'm sure I'll end up feeling stupid for asking this ( because the solution is probably obvious ), but I'm having trouble with the tile map I have created. Drawing the 2D map at ( x, y ) position works fine. But, I'm having trouble with scrolling the map. When I call the second command below, it runs a never ending loop and crashes. What should I do differently?
void cTileMap::draw_map ( int x_start, int y_start )
{
if ( vTileMap.size ( ) )
{
int n = 50;
int map_size = ( int ) vTileMap.size ( );
for ( int x = 0; x < map_size; x++ )
{
for ( int y = 0; y < map_size; y++ )
{
dbSprite ( n, x * tile_width + x_start, y * tile_height + y_start, vTileMap[y][x].type );
n++;
}
}
}
}
void cTileMap::scroll_map ( int x_start, int y_start, int x_end, int y_end, int speed )
{
for ( int x = 0; x < ( x_end - x_start ); x++ )
{
for ( int y = 0; y < ( y_end - y_start ); y++ )
{
draw_map ( x_start + x, y_start + y );
dbSync ( );
}
}
}
EDIT: The speed parameter for scroll_map is for future usage. I hope to use that variable to control the speed of animation. I'm not really sure how to at the moment.