예제 #1
0
void
GameView::drawMap(Surface &window)
{
    TileSet * ts = TileInterface::getTileSet();
    unsigned long world_x;
    unsigned long world_y;
    unsigned short map_x;
    unsigned short map_y;
    
    WorldViewInterface::getMainCamera()->getViewStart(window.getWidth(), window.getHeight(),
                              &world_x, &world_y);
    MapInterface::pointXYtoMapXY( world_x, world_y, &map_x, &map_y );
        
    unsigned short tile_size = ts->getTileXsize();
    
    long partial_y = world_y % tile_size;
    int y = 0;
    if ( partial_y )
    {
        y -= partial_y;
    }
    
    long partial_x = world_x % tile_size;
    int start_x = 0;
    if ( partial_x )
    {
        start_x -= partial_x;
    }
    
    unsigned int tile = 0;
    
    WorldMap * map = MapInterface::getMap();
    
    unsigned short tmx;
    
    for ( ; y < (int)window.getHeight(); y += tile_size )
    {
        tmx = map_x;
        for ( int x = start_x; x < (int)window.getWidth(); x += tile_size )
        {
            tile = map->getValue(tmx++, map_y);
            blitTile(window, tile, x, y);
        }
        map_y ++;
    }
}
 static WorldMap::MapElementType MapValue(size_t offset)
 {
     return main_map.getValue(offset);
 }
 static WorldMap::MapElementType MapValue(size_t x, size_t y)
 {
     return main_map.getValue(x, y);
 }