| 30 | } |
| 31 | |
| 32 | void Screen::Draw(Bitmap& dst) { |
| 33 | auto flash_color = Main_Data::game_screen->GetFlashColor(); |
| 34 | if (flash_color.alpha > 0) { |
| 35 | if (!flash) { |
| 36 | flash = Bitmap::Create(dst.GetWidth(), dst.GetHeight(), flash_color); |
| 37 | } else { |
| 38 | flash->Fill(flash_color); |
| 39 | } |
| 40 | dst.Blit(0, 0, *flash, flash->GetRect(), 255); |
| 41 | } |
| 42 | |
| 43 | if (viewport != Rect()) { |
| 44 | // Clear all parts of the screen that are out-of-bounds |
| 45 | Rect dst_rect = dst.GetRect(); |
| 46 | int dx = viewport.x - dst_rect.x; |
| 47 | int dy = viewport.y - dst_rect.y; |
| 48 | |
| 49 | if (dx > 0) { |
| 50 | // Left and Right |
| 51 | dst.ClearRect({0, 0, dx, dst.GetHeight()}); |
| 52 | dst.ClearRect({dst.GetWidth() - dx, 0, dx, dst.GetHeight()}); |
| 53 | } |
| 54 | |
| 55 | if (dy > 0) { |
| 56 | // Top and Bottom |
| 57 | dst.ClearRect({0, 0, dst.GetWidth(), dy}); |
| 58 | dst.ClearRect({0, dst.GetHeight() - dy, dst.GetWidth(), dy}); |
| 59 | } |
| 60 | } |
| 61 | } |