Code: Select all
bool LoadLevel( const std::string& filename )
{
std::ifstream file;
file.open( filename.c_str(), ios::in );
char temp;
if(!file.is_open())
{
return false;
}
for( int x = 0; x < 40; x++ )
{
for( int y = 0; y < 30; y++ )
{
file >> map[y][x];
//map[y][x] = temp;
cout<<map[y][x];
}
}
file.close();
return true;
}
void draw_level()
{
for( int x = 0; x < 40; x++ )
{
for( int y = 0; y < 30; y++ )
{
if( map[y][x] == 0 )
{
draw_surface( x * 32 - camera.x, y * 32 - camera.y, tiles, screen, &clip_tiles[0] ); //draw the first tile in the sprite sheet
}
if( map[y][x] == 2 )
{
draw_surface( x * 32 - camera.x, y * 32 - camera.y, tiles, screen, &clip_tiles[2] ); //draw the third sprite in the tilesheet
}
}
}
}