From b60bbf3739266426d7fa4b57c1d807601b39d32c Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Wed, 15 Mar 2017 21:58:24 +0000 Subject: [PATCH] Add background layer from IngameScene, not the base class. --- src/gamelib/gamescenebase.cpp | 4 ---- src/gamelib/ingamescene.cpp | 14 ++++++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/gamelib/gamescenebase.cpp b/src/gamelib/gamescenebase.cpp index aa977e5..7d01b2a 100644 --- a/src/gamelib/gamescenebase.cpp +++ b/src/gamelib/gamescenebase.cpp @@ -22,7 +22,6 @@ #include "sdlmain.hpp" #include "rect.hpp" #include "drawing_queue.hpp" -#include "draw_layer_names.hpp" #include #include #include @@ -79,9 +78,6 @@ namespace curry { m_wants_to_quit(false) { assert(m_sdlmain); - const bool layer_added = m_drawing_queue->add_layer(DrawaLayerNames::Background); - assert(layer_added); - static_cast(layer_added); } GameSceneBase::~GameSceneBase() noexcept = default; diff --git a/src/gamelib/ingamescene.cpp b/src/gamelib/ingamescene.cpp index 1ea5d93..e6de36d 100644 --- a/src/gamelib/ingamescene.cpp +++ b/src/gamelib/ingamescene.cpp @@ -45,6 +45,11 @@ namespace curry { namespace { + void add_layer_assert_done (DrawingQueue& parDQ, DrawaLayerNames parName) { + const bool layer_added = parDQ.add_layer(parName); + assert(layer_added); + static_cast(layer_added); + } } //unnamed namespace struct IngameScene::LocalData { @@ -62,9 +67,6 @@ namespace curry { MovingObject player; Character character; WorldItems moveable_items; -#if !defined(NDEBUG) - std::size_t debug_layer_id; -#endif }; IngameScene::IngameScene (cloonel::SDLMain* parSDLMain) : @@ -79,10 +81,10 @@ namespace curry { inp.AddAction(ActionUp, Key(InputDevice_Keyboard, SDL_SCANCODE_UP), "Move up"); inp.AddAction(ActionRight, Key(InputDevice_Keyboard, SDL_SCANCODE_RIGHT), "Move right"); inp.AddAction(ActionDown, Key(InputDevice_Keyboard, SDL_SCANCODE_DOWN), "Move down"); + + add_layer_assert_done(drawing_queue(), DrawaLayerNames::Background); #if !defined(NDEBUG) - const bool layer_added = drawing_queue().add_layer(DrawaLayerNames::Debug); - assert(layer_added); - static_cast(layer_added); + add_layer_assert_done(drawing_queue(), DrawaLayerNames::Debug); #endif }