From 96568b57422f89d47350028f987442e9e9006cbb Mon Sep 17 00:00:00 2001 From: scawful Date: Fri, 22 Jul 2022 20:18:47 -0400 Subject: [PATCH] Refactor bitmap CreateTiles function --- src/app/gfx/bitmap.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/app/gfx/bitmap.cc b/src/app/gfx/bitmap.cc index 892cf471..2d0e8a1e 100644 --- a/src/app/gfx/bitmap.cc +++ b/src/app/gfx/bitmap.cc @@ -96,14 +96,12 @@ std::vector Bitmap::CreateTiles() { std::vector tiles; for (int i = 0; i < 16; ++i) { for (int j = 0; j < 4; ++j) { - tiles.emplace_back(8, 8, 8, 32); - auto surface = tiles[i + j].GetSurface(); - SDL_Rect src_rect; - src_rect.x = i; - src_rect.y = j; - src_rect.w = 8; - src_rect.h = 8; - SDL_BlitSurface(surface_, &src_rect, surface, NULL); + Bitmap bmp; + bmp.Create(8, 8, 8, 32); + auto surface = bmp.GetSurface(); + SDL_Rect src_rect = {i, j, 8, 8}; + SDL_BlitSurface(surface_, &src_rect, surface, nullptr); + tiles.push_back(bmp); } } return tiles;