void CMinimapInstance::drawScaled(int level) { int3 mapSizes = LOCPLINT->cb->getMapSize(); //size of one map tile on our minimap double stepX = double(pos.w) / mapSizes.x; double stepY = double(pos.h) / mapSizes.y; double currY = 0; for (int y=0; y<mapSizes.y; y++, currY += stepY) { double currX = 0; for (int x=0; x<mapSizes.x; x++, currX += stepX) { const SDL_Color &color = getTileColor(int3(x,y,level)); //coordinates of rectangle on minimap representing this tile // begin - first to blit, end - first NOT to blit int xBegin = currX; int yBegin = currY; int xEnd = currX + stepX; int yEnd = currY + stepY; for (int y=yBegin; y<yEnd; y++) { Uint8 *ptr = (Uint8*)minimap->pixels + y * minimap->pitch + xBegin * minimap->format->BytesPerPixel; for (int x=xBegin; x<xEnd; x++) ColorPutter<4, 1>::PutColor(ptr, color); } } } }
void TileMap::draw() { const DWORD COLOR_BOARD_LINE = 0x55020202; for (int i = 0; i <= CELL_COUNT_Y; ++i) // ºáÏß { g_HGE->Gfx_RenderLine(0, i*CELL_SIZE_Y, CELL_COUNT_X*CELL_SIZE_X, i*CELL_SIZE_Y, COLOR_BOARD_LINE); } for (int i = 0; i <= CELL_COUNT_X; ++i) // ÊúÏß { g_HGE->Gfx_RenderLine(i*CELL_SIZE_X, 0, i*CELL_SIZE_X, CELL_COUNT_Y*CELL_SIZE_Y, COLOR_BOARD_LINE); } for (short x = 0; x < CELL_COUNT_X; ++x) { for (short y = 0; y < CELL_COUNT_Y; ++y) { util::fillCell(CellCoord(x, y), getTileColor(getTileType(fdkgame::navi::CellCoord(x, y))) ); } } }
void initMiniMap(bool loadUpWorld) { int i, x, y; for (i = 0; i < 5; ++i) { for (x = 0; x < 128; ++x) { for (y = 0; y < 128; ++y) { if (!loadUpWorld) { // generate stairs up when making a new world. switch (map[i][x + y * 128]) { case TILE_STAIRS_DOWN: map[i + 1][x + y * 128] = TILE_STAIRS_UP; if (i == 0) { map[i + 1][(x + 1) + y * 128] = TILE_HARDROCK; map[i + 1][x + (y + 1) * 128] = TILE_HARDROCK; map[i + 1][(x - 1) + y * 128] = TILE_HARDROCK; map[i + 1][x + (y - 1) * 128] = TILE_HARDROCK; map[i + 1][(x + 1) + (y + 1) * 128] = TILE_HARDROCK; map[i + 1][(x - 1) + (y - 1) * 128] = TILE_HARDROCK; map[i + 1][(x - 1) + (y + 1) * 128] = TILE_HARDROCK; map[i + 1][(x + 1) + (y - 1) * 128] = TILE_HARDROCK; } else { map[i + 1][(x + 1) + y * 128] = TILE_DIRT; map[i + 1][x + (y + 1) * 128] = TILE_DIRT; map[i + 1][(x - 1) + y * 128] = TILE_DIRT; map[i + 1][x + (y - 1) * 128] = TILE_DIRT; map[i + 1][(x + 1) + (y + 1) * 128] = TILE_DIRT; map[i + 1][(x - 1) + (y - 1) * 128] = TILE_DIRT; map[i + 1][(x - 1) + (y + 1) * 128] = TILE_DIRT; map[i + 1][(x + 1) + (y - 1) * 128] = TILE_DIRT; } } } /* Minimaps */ sf2d_set_pixel(minimap[i], x, y, getTileColor(map[i][x + y * 128])); } } } }
void DisplayGrid::draw(sf::RenderTarget &target, sf::RenderStates states) const { int amtX = obsMap->getWidth(); int amtY = obsMap->getHeight(); int sizeX = getSize().x; int sizeY = getSize().y; int tileX, tileY; sf::Vector2f tileSize(sizeX / amtX, sizeY / amtY); sf::RectangleShape tile(tileSize); sf::Vector2f pos = getPosition(); for (int x = 0; x < amtX; x++) { for (int y = 0; y < amtY; y++) { tileX = pos.x + tileSize.x * x; tileY = pos.y + tileSize.y * y; tile.setPosition(tileX, tileY); tile.setFillColor(getTileColor(obsMap->at(x, y))); tile.setOutlineColor(getOutlineColor()); tile.setOutlineThickness(getOutlineThickness()); target.draw(tile); } } }
void CMinimapInstance::refreshTile(const int3 &tile) { blitTileWithColor(getTileColor(int3(tile.x, tile.y, level)), tile, minimap, 0, 0); }