Example #1
0
void MapView::displayBackground()
{
    this->removeLayer(BGRD);
    for(int i=0;i<map->getSize().width();i++)
    {
        for(int j=0;j<map->getSize().height();j++)
        {
            blitTile(i,j,0,BGRD);
        }
    }
}
Example #2
0
void blitTilePalette( ) {
  serial_fillRect(panel_left,panel_top,240,35,1);

  serial_fillRect(tile_palette_left+(tile_a_x*9)-1,tile_palette_top+(tile_a_y*9)-1,10,10,7);
  serial_fillRect(tile_palette_left+tile_b_x*9-1,tile_palette_top+tile_b_y*9-1,10,10,3);
 
  for (uint16_t ty=0; ty<4; ty++){
    for (uint16_t tx =0 ;tx < 26; tx++) {
      uint16_t tilex= (palette_offset_x +tx) % tileset_width;
      uint8_t halfskip= ((palette_offset_x +tx) /tileset_width) * (tileset_height/2);
      uint16_t tiley= ((palette_offset_y + ty +halfskip)) % tileset_height  ;
      blitTile(panel_left+3+tx*9,panel_top+1+ty*9,tilex+tiley*tileset_width,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 ++;
    }
}
void
GameView::drawMap(Surface &window)
{
    // @todo make new map drawing
//    TileSet * ts = TileInterface::getTileSet();
    iXY world;
    iXY map;
    
    WorldViewInterface::getMainCamera()->getViewStart(window.getWidth(), window.getHeight(),
                              &world.x, &world.y);
    MapInterface::pointXYtoMapXY( world, map );
        
//    unsigned short tile_size = ts->getTileXsize();
    unsigned short tile_size = 32;
    
    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;
    
    const MapFile * worldmap = 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 = worldmap->getValue(tmx++, map.y);
            blitTile(window, tile, x, y);
        }
        map.y ++;
    }
}