diff --git a/source/credits.cpp b/source/credits.cpp index a61226a..aa74121 100644 --- a/source/credits.cpp +++ b/source/credits.cpp @@ -29,10 +29,10 @@ Credits::Credits() Screen::get()->setBorderColor(stringToColor("black")); // Crea la textura para el texto que se escribe en pantalla - text_surface_ = std::make_shared(Screen::get()->getRenderSurfaceData(), options.game.width, options.game.height); + text_surface_ = std::make_shared(Screen::get()->getRendererSurface(), options.game.width, options.game.height); // Crea la textura para cubrir el rexto - cover_surface_ = std::make_shared(Screen::get()->getRenderSurfaceData(), options.game.width, options.game.height); + cover_surface_ = std::make_shared(Screen::get()->getRendererSurface(), options.game.width, options.game.height); // Escribe el texto en la textura fillTexture(); @@ -142,7 +142,7 @@ void Credits::fillTexture() iniTexts(); // Rellena la textura de texto - Screen::get()->setRenderSurfaceData(text_surface_); + Screen::get()->setRendererSurface(text_surface_); Screen::get()->clearSurface(stringToColor("black")); auto text = Resource::get()->getText("smb2"); @@ -164,46 +164,46 @@ void Credits::fillTexture() // Recoloca el sprite del brillo shining_sprite_->setPosX(POS_X + 2); - Screen::get()->setRenderSurfaceData(nullptr); + Screen::get()->setRendererSurface(nullptr); // Rellena la textura que cubre el texto con color transparente - Screen::get()->setRenderSurfaceData(text_surface_); + Screen::get()->setRendererSurface(text_surface_); Screen::get()->clearSurface(stringToColor("transparent")); // Los primeros 8 pixels crea una malla - auto surface_data = *(Screen::get()->getRenderSurfaceData()); + auto surface = Screen::get()->getRendererSurface(); auto color = stringToColor("black"); for (int i = 0; i < 256; i += 2) { - text_surface_->putPixel(surface_data, i, 0, color); - text_surface_->putPixel(surface_data, i, 2, color); - text_surface_->putPixel(surface_data, i, 4, color); - text_surface_->putPixel(surface_data, i, 6, color); + surface->putPixel(i, 0, color); + surface->putPixel(i, 2, color); + surface->putPixel(i, 4, color); + surface->putPixel(i, 6, color); - text_surface_->putPixel(surface_data, i + 1, 5, color); - text_surface_->putPixel(surface_data, i + 1, 7, color); + surface->putPixel(i + 1, 5, color); + surface->putPixel(i + 1, 7, color); } // El resto se rellena de color sólido SDL_Rect rect = {0, 8, 256, 192}; - text_surface_->fillRect(surface_data, &rect, color); + surface->fillRect(&rect, color); for (int i = 0; i < 256; i += 2) { - text_surface_->putPixel(surface_data, i, 0, color); - text_surface_->putPixel(surface_data, i, 2, color); - text_surface_->putPixel(surface_data, i, 4, color); - text_surface_->putPixel(surface_data, i, 6, color); + surface->putPixel(i, 0, color); + surface->putPixel(i, 2, color); + surface->putPixel(i, 4, color); + surface->putPixel(i, 6, color); - text_surface_->putPixel(surface_data, i + 1, 5, color); - text_surface_->putPixel(surface_data, i + 1, 7, color); + surface->putPixel(i + 1, 5, color); + surface->putPixel(i + 1, 7, color); } // El resto se rellena de color sólido rect = {0, 8, 256, 192}; - text_surface_->fillRect(surface_data, &rect, color); + surface->fillRect(&rect, color); - Screen::get()->setRenderSurfaceData(nullptr); + Screen::get()->setRendererSurface(nullptr); } // Actualiza el contador diff --git a/source/ending.cpp b/source/ending.cpp index 11b6b42..3879b08 100644 --- a/source/ending.cpp +++ b/source/ending.cpp @@ -43,7 +43,7 @@ Ending::Ending() Screen::get()->setBorderColor(stringToColor("black")); // Crea la textura para cubrir el texto - cover_surface_ = std::make_shared(Screen::get()->getRenderSurfaceData(), options.game.width, options.game.height + 8); + cover_surface_ = std::make_shared(Screen::get()->getRendererSurface(), options.game.width, options.game.height + 8); // Rellena la textura para la cortinilla fillCoverTexture(); @@ -172,8 +172,8 @@ void Ending::iniTexts() EndingSurface st; // Crea la textura - st.image_surface = std::make_shared(Screen::get()->getRenderSurfaceData(), WIDTH, HEIGHT); - Screen::get()->setRenderSurfaceData(st.image_surface); + st.image_surface = std::make_shared(Screen::get()->getRendererSurface(), WIDTH, HEIGHT); + Screen::get()->setRendererSurface(st.image_surface); text->writeDX(TEXT_STROKE, 2, 2, txt.caption, 1, color, 2, color); // Crea el sprite @@ -181,29 +181,29 @@ void Ending::iniTexts() st.image_sprite->setPosition((options.game.width - st.image_surface->getWidth()) / 2, txt.pos); // Crea la cover_surface - st.cover_surface = std::make_shared(Screen::get()->getRenderSurfaceData(), WIDTH, HEIGHT + 8); - Screen::get()->setRenderSurfaceData(st.cover_surface); + st.cover_surface = std::make_shared(Screen::get()->getRendererSurface(), WIDTH, HEIGHT + 8); + Screen::get()->setRendererSurface(st.cover_surface); // Rellena la cover_surface con color transparente Screen::get()->clearSurface(stringToColor("transparent")); // Crea una malla de 8 pixels de alto - auto surface_data = *(Screen::get()->getRenderSurfaceData()); + auto surface = Screen::get()->getRendererSurface(); color = stringToColor("black"); for (int i = 0; i < WIDTH; i += 2) { - st.cover_surface->putPixel(surface_data, i, 0, color); - st.cover_surface->putPixel(surface_data, i, 2, color); - st.cover_surface->putPixel(surface_data, i, 4, color); - st.cover_surface->putPixel(surface_data, i, 6, color); + surface->putPixel(i, 0, color); + surface->putPixel(i, 2, color); + surface->putPixel(i, 4, color); + surface->putPixel(i, 6, color); - st.cover_surface->putPixel(surface_data, i + 1, 5, color); - st.cover_surface->putPixel(surface_data, i + 1, 7, color); + surface->putPixel(i + 1, 5, color); + surface->putPixel(i + 1, 7, color); } // El resto se rellena de color sólido SDL_Rect rect = {0, 8, WIDTH, HEIGHT}; - st.cover_surface->fillRect(surface_data, &rect, color); + surface->fillRect(&rect, color); // Crea el sprite st.cover_sprite = std::make_shared(st.cover_surface, 0, 0, st.cover_surface->getWidth(), st.cover_surface->getHeight() - 8); @@ -215,7 +215,7 @@ void Ending::iniTexts() st.cover_clip_height = HEIGHT; sprite_texts_.push_back(st); - Screen::get()->setRenderSurfaceData(nullptr); + Screen::get()->setRendererSurface(nullptr); } } @@ -248,29 +248,29 @@ void Ending::iniPics() sp.image_sprite->setPosition((options.game.width - WIDTH) / 2, pic.pos); // Crea la cover_surface - sp.cover_surface = std::make_shared(Screen::get()->getRenderSurfaceData(), WIDTH, HEIGHT + 8); - Screen::get()->setRenderSurfaceData(sp.cover_surface); + sp.cover_surface = std::make_shared(Screen::get()->getRendererSurface(), WIDTH, HEIGHT + 8); + Screen::get()->setRendererSurface(sp.cover_surface); // Rellena la cover_surface con color transparente Screen::get()->clearSurface(stringToColor("transparent")); // Crea una malla en los primeros 8 pixels - auto surface_data = *(Screen::get()->getRenderSurfaceData()); + auto surface = Screen::get()->getRendererSurface(); auto color = stringToColor("black"); for (int i = 0; i < WIDTH; i += 2) { - sp.cover_surface->putPixel(surface_data, i, 0, color); - sp.cover_surface->putPixel(surface_data, i, 2, color); - sp.cover_surface->putPixel(surface_data, i, 4, color); - sp.cover_surface->putPixel(surface_data, i, 6, color); + surface->putPixel(i, 0, color); + surface->putPixel(i, 2, color); + surface->putPixel(i, 4, color); + surface->putPixel(i, 6, color); - sp.cover_surface->putPixel(surface_data, i + 1, 5, color); - sp.cover_surface->putPixel(surface_data, i + 1, 7, color); + surface->putPixel(i + 1, 5, color); + surface->putPixel(i + 1, 7, color); } // El resto se rellena de color sólido SDL_Rect rect = {0, 8, WIDTH, HEIGHT}; - sp.cover_surface->fillRect(surface_data, &rect, color); + surface->fillRect(&rect, color); // Crea el sprite sp.cover_sprite = std::make_shared(sp.cover_surface, 0, 0, sp.cover_surface->getWidth(), sp.cover_surface->getHeight() - 8); @@ -282,7 +282,7 @@ void Ending::iniPics() sp.cover_clip_height = HEIGHT; sprite_pics_.push_back(sp); - Screen::get()->setRenderSurfaceData(nullptr); + Screen::get()->setRendererSurface(nullptr); } } @@ -472,29 +472,29 @@ void Ending::checkChangeScene() void Ending::fillCoverTexture() { // Rellena la textura que cubre el texto con color transparente - Screen::get()->setRenderSurfaceData(cover_surface_); + Screen::get()->setRendererSurface(cover_surface_); Screen::get()->clearSurface(stringToColor("transparent")); // Los primeros 8 pixels crea una malla const Uint8 color = stringToColor("black"); - auto surface_data = *(Screen::get()->getRenderSurfaceData()); + auto surface = Screen::get()->getRendererSurface(); for (int i = 0; i < 256; i += 2) { - cover_surface_->putPixel(surface_data, i + 0, options.game.height + 0, color); - cover_surface_->putPixel(surface_data, i + 1, options.game.height + 1, color); - cover_surface_->putPixel(surface_data, i + 0, options.game.height + 2, color); - cover_surface_->putPixel(surface_data, i + 1, options.game.height + 3, color); + surface->putPixel(i + 0, options.game.height + 0, color); + surface->putPixel(i + 1, options.game.height + 1, color); + surface->putPixel(i + 0, options.game.height + 2, color); + surface->putPixel(i + 1, options.game.height + 3, color); - cover_surface_->putPixel(surface_data, i, options.game.height + 4, color); - cover_surface_->putPixel(surface_data, i, options.game.height + 6, color); + surface->putPixel(i, options.game.height + 4, color); + surface->putPixel(i, options.game.height + 6, color); } // El resto se rellena de color sólido SDL_Rect rect = {0, 0, 256, options.game.height}; - cover_surface_->fillRect(surface_data, &rect, color); + surface->fillRect(&rect, color); - Screen::get()->setRenderSurfaceData(nullptr); + Screen::get()->setRendererSurface(nullptr); } // Dibuja la cortinilla de cambio de escena diff --git a/source/ending2.cpp b/source/ending2.cpp index 4ba1b7d..25099b1 100644 --- a/source/ending2.cpp +++ b/source/ending2.cpp @@ -114,25 +114,24 @@ void Ending2::render() // Dibuja una trama arriba y abajo Uint8 color = stringToColor("black"); - auto surface = std::make_shared(Screen::get()->getRenderSurfaceData(), 1, 1); - auto surface_data = *(Screen::get()->getRenderSurfaceData()); + auto surface = Screen::get()->getRendererSurface(); for (int i = 0; i < 256; i += 2) { - surface->putPixel(surface_data, i + 0, 0, color); - surface->putPixel(surface_data, i + 1, 1, color); - surface->putPixel(surface_data, i + 0, 2, color); - surface->putPixel(surface_data, i + 1, 3, color); + surface->putPixel(i + 0, 0, color); + surface->putPixel(i + 1, 1, color); + surface->putPixel(i + 0, 2, color); + surface->putPixel(i + 1, 3, color); - surface->putPixel(surface_data, i, 4, color); - surface->putPixel(surface_data, i, 6, color); + surface->putPixel(i, 4, color); + surface->putPixel(i, 6, color); - surface->putPixel(surface_data, i + 0, 191, color); - surface->putPixel(surface_data, i + 1, 190, color); - surface->putPixel(surface_data, i + 0, 189, color); - surface->putPixel(surface_data, i + 1, 188, color); + surface->putPixel(i + 0, 191, color); + surface->putPixel(i + 1, 190, color); + surface->putPixel(i + 0, 189, color); + surface->putPixel(i + 1, 188, color); - surface->putPixel(surface_data, i, 187, color); - surface->putPixel(surface_data, i, 185, color); + surface->putPixel(i, 187, color); + surface->putPixel(i, 185, color); } // Vuelca el contenido del renderizador en pantalla @@ -424,15 +423,15 @@ void Ending2::createSpriteTexts() const int Y = sprites_.at(i)->getPosY() + sprites_.at(i)->getHeight() + DIST_SPRITE_TEXT_; // Crea la surface - auto surface = std::make_shared(Screen::get()->getRenderSurfaceData(), W, H); - Screen::get()->setRenderSurfaceData(surface); + auto surface = std::make_shared(Screen::get()->getRendererSurface(), W, H); + Screen::get()->setRendererSurface(surface); text->write(0, 0, txt); // Crea el sprite SDL_Rect pos = {X, Y, W, H}; sprite_texts_.emplace_back(std::make_shared(surface, pos)); sprite_texts_.back()->setVelY(SPRITE_DESP_SPEED_); - Screen::get()->setRenderSurfaceData(nullptr); + Screen::get()->setRendererSurface(nullptr); } } @@ -456,15 +455,15 @@ void Ending2::createTexts() const int y = options.game.height + (text->getCharacterSize() * (i * 2)); // Crea la surface - auto surface = std::make_shared(Screen::get()->getRenderSurfaceData(), w, h); - Screen::get()->setRenderSurfaceData(surface); + auto surface = std::make_shared(Screen::get()->getRendererSurface(), w, h); + Screen::get()->setRendererSurface(surface); text->write(0, 0, list[i]); // Crea el sprite SDL_Rect pos = {x + dx, y, w, h}; texts_.emplace_back(std::make_shared(surface, pos)); texts_.back()->setVelY(SPRITE_DESP_SPEED_); - Screen::get()->setRenderSurfaceData(nullptr); + Screen::get()->setRendererSurface(nullptr); } // Crea los últimos textos @@ -485,15 +484,15 @@ void Ending2::createTexts() const int y = START + (text->getCharacterSize() * (i * 2)); // Crea la surface - auto surface = std::make_shared(Screen::get()->getRenderSurfaceData(), w, h); - Screen::get()->setRenderSurfaceData(surface); + auto surface = std::make_shared(Screen::get()->getRendererSurface(), w, h); + Screen::get()->setRendererSurface(surface); text->write(0, 0, list[i]); // Crea el sprite SDL_Rect pos = {x + dx, y, w, h}; texts_.emplace_back(std::make_shared(surface, pos)); texts_.back()->setVelY(SPRITE_DESP_SPEED_); - Screen::get()->setRenderSurfaceData(nullptr); + Screen::get()->setRendererSurface(nullptr); } } diff --git a/source/game.cpp b/source/game.cpp index c1075c7..3074cf9 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -562,7 +562,7 @@ void Game::initStats() void Game::fillRoomNameTexture() { // Pone la textura como destino de renderizado - Screen::get()->setRenderSurfaceData(room_name_surface_); + Screen::get()->setRendererSurface(room_name_surface_); // Rellena la textura de color Screen::get()->clearSurface(stringToColor("white")); @@ -572,7 +572,7 @@ void Game::fillRoomNameTexture() text->writeDX(TEXT_CENTER | TEXT_COLOR, GAMECANVAS_CENTER_X, text->getCharacterSize() / 2, room_->getName(), 1, room_->getBGColor()); // Deja el renderizador por defecto - Screen::get()->setRenderSurfaceData(nullptr); + Screen::get()->setRendererSurface(nullptr); } // Comprueba algunos logros @@ -662,7 +662,7 @@ void Game::initPlayer(const PlayerSpawn &spawn_point, std::shared_ptr room void Game::createRoomNameTexture() { auto text = Resource::get()->getText("smb2"); - room_name_surface_ = std::make_shared(Screen::get()->getRenderSurfaceData(), options.game.width, text->getCharacterSize() * 2); + room_name_surface_ = std::make_shared(Screen::get()->getRendererSurface(), options.game.width, text->getCharacterSize() * 2); // Establece el destino de la textura room_name_rect_ = {0, PLAY_AREA_HEIGHT, options.game.width, text->getCharacterSize() * 2}; diff --git a/source/loading_screen.cpp b/source/loading_screen.cpp index 41412d3..583a0a8 100644 --- a/source/loading_screen.cpp +++ b/source/loading_screen.cpp @@ -22,11 +22,11 @@ LoadingScreen::LoadingScreen() color_loading_screen_surface_(Resource::get()->getSurface("loading_screen_color.gif")), mono_loading_screen_sprite_(std::make_shared(mono_loading_screen_surface_, 0, 0, mono_loading_screen_surface_->getWidth(), mono_loading_screen_surface_->getHeight())), color_loading_screen_sprite_(std::make_shared(color_loading_screen_surface_, 0, 0, color_loading_screen_surface_->getWidth(), color_loading_screen_surface_->getHeight())), - screen_surface_(std::make_shared(Screen::get()->getRenderSurfaceData(), options.game.width, options.game.height)) + screen_surface_(std::make_shared(Screen::get()->getRendererSurface(), options.game.width, options.game.height)) { // Cambia el destino de las surfaces - mono_loading_screen_surface_->setSurfaceDataDestRaw(screen_surface_->getSurfaceData()); - color_loading_screen_surface_->setSurfaceDataDestRaw(screen_surface_->getSurfaceData()); + mono_loading_screen_surface_->setSurfaceDest(screen_surface_); + color_loading_screen_surface_->setSurfaceDest(screen_surface_); // Configura la superficie donde se van a pintar los sprites screen_surface_->setColor(0, 0xFF000000); @@ -156,7 +156,7 @@ void LoadingScreen::renderBorder() const int WIDTH = options.game.width + (options.video.border.width * 2); const int HEIGHT = options.game.height + (options.video.border.height * 2); bool draw_enabled = rand() % 2 == 0 ? true : false; - auto surface_data = *(Screen::get()->getRenderSurfaceData()); + auto surface = Screen::get()->getRendererSurface(); int row = 0; while (row < HEIGHT) @@ -166,7 +166,7 @@ void LoadingScreen::renderBorder() { for (int i = row; i < row + ROW_HEIGHT; ++i) { - screen_surface_->drawLine(surface_data, 0, i, WIDTH, i, color); + surface->drawLine(0, i, WIDTH, i, color); } } row += ROW_HEIGHT; diff --git a/source/notifier.cpp b/source/notifier.cpp index 0907437..b4e2228 100644 --- a/source/notifier.cpp +++ b/source/notifier.cpp @@ -234,27 +234,27 @@ void Notifier::show(std::vector texts, NotificationText text_is, in n.rect = {desp_h, y_pos, width, height}; // Crea la textura - n.surface = std::make_shared(Screen::get()->getRenderSurfaceData(), width, height); + n.surface = std::make_shared(Screen::get()->getRendererSurface(), width, height); // Prepara para dibujar en la textura - Screen::get()->setRenderSurfaceData(n.surface); + Screen::get()->setRendererSurface(n.surface); // Dibuja el fondo de la notificación SDL_Rect rect; - auto surface_data = *(Screen::get()->getRenderSurfaceData()); + auto surface = Screen::get()->getRendererSurface(); if (shape == NotificationShape::ROUNDED) { rect = {4, 0, width - (4 * 2), height}; - n.surface->fillRect(surface_data, &rect, bg_color_); + surface->fillRect(&rect, bg_color_); rect = {4 / 2, 1, width - 4, height - 2}; - n.surface->fillRect(surface_data, &rect, bg_color_); + surface->fillRect(&rect, bg_color_); rect = {1, 4 / 2, width - 2, height - 4}; - n.surface->fillRect(surface_data, &rect, bg_color_); + surface->fillRect(&rect, bg_color_); rect = {0, 4, width, height - (4 * 2)}; - n.surface->fillRect(surface_data, &rect, bg_color_); + surface->fillRect(&rect, bg_color_); } else if (shape == NotificationShape::SQUARED) @@ -288,7 +288,7 @@ void Notifier::show(std::vector texts, NotificationText text_is, in } // Deja de dibujar en la textura - Screen::get()->setRenderSurfaceData(nullptr); + Screen::get()->setRendererSurface(nullptr); // Crea el sprite de la notificación n.sprite = std::make_shared(n.surface, n.rect); diff --git a/source/options.h b/source/options.h index 9fcb9c9..f2edc34 100644 --- a/source/options.h +++ b/source/options.h @@ -212,10 +212,10 @@ struct OptionsStats worst_nightmare("") {} // Constructor - OptionsStats(int rooms, int items, const std::string &worst_nightmare) - : rooms(rooms), - items(items), - worst_nightmare(worst_nightmare) {} + OptionsStats(int r, int i, const std::string wn) + : rooms(r), + items(i), + worst_nightmare(wn) {} }; // Estructura con opciones de la ventana diff --git a/source/resource.cpp b/source/resource.cpp index b44f6cf..d305339 100644 --- a/source/resource.cpp +++ b/source/resource.cpp @@ -247,7 +247,7 @@ void Resource::loadSurfaces() for (const auto &l : list) { auto name = getFileName(l); - surfaces_.emplace_back(ResourceSurface(name, std::make_shared(Screen::get()->getRenderSurfaceData(), l))); + surfaces_.emplace_back(ResourceSurface(name, std::make_shared(Screen::get()->getRendererSurface(), l))); updateLoadingProgress(); } } @@ -407,15 +407,14 @@ void Resource::renderProgress() Screen::get()->start(); Screen::get()->clearSurface(); - auto surface = std::make_shared(Screen::get()->getRenderSurfaceData(), 1, 1); - auto surface_data = *(Screen::get()->getRenderSurfaceData()); + auto surface = Screen::get()->getRendererSurface(); const int wired_bar_width = options.game.width - (X_PADDING * 2); SDL_Rect rect_wired = {X_PADDING, bar_position, wired_bar_width, X_PADDING}; - surface->fillRect(surface_data, &rect_wired, stringToColor("blue")); - + surface->fillRect(&rect_wired, stringToColor("blue")); + const int full_bar_width = wired_bar_width * count_.getPercentage(); SDL_Rect rect_full = {X_PADDING, bar_position, full_bar_width, X_PADDING}; - surface->fillRect(surface_data, &rect_full, stringToColor("white")); + surface->fillRect(&rect_full, stringToColor("white")); Screen::get()->renderWithoutNotifier(); } diff --git a/source/room.cpp b/source/room.cpp index 24069d8..b950451 100644 --- a/source/room.cpp +++ b/source/room.cpp @@ -415,7 +415,7 @@ Room::Room(const std::string &room_path, std::shared_ptr data) setAnimatedTiles(); // Crea la textura para el mapa de tiles de la habitación - map_surface_ = std::make_shared(Screen::get()->getRenderSurfaceData(), PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT); + map_surface_ = std::make_shared(Screen::get()->getRendererSurface(), PLAY_AREA_WIDTH, PLAY_AREA_HEIGHT); // Pinta el mapa de la habitación en la textura fillMapTexture(); @@ -474,7 +474,7 @@ void Room::initializeRoom(const RoomData &room) void Room::fillMapTexture() { const Uint8 color = stringToColor(bg_color_); - Screen::get()->setRenderSurfaceData(map_surface_); + Screen::get()->setRendererSurface(map_surface_); Screen::get()->clearSurface(color); // Los tileSetFiles son de 20x20 tiles. El primer tile es el 0. Cuentan hacia la derecha y hacia abajo @@ -593,7 +593,7 @@ void Room::fillMapTexture() } #endif - Screen::get()->setRenderSurfaceData(nullptr); + Screen::get()->setRendererSurface(nullptr); } // Dibuja el mapa en pantalla diff --git a/source/scoreboard.cpp b/source/scoreboard.cpp index 72210c5..33feaf4 100644 --- a/source/scoreboard.cpp +++ b/source/scoreboard.cpp @@ -27,7 +27,7 @@ Scoreboard::Scoreboard(std::shared_ptr data) player_sprite_ = std::make_shared(player_texture, player_animations); player_sprite_->setCurrentAnimation("walk_menu"); - surface_ = std::make_shared(Screen::get()->getRenderSurfaceData(), SURFACE_WIDTH_, SURFACE_HEIGHT_); + surface_ = std::make_shared(Screen::get()->getRendererSurface(), SURFACE_WIDTH_, SURFACE_HEIGHT_); surface_dest_ = {0, options.game.height - SURFACE_HEIGHT_, SURFACE_WIDTH_, SURFACE_HEIGHT_}; // Inicializa las variables @@ -136,7 +136,7 @@ int Scoreboard::getMinutes() void Scoreboard::fillTexture() { // Empieza a dibujar en la textura - Screen::get()->setRenderSurfaceData(surface_); + Screen::get()->setRendererSurface(surface_); // Limpia la textura Screen::get()->clearSurface(stringToColor("black")); @@ -179,5 +179,5 @@ void Scoreboard::fillTexture() text->writeColored(28 * BLOCK, LINE2, ROOMS_TEXT, stringToColor("white")); // Deja el renderizador como estaba - Screen::get()->setRenderSurfaceData(nullptr); + Screen::get()->setRendererSurface(nullptr); } \ No newline at end of file diff --git a/source/screen.cpp b/source/screen.cpp index 22debec..0965099 100644 --- a/source/screen.cpp +++ b/source/screen.cpp @@ -75,8 +75,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer) } // Crea la surface donde se dibujan los graficos del juego - game_surface_data_ = std::make_shared>(std::make_shared(options.game.width, options.game.height)); - game_surface_ = std::make_shared(game_surface_data_, options.game.width, options.game.height); + game_surface_ = std::make_shared(nullptr, options.game.width, options.game.height); game_surface_->loadPalette(palettes_.front()); // Crea la surface donde se dibujan los graficos del juego @@ -115,7 +114,12 @@ void Screen::clearSurface(Uint8 index) void Screen::start() { SDL_SetRenderTarget(renderer_, game_texture_); - setRenderSurfaceData(nullptr); + setRendererSurface(nullptr); +} + +// Prepara para empezar a dibujar en la textura del borde +void Screen::startDrawOnBorder() +{ } // Vuelca el contenido del renderizador en pantalla @@ -373,9 +377,9 @@ void Screen::resetShaders() } // Establece el renderizador para las surfaces -void Screen::setRenderSurfaceData(std::shared_ptr surface) +void Screen::setRendererSurface(std::shared_ptr surface) { - (surface) ? game_surface_->redirectSurfaceDataTo(surface) : game_surface_->restoreOriginalSurfaceData(); + (surface) ? game_surface_->setSurfaceDest(surface) : game_surface_->setSurfaceDest(nullptr); } // Cambia la paleta diff --git a/source/screen.h b/source/screen.h index b7dc44a..df218bf 100644 --- a/source/screen.h +++ b/source/screen.h @@ -26,13 +26,12 @@ private: static Screen *screen_; // Objetos y punteros - SDL_Window *window_; // Ventana de la aplicación - SDL_Renderer *renderer_; // El renderizador de la ventana - SDL_Texture *game_texture_; // Textura donde se dibuja el juego - SDL_Texture *border_texture_; // Textura donde se dibuja el borde del juego - std::shared_ptr> game_surface_data_; // SurfaceData principal donde van a dibujar el resto de Surfaces - std::shared_ptr game_surface_; // Surface principal para manejar game_surface_data_ - std::shared_ptr border_surface_; // Surface para pintar el el borde de la pantalla + SDL_Window *window_; // Ventana de la aplicación + SDL_Renderer *renderer_; // El renderizador de la ventana + SDL_Texture *game_texture_; // Textura donde se dibuja el juego + SDL_Texture *border_texture_; // Textura donde se dibuja el borde del juego + std::shared_ptr game_surface_; // Surface principal para manejar game_surface_data_ + std::shared_ptr border_surface_; // Surface para pintar el el borde de la pantalla // Variables int window_width_; // Ancho de la pantalla o ventana @@ -85,6 +84,7 @@ public: // Prepara para empezar a dibujar en la textura de juego void start(); + void startDrawOnBorder(); // Vuelca el contenido del renderizador en pantalla void render(); @@ -134,14 +134,11 @@ public: int getMaxZoom(); // Establece el renderizador para las surfaces - void setRenderSurfaceData(std::shared_ptr surface = nullptr); + void setRendererSurface(std::shared_ptr surface = nullptr); // Getters SDL_Renderer *getRenderer() { return renderer_; } - std::shared_ptr> getRenderSurfaceData() { return std::make_shared>(game_surface_->getSurfaceData()); } - - // Prepara para empezar a dibujar en la textura del borde - void startDrawOnBorder() { setRenderSurfaceData(border_surface_); } + std::shared_ptr getRendererSurface() { return game_surface_; } // Cambia la paleta void nextPalette(); diff --git a/source/surface.cpp b/source/surface.cpp index 89cdc19..b5bcf74 100644 --- a/source/surface.cpp +++ b/source/surface.cpp @@ -11,30 +11,17 @@ #include "gif.h" // for LoadGif, LoadPalette // Constructor -Surface::Surface(std::shared_ptr> surface_dest, int w, int h) - : surface_data_dest_(surface_dest), +Surface::Surface(std::shared_ptr surface_dest, int w, int h) + : surface_dest_(surface_dest), surface_data_(std::make_shared(w, h)), - original_surface_data_(surface_data_), - transparent_color_(0) -{ - if (!surface_data_dest_) - { - surface_data_dest_ = std::make_shared>(surface_data_); - } -} + transparent_color_(0){} -Surface::Surface(std::shared_ptr> surface_dest, const std::string &file_path) - : surface_data_dest_(surface_dest), +Surface::Surface(std::shared_ptr surface_dest, const std::string &file_path) + : surface_dest_(surface_dest), transparent_color_(0) { SurfaceData loadedData = loadSurface(file_path); surface_data_ = std::make_shared(std::move(loadedData)); - original_surface_data_ = surface_data_; - - if (!surface_data_dest_) - { - surface_data_dest_ = std::make_shared>(surface_data_); - } } // Carga una superficie desde un archivo @@ -117,48 +104,45 @@ void Surface::clear(Uint8 color) } // Pone un pixel en la SurfaceData -void Surface::putPixel(std::shared_ptr surface_data, int x, int y, Uint8 color) +void Surface::putPixel(int x, int y, Uint8 color) { - if (x < 0 || y < 0 || x >= surface_data->width || y >= surface_data->height) + if (x < 0 || y < 0 || x >= surface_data_->width || y >= surface_data_->height) { return; // Coordenadas fuera de rango } - const int index = x + y * surface_data->width; - surface_data->data[index] = color; + const int index = x + y * surface_data_->width; + surface_data_->data[index] = color; } -// Obtiene el color de un pixel de la superficie de origen +// Obtiene el color de un pixel de la surface_data Uint8 Surface::getPixel(int x, int y) { return surface_data_->data[x + y * surface_data_->width]; } // Dibuja un rectangulo -void Surface::fillRect(std::shared_ptr surface_data, SDL_Rect *rect, Uint8 color) +void Surface::fillRect(SDL_Rect *rect, Uint8 color) { - if (!rect) - return; // Verificar si el rectángulo es válido - // Limitar los valores del rectángulo al tamaño de la superficie int x_start = std::max(0, rect->x); int y_start = std::max(0, rect->y); - int x_end = std::min(rect->x + rect->w, static_cast(surface_data->width)); - int y_end = std::min(rect->y + rect->h, static_cast(surface_data->height)); + int x_end = std::min(rect->x + rect->w, static_cast(surface_data_->width)); + int y_end = std::min(rect->y + rect->h, static_cast(surface_data_->height)); // Recorrer cada píxel dentro del rectángulo directamente for (int y = y_start; y < y_end; ++y) { for (int x = x_start; x < x_end; ++x) { - const int index = x + y * surface_data->width; - surface_data->data[index] = color; + const int index = x + y * surface_data_->width; + surface_data_->data[index] = color; } } } // Dibuja una linea -void Surface::drawLine(std::shared_ptr surface_data, int x1, int y1, int x2, int y2, Uint8 color) +void Surface::drawLine(int x1, int y1, int x2, int y2, Uint8 color) { // Calcula las diferencias int dx = std::abs(x2 - x1); @@ -173,9 +157,9 @@ void Surface::drawLine(std::shared_ptr surface_data, int x1, int y1 while (true) { // Asegúrate de no dibujar fuera de los límites de la superficie - if (x1 >= 0 && x1 < surface_data->width && y1 >= 0 && y1 < surface_data->height) + if (x1 >= 0 && x1 < surface_data_->width && y1 >= 0 && y1 < surface_data_->height) { - surface_data->data[x1 + y1 * surface_data->width] = color; + surface_data_->data[x1 + y1 * surface_data_->width] = color; } // Si alcanzamos el punto final, salimos @@ -199,17 +183,13 @@ void Surface::drawLine(std::shared_ptr surface_data, int x1, int y1 // Copia una región de la superficie de origen a la de destino void Surface::render(int dx, int dy, int sx, int sy, int w, int h) { - if (!surface_data_ || !surface_data_dest_ || !*surface_data_dest_) { - throw std::runtime_error("Surface source or destination is null."); - } - - auto &dest = **surface_data_dest_; + auto surface_data = surface_dest_->getSurfaceData(); // Limitar la región para evitar accesos fuera de rango w = std::min(w, surface_data_->width - sx); h = std::min(h, surface_data_->height - sy); - w = std::min(w, dest.width - dx); - h = std::min(h, dest.height - dy); + w = std::min(w, surface_data->width - dx); + h = std::min(h, surface_data->height - dy); for (int iy = 0; iy < h; ++iy) { @@ -218,7 +198,7 @@ void Surface::render(int dx, int dy, int sx, int sy, int w, int h) Uint8 color = surface_data_->data[(sx + ix) + (sy + iy) * surface_data_->width]; if (color != transparent_color_) { - dest.data[(dx + ix) + (dy + iy) * dest.width] = color; + surface_data->data[(dx + ix) + (dy + iy) * surface_data->width] = color; } } } @@ -227,12 +207,8 @@ void Surface::render(int dx, int dy, int sx, int sy, int w, int h) // Copia una región de la superficie de origen a la de destino void Surface::render(int x, int y, SDL_Rect *srcRect, SDL_RendererFlip flip) { - if (!surface_data_ || !surface_data_dest_ || !*surface_data_dest_) { - throw std::runtime_error("Surface source or destination is null."); - } - - auto &dest = **surface_data_dest_; - + auto surface_data = surface_dest_->getSurfaceData(); + // Determina la región de origen (clip) a renderizar int sx = (srcRect) ? srcRect->x : 0; int sy = (srcRect) ? srcRect->y : 0; @@ -242,8 +218,8 @@ void Surface::render(int x, int y, SDL_Rect *srcRect, SDL_RendererFlip flip) // Limitar la región para evitar accesos fuera de rango w = std::min(w, surface_data_->width - sx); h = std::min(h, surface_data_->height - sy); - w = std::min(w, dest.width - x); - h = std::min(h, dest.height - y); + w = std::min(w, surface_data->width - x); + h = std::min(h, surface_data->height - y); // Renderiza píxel por píxel aplicando el flip si es necesario for (int iy = 0; iy < h; ++iy) @@ -262,7 +238,7 @@ void Surface::render(int x, int y, SDL_Rect *srcRect, SDL_RendererFlip flip) Uint8 color = surface_data_->data[src_x + src_y * surface_data_->width]; if (color != transparent_color_) { - dest.data[dest_x + dest_y * dest.width] = color; + surface_data->data[dest_x + dest_y * surface_data->width] = color; } } } @@ -271,11 +247,7 @@ void Surface::render(int x, int y, SDL_Rect *srcRect, SDL_RendererFlip flip) // Copia una región de la superficie de origen a la de destino void Surface::render(SDL_Rect *srcRect, SDL_Rect *dstRect, SDL_RendererFlip flip) { - if (!surface_data_ || !surface_data_dest_ || !*surface_data_dest_) { - throw std::runtime_error("Surface source or destination is null."); - } - - auto &dest = **surface_data_dest_; + auto surface_data = surface_dest_->getSurfaceData(); // Si srcRect es nullptr, tomar toda la superficie fuente int sx = (srcRect) ? srcRect->x : 0; @@ -299,8 +271,8 @@ void Surface::render(SDL_Rect *srcRect, SDL_Rect *dstRect, SDL_RendererFlip flip // Limitar la región para evitar accesos fuera de rango en src y dst sw = std::min(sw, surface_data_->width - sx); sh = std::min(sh, surface_data_->height - sy); - dw = std::min(dw, dest.width - dx); - dh = std::min(dh, dest.height - dy); + dw = std::min(dw, surface_data->width - dx); + dh = std::min(dh, surface_data->height - dy); int final_width = std::min(sw, dw); int final_height = std::min(sh, dh); @@ -322,7 +294,7 @@ void Surface::render(SDL_Rect *srcRect, SDL_Rect *dstRect, SDL_RendererFlip flip Uint8 color = surface_data_->data[src_x + src_y * surface_data_->width]; if (color != transparent_color_) { - dest.data[dest_x + dest_y * dest.width] = color; + surface_data->data[dest_x + dest_y * surface_data->width] = color; } } } @@ -331,11 +303,7 @@ void Surface::render(SDL_Rect *srcRect, SDL_Rect *dstRect, SDL_RendererFlip flip // Copia una región de la SurfaceData de origen a la SurfaceData de destino reemplazando un color por otro void Surface::renderWithColorReplace(int x, int y, Uint8 source_color, Uint8 target_color, SDL_Rect *srcRect, SDL_RendererFlip flip) { - if (!surface_data_ || !surface_data_dest_ || !*surface_data_dest_) { - throw std::runtime_error("Surface source or destination is null."); - } - - auto &dest = **surface_data_dest_; + auto surface_data = surface_dest_->getSurfaceData(); // Determina la región de origen (clip) a renderizar int sx = (srcRect) ? srcRect->x : 0; @@ -361,7 +329,7 @@ void Surface::renderWithColorReplace(int x, int y, Uint8 source_color, Uint8 tar int dest_y = y + iy; // Verifica que las coordenadas de destino estén dentro de los límites - if (dest_x < 0 || dest_y < 0 || dest_x >= dest.width || dest_y >= dest.height) + if (dest_x < 0 || dest_y < 0 || dest_x >= surface_data->width || dest_y >= surface_data->height) { continue; // Saltar píxeles fuera del rango del destino } @@ -370,7 +338,7 @@ void Surface::renderWithColorReplace(int x, int y, Uint8 source_color, Uint8 tar Uint8 color = surface_data_->data[src_x + src_y * surface_data_->width]; if (color != transparent_color_) { - dest.data[dest_x + dest_y * dest.width] = + surface_data->data[dest_x + dest_y * surface_data->width] = (color == source_color) ? target_color : color; } } @@ -444,27 +412,4 @@ bool Surface::fadePalette() // Devolver si el índice 15 coincide con el índice 0 return palette_[15] == palette_[0]; -} - -// Permite que una Surface apunte al SurfaceData de otra Surface -void Surface::redirectSurfaceDataTo(const std::shared_ptr &newSurfaceData) -{ - if (surface_data_dest_) - { - *surface_data_dest_ = newSurfaceData; - } -} - -void Surface::redirectSurfaceDataTo(const std::shared_ptr &otherSurface) -{ - redirectSurfaceDataTo(otherSurface->getSurfaceData()); -} - -// Método para restaurar -void Surface::restoreOriginalSurfaceData() -{ - if (surface_data_dest_) - { - *surface_data_dest_ = original_surface_data_; - } } \ No newline at end of file diff --git a/source/surface.h b/source/surface.h index 2ce3f97..79e4bd4 100644 --- a/source/surface.h +++ b/source/surface.h @@ -60,16 +60,15 @@ struct SurfaceData class Surface { private: - std::shared_ptr> surface_data_dest_; // Puntero a la SurfaceData remota donde copiar la información - std::shared_ptr surface_data_; // SurfaceData propia - std::shared_ptr original_surface_data_; // SurfaceData original para restauración - std::array palette_; // Paleta para volcar la SurfaceData a una Textura - int transparent_color_; // Indice de la paleta que se omite en la copia de datos + std::shared_ptr surface_dest_; // Surface remota donde dibujar la surface_data_ + std::shared_ptr surface_data_; // Datos a dibujar + std::array palette_; // Paleta para volcar la SurfaceData a una Textura + int transparent_color_; // Indice de la paleta que se omite en la copia de datos public: // Constructor - Surface(std::shared_ptr> surface_dest, int w, int h); - Surface(std::shared_ptr> surface_dest, const std::string &file_path); + Surface(std::shared_ptr surface_dest, int w, int h); + Surface(std::shared_ptr surface_dest, const std::string &file_path); // Destructor ~Surface() = default; @@ -101,34 +100,33 @@ public: bool fadePalette(); // Pone un pixel en la SurfaceData - void putPixel(std::shared_ptr surface_data, int x, int y, Uint8 color); + void putPixel(int x, int y, Uint8 color); - // Obtiene el color de un pixel de la superficie de origen + // Obtiene el color de un pixel de la surface_data Uint8 getPixel(int x, int y); // Dibuja un rectangulo - void fillRect(std::shared_ptr surface_data, SDL_Rect *rect, Uint8 color); + void fillRect(SDL_Rect *rect, Uint8 color); // Dibuja una linea - void drawLine(std::shared_ptr surface_data, int x1, int y1, int x2, int y2, Uint8 color); + void drawLine(int x1, int y1, int x2, int y2, Uint8 color); - // Getters + // Métodos para gestionar surface_dest_ + std::shared_ptr getSurfaceDest() const { return surface_dest_; } + void setSurfaceDest(std::shared_ptr new_surface_dest) { surface_dest_ = new_surface_dest; } + + // Metodos para gestionar surface_data_ std::shared_ptr getSurfaceData() const { return surface_data_; } - int getTransparentColor() const { return transparent_color_; } + void setSurfaceData(std::shared_ptr new_data) { surface_data_ = new_data; } + + // Obtien ancho y alto int getWidth() const { return surface_data_->width; } int getHeight() const { return surface_data_->height; } - - // Setters + + // Color transparente + int getTransparentColor() const { return transparent_color_; } void setTransparentColor(int color) { transparent_color_ = color; } - void setSurfaceDataDest(std::shared_ptr> surface_data_dest) { surface_data_dest_ = surface_data_dest; } - void setSurfaceDataDestRaw(std::shared_ptr surface_data_dest) { surface_data_dest_ = std::make_shared>(surface_data_dest); } + + // Paleta void setPalette(const std::array &palette) { palette_ = palette; } - void setSurface(std::shared_ptr surface) { surface_data_ = surface; } - - // Permite que una Surface apunte al SurfaceData de otra Surface - void redirectSurfaceDataTo(const std::shared_ptr &newSurfaceData); - void redirectSurfaceDataTo(const std::shared_ptr &otherSurface); - - // Método para restaurar - void restoreOriginalSurfaceData(); }; diff --git a/source/text.cpp b/source/text.cpp index a744f5b..62af92a 100644 --- a/source/text.cpp +++ b/source/text.cpp @@ -146,11 +146,11 @@ std::shared_ptr Text::writeToSurface(const std::string &text, int zoom, { auto width = lenght(text, kerning) * zoom; auto height = box_height_ * zoom; - auto surface = std::make_shared(Screen::get()->getRenderSurfaceData(), width, height); - Screen::get()->setRenderSurfaceData(surface); + auto surface = std::make_shared(Screen::get()->getRendererSurface(), width, height); + Screen::get()->setRendererSurface(surface); Screen::get()->clearSurface(stringToColor("transparent")); write(0, 0, text, kerning); - Screen::get()->setRenderSurfaceData(nullptr); + Screen::get()->setRendererSurface(nullptr); return surface; } @@ -160,11 +160,11 @@ std::shared_ptr Text::writeDXToSurface(Uint8 flags, const std::string & { auto width = Text::lenght(text, kerning) + shadow_distance; auto height = box_height_ + shadow_distance; - auto surface = std::make_shared(Screen::get()->getRenderSurfaceData(), width, height); - Screen::get()->setRenderSurfaceData(surface); + auto surface = std::make_shared(Screen::get()->getRendererSurface(), width, height); + Screen::get()->setRendererSurface(surface); Screen::get()->clearSurface(stringToColor("transparent")); writeDX(flags, 0, 0, text, kerning, textColor, shadow_distance, shadow_color, lenght); - Screen::get()->setRenderSurfaceData(nullptr); + Screen::get()->setRendererSurface(nullptr); return surface; } diff --git a/source/title.cpp b/source/title.cpp index 34858bf..c6c61f2 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -25,7 +25,7 @@ Title::Title() : title_logo_surface_(Resource::get()->getSurface("title_logo.gif")), title_logo_sprite_(std::make_shared(title_logo_surface_, 0, 0, title_logo_surface_->getWidth(), title_logo_surface_->getHeight())), - bg_surface_(std::make_shared(Screen::get()->getRenderSurfaceData(), options.game.width, options.game.height)) + bg_surface_(std::make_shared(Screen::get()->getRendererSurface(), options.game.width, options.game.height)) { // Carga la surface con los gráficos de la pantalla de carga pInit(Screen::get()->getRenderer(), 256, 128); @@ -33,7 +33,7 @@ Title::Title() pLoadPal(Asset::get()->get("loading_screen_color.gif").c_str()); pSetSource(loading_screen_); - //title_logo_surface_->setSurfaceDataDestRaw(bg_surface_->getSurfaceData()); + // title_logo_surface_->setSurfaceDataDestRaw(bg_surface_->getSurfaceData()); // Inicializa variables state_ = options.section.subsection == Subsection::TITLE_WITH_LOADING_SCREEN ? TitleState::SHOW_LOADING_SCREEN : TitleState::SHOW_MENU; @@ -313,7 +313,7 @@ void Title::moveCheevosList(int direction) void Title::fillSurface() { // Coloca el puntero del renderizador sobre la textura - Screen::get()->setRenderSurfaceData(bg_surface_); + Screen::get()->setRendererSurface(bg_surface_); // Rellena la textura de color Screen::get()->clearSurface(4); @@ -332,7 +332,7 @@ void Title::fillSurface() text->writeColored(PLAY_AREA_CENTER_X, 30 * TEXT_SIZE, "ESC.EXIT GAME", COLOR); // Devuelve el puntero del renderizador a su sitio - Screen::get()->setRenderSurfaceData(nullptr); + Screen::get()->setRendererSurface(nullptr); } // Crea y rellena la textura para mostrar los logros @@ -347,10 +347,10 @@ void Title::createCheevosTexture() constexpr int CHEEVOS_PADDING = 10; const int CHEEVO_HEIGHT = CHEEVOS_PADDING + (TEXT->getCharacterSize() * 2) + 1; const int CHEEVOS_TEXTURE_HEIGHT = (CHEEVO_HEIGHT * CHEEVOS_LIST.size()) + 2 + TEXT->getCharacterSize() + 8; - cheevos_surface_ = std::make_shared(Screen::get()->getRenderSurfaceData(), CHEEVOS_TEXTURE_WIDTH, CHEEVOS_TEXTURE_HEIGHT); + cheevos_surface_ = std::make_shared(Screen::get()->getRendererSurface(), CHEEVOS_TEXTURE_WIDTH, CHEEVOS_TEXTURE_HEIGHT); // Prepara para dibujar sobre la textura - Screen::get()->setRenderSurfaceData(cheevos_surface_); + Screen::get()->setRendererSurface(cheevos_surface_); // Rellena la textura con color sólido const Uint8 CHEEVOS_BG_COLOR = stringToColor("black"); @@ -373,8 +373,8 @@ void Title::createCheevosTexture() cheevoColor = cheevo.completed ? CHEEVO_UNLOCKED_COLOR : CHEEVO_LOCKED_COLOR; pos += CHEEVOS_PADDING; constexpr int HALF = CHEEVOS_PADDING / 2; - auto surface_data = *(Screen::get()->getRenderSurfaceData()); - cheevos_surface_->drawLine(surface_data, LINE_X1, pos - HALF - 1, LINE_X2, pos - HALF - 1, cheevoColor); + auto surface = Screen::get()->getRendererSurface(); + surface->drawLine(LINE_X1, pos - HALF - 1, LINE_X2, pos - HALF - 1, cheevoColor); TEXT->writeDX(TEXT_CENTER | TEXT_COLOR, CHEEVOS_TEXTURE_WIDTH / 2, pos, cheevo.caption, 1, cheevoColor); pos += TEXT->getCharacterSize() + 1; TEXT->writeDX(TEXT_CENTER | TEXT_COLOR, CHEEVOS_TEXTURE_WIDTH / 2, pos, cheevo.description, 1, cheevoColor); @@ -382,7 +382,7 @@ void Title::createCheevosTexture() } // Restablece el RenderSurface - Screen::get()->setRenderSurfaceData(nullptr); + Screen::get()->setRendererSurface(nullptr); // Crea el sprite para el listado de logros cheevos_sprite_ = std::make_shared(cheevos_surface_, (GAMECANVAS_WIDTH - cheevos_surface_->getWidth()) / 2, CHEEVOS_TEXTURE_POS_Y, cheevos_surface_->getWidth(), cheevos_surface_->getHeight());