void TileOverlay::Draw(Region viewport, std::vector< TileOverlay*> &overlays) { Video* vid = core->GetVideoDriver(); Region vp = vid->GetViewport(); // if the video's viewport is partially outside of the map, bump it back BumpViewport(viewport, vp); // determine which tiles are visible int sx = vp.x / 64; int sy = vp.y / 64; int dx = ( vp.x + vp.w + 63 ) / 64; int dy = ( vp.y + vp.h + 63 ) / 64; for (int y = sy; y < dy && y < h; y++) { for (int x = sx; x < dx && x < w; x++) { Tile* tile = tiles[( y* w ) + x]; //draw door tiles if there are any Animation* anim = tile->anim[tile->tileIndex]; if (!anim && tile->tileIndex) { anim = tile->anim[0]; } vid->BlitTile( anim->NextFrame(), 0, viewport.x + ( x * 64 ), viewport.y + ( y * 64 ), &viewport, false ); if (!tile->om || tile->tileIndex) { continue; } //draw overlay tiles, they should be half transparent int mask = 2; for (size_t z = 1;z<overlays.size();z++) { TileOverlay * ov = overlays[z]; if (ov && ov->count > 0) { Tile *ovtile = ov->tiles[0]; //allow only 1x1 tiles now if (tile->om & mask) { if (RedrawTile) { vid->BlitTile( ovtile->anim[0]->NextFrame(), tile->anim[0]->NextFrame(), viewport.x + ( x * 64 ), viewport.y + ( y * 64 ), &viewport, false ); } else { Sprite2D* mask = 0; if (tile->anim[1]) mask = tile->anim[1]->NextFrame(); vid->BlitTile( ovtile->anim[0]->NextFrame(), mask, viewport.x + ( x * 64 ), viewport.y + ( y * 64 ), &viewport, true ); } } } mask<<=1; } } } }
void Sprite::NextFrame() { Animation* temp; temp = pAnimations->GetAnimation( current_behaviour ); temp->NextFrame(); }