void Map::DrawAI(int minTileID) { int DrawX = 0; int DrawY = 0; for (int y = 0; y < mHeight; y++) { for (int x = 0; x < mWidth; x++) { const Tile & tile = TileAt(x, y); if (tile.mAI >= minTileID) { SDL_Rect src = { tile.mAI * TILE_SIZE, 0, TILE_SIZE, TILE_SIZE }; SDL_Rect dest = { DrawX, DrawY, 0, 0 }; SDL_BlitSurface(mAISurface, &src, Engine.GetBackBuffer(), &dest); } DrawX += TILE_SIZE; } DrawX = 0; DrawY += TILE_SIZE; } }
void BackMap::Update(GFX::rect rect) { if (fImage == NULL) return; assert(fOverlays[0]); fImage->Clear(0); const uint16 firstTileX = rect.x / fTileWidth; const uint16 firstTileY = rect.y / fTileHeight; uint16 lastTileX = firstTileX + (rect.w / fTileWidth) + 2; uint16 lastTileY = firstTileY + (rect.h / fTileHeight) + 2; lastTileX = std::min(lastTileX, fMapWidth); lastTileY = std::min(lastTileY, fMapHeight); bool advance = true; //bool advance = Timer::Get("ANIMATEDTILES")->Expired(); GFX::rect tileRect(0, 0, fTileWidth, fTileHeight); for (uint16 y = 0; y < fMapHeight; y++) { tileRect.w = fTileWidth; tileRect.h = fTileHeight; tileRect.y = y * fTileHeight - rect.y; const uint32 tileNumY = y * fMapWidth; for (uint16 x = 0; x < fMapWidth; x++) { tileRect.w = fTileWidth; tileRect.x = x * fTileWidth - rect.x; TileCell* tile = TileAt(tileNumY, x); if (tile == NULL) { continue; } if (advance) tile->AdvanceFrame(); if (y >= firstTileY && y <= lastTileY && x >= firstTileX && x <= lastTileX) tile->Draw(fImage, &tileRect, false, true); } } }
void RoomContainer::_UpdateBaseMap(GFX::rect mapRect) { #if 0 MapOverlay *overlay = fOverlays[0]; if (overlay == NULL) { std::cerr << "Overlay 0 is NULL!!" << std::endl; return; } const uint16 overlayWidth = overlay->Width(); const uint16 firstTileX = fAreaOffset.x / TILE_WIDTH; const uint16 firstTileY = fAreaOffset.y / TILE_HEIGHT; uint16 lastTileX = firstTileX + (mapRect.w / TILE_WIDTH) + 2; uint16 lastTileY = firstTileY + (mapRect.h / TILE_HEIGHT) + 2; lastTileX = std::min(lastTileX, overlayWidth); lastTileY = std::min(lastTileY, overlay->Height()); bool advance = true; //bool advance = Timer::Get("ANIMATEDTILES")->Expired(); GFX::rect tileRect(0, 0, TILE_WIDTH, TILE_HEIGHT); for (uint16 y = 0; y < overlay->Height(); y++) { tileRect.w = TILE_WIDTH; tileRect.h = TILE_HEIGHT; tileRect.y = y * TILE_HEIGHT - fAreaOffset.y; const uint32 tileNumY = y * overlayWidth; for (uint16 x = 0; x < overlayWidth; x++) { tileRect.w = TILE_WIDTH; tileRect.x = x * TILE_WIDTH - fAreaOffset.x; TileCell* tile = TileAt(tileNumY, x); if (advance) tile->AdvanceFrame(); if (y >= firstTileY && y <= lastTileY && x >= firstTileX && x <= lastTileX) tile->Draw(fBackBitmap, &tileRect, false, fDrawOverlays); } } #endif }
void Map::Draw() { mAnimationFrameTime += Engine.GetElapsedTime(); if (mAnimationFrameTime >= 0.25f) { mAnimationFrameTime = 0.0f; mAcidPoolsAnimationFrame++; if (mAcidPoolsAnimationFrame == 4) { mAcidPoolsAnimationFrame = 0; } } int DrawX = 0; int DrawY = 0; for (int y = 0; y < mHeight; y++) { for (int x = 0; x < mWidth; x++) { const Tile & tile = TileAt(x, y); int gfx = tile.mGfxID; if (gfx == 12) { gfx += mAcidPoolsAnimationFrame; } SDL_Rect src = { gfx * TILE_SIZE, 0, TILE_SIZE, TILE_SIZE }; SDL_Rect dest = { DrawX, DrawY, 0, 0 }; DrawX += TILE_SIZE; SDL_BlitSurface(mSurface, &src, Engine.GetBackBuffer(), &dest); } DrawX = 0; DrawY += TILE_SIZE; } }