Mario: Add restart and background color for menus
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
zv0n 2022-09-22 20:16:46 +02:00
parent 8b9ef16929
commit a1afaf427a
10 changed files with 95 additions and 41 deletions

View File

@ -11,3 +11,4 @@ std::shared_ptr<SDLPP::Texture> g_translucent_enemies_texture;
std::shared_ptr<SDLPP::Scene> g_playground{}; std::shared_ptr<SDLPP::Scene> g_playground{};
std::shared_ptr<SDLPP::FontConfiguration> g_text_config{}; std::shared_ptr<SDLPP::FontConfiguration> g_text_config{};
bool g_quit = false; bool g_quit = false;
bool g_death = false;

View File

@ -13,5 +13,6 @@ extern std::shared_ptr<SDLPP::Texture> g_translucent_enemies_texture;
extern std::shared_ptr<SDLPP::Scene> g_playground; extern std::shared_ptr<SDLPP::Scene> g_playground;
extern std::shared_ptr<SDLPP::FontConfiguration> g_text_config; extern std::shared_ptr<SDLPP::FontConfiguration> g_text_config;
extern bool g_quit; extern bool g_quit;
extern bool g_death;
#endif #endif

View File

@ -24,6 +24,7 @@
#include "scenes/game_scenes.hpp" #include "scenes/game_scenes.hpp"
bool update = false; bool update = false;
int update_count = 0;
bool newLoaded = false; bool newLoaded = false;
std::shared_ptr<Mario> mario = nullptr; std::shared_ptr<Mario> mario = nullptr;
std::shared_ptr<SDLPP::RectangleRender> leftStop = nullptr; std::shared_ptr<SDLPP::RectangleRender> leftStop = nullptr;
@ -32,6 +33,7 @@ std::shared_ptr<SDLPP::TextRenderer> fps = nullptr;
std::shared_ptr<SDLPP::TextRenderer> coins = nullptr; std::shared_ptr<SDLPP::TextRenderer> coins = nullptr;
int coin_count = 0; int coin_count = 0;
int global_frames = 0; int global_frames = 0;
std::string last_load_level = "";
std::vector<std::shared_ptr<MarioBlock>> moving_objects = {}; std::vector<std::shared_ptr<MarioBlock>> moving_objects = {};
std::vector<SceneStruct> game_scenes{}; std::vector<SceneStruct> game_scenes{};
@ -71,7 +73,7 @@ void handleKeyUp(SDL_Keycode key) {
case SDLK_ESCAPE: case SDLK_ESCAPE:
{ {
std::lock_guard<std::mutex> lock(render_mutex); std::lock_guard<std::mutex> lock(render_mutex);
game_scenes.push_back(createGameMainMenuScene(renderer)); game_scenes.push_back(createGameMainMenuScene(renderer, false, true, true));
} }
break; break;
case SDLK_a: case SDLK_a:
@ -136,6 +138,7 @@ void pollEvents(SDLPP::Scene &scene) {
scene.updateSizeAndPosition(); scene.updateSizeAndPosition();
moveToMarioPosition(scene, prev_mario_pos); moveToMarioPosition(scene, prev_mario_pos);
update = true; update = true;
update_count = 2;
} }
default: default:
break; break;
@ -144,6 +147,18 @@ void pollEvents(SDLPP::Scene &scene) {
} }
void doInputMainGame(std::shared_ptr<SDLPP::Scene> scene) { void doInputMainGame(std::shared_ptr<SDLPP::Scene> scene) {
if(newLoaded) {
auto prev_mario_pos = mario->getAbsolutePos();
scene->updateSizeAndPosition();
moveToMarioPosition(*scene, prev_mario_pos);
update = true;
update_count = 2;
newLoaded = false;
}
if(g_death) {
game_scenes.push_back(createGameMainMenuScene(renderer, true, false, true));
g_death = false;
}
pollEvents(*scene); pollEvents(*scene);
std::lock_guard<std::mutex> lock(render_mutex); std::lock_guard<std::mutex> lock(render_mutex);
scene->updateScene(); scene->updateScene();
@ -154,7 +169,7 @@ void doInputMainGame(std::shared_ptr<SDLPP::Scene> scene) {
if (!moving_objects[i]->wasVisible()) { if (!moving_objects[i]->wasVisible()) {
continue; continue;
} }
auto visitor = getVisitor(*moving_objects[i], *scene, g_quit, auto visitor = getVisitor(*moving_objects[i], *scene, g_death,
coin_count, moving_objects); coin_count, moving_objects);
scene->visitCollisions(*moving_objects[i], *visitor); scene->visitCollisions(*moving_objects[i], *visitor);
moving_objects[i]->handleVisitor(*visitor); moving_objects[i]->handleVisitor(*visitor);
@ -178,6 +193,8 @@ void doInputMainGame(std::shared_ptr<SDLPP::Scene> scene) {
if (coin_count != prev_coin_count) { if (coin_count != prev_coin_count) {
coins->changeText(std::to_string(coin_count) + " COINS"); coins->changeText(std::to_string(coin_count) + " COINS");
update = true;
update_count = 2;
} }
// if player is > 0.7 of playground, move everything left // if player is > 0.7 of playground, move everything left
auto playerX = mario->getRect().x; auto playerX = mario->getRect().x;
@ -230,6 +247,7 @@ SceneStruct mainGameScene(const std::string &level_path) {
bg->setId(1); bg->setId(1);
scene->addObject(bg); scene->addObject(bg);
mario.reset();
mario = std::make_shared<Mario>(renderer); mario = std::make_shared<Mario>(renderer);
scene->addObject(mario); scene->addObject(mario);
@ -311,11 +329,23 @@ void loadLevel(const std::string &level) {
//std::lock_guard<std::mutex> lock(render_mutex); //std::lock_guard<std::mutex> lock(render_mutex);
coin_count = 0; coin_count = 0;
std::lock_guard<std::mutex> lock(gamescene_mutex); std::lock_guard<std::mutex> lock(gamescene_mutex);
for(auto &scene : game_scenes) {
scene.scene->resetScene();
}
game_scenes.clear(); game_scenes.clear();
game_scenes.push_back(mainGameScene("levels/" + level)); game_scenes.push_back(mainGameScene("levels/" + level));
game_scenes.back().scene->updateSizeAndPosition(); game_scenes.back().scene->updateSizeAndPosition();
update = true; update = true;
newLoaded = true; newLoaded = true;
update_count = 2;
last_load_level = level;
g_death = false;
}
void loadLastLevel() {
if(last_load_level != "") {
loadLevel(last_load_level);
}
} }
#ifdef _WIN32 #ifdef _WIN32
@ -350,15 +380,10 @@ int main() {
auto font = std::make_shared<SDLPP::Font>("testfont.ttf", 36); auto font = std::make_shared<SDLPP::Font>("testfont.ttf", 36);
g_text_config = std::make_shared<SDLPP::FontConfiguration>(font, "#FFFFFF", g_text_config = std::make_shared<SDLPP::FontConfiguration>(font, "#FFFFFF",
"#000000", 0.15); "#000000", 0.15);
game_scenes.push_back(createGameMainMenuScene(renderer, false)); game_scenes.push_back(createGameMainMenuScene(renderer, false, false, false));
std::thread inputThread(doInput); std::thread inputThread(doInput);
SDL_PumpEvents(); SDL_PumpEvents();
// TODO main menu
/* game_scenes.push_back(mainGameScene("levels/test.marmap"));
game_scenes.back().scene->updateSizeAndPosition();
game_scenes.back().scene->renderScene();
renderer->presentRenderer();*/
game_scenes.back().scene->updateSizeAndPosition(); game_scenes.back().scene->updateSizeAndPosition();
game_scenes.back().scene->renderScene(); game_scenes.back().scene->renderScene();
renderer->presentRenderer(); renderer->presentRenderer();
@ -368,12 +393,12 @@ int main() {
SDL_framerateDelay(&gFPS); SDL_framerateDelay(&gFPS);
SDL_PumpEvents(); SDL_PumpEvents();
std::lock_guard<std::mutex> lock(render_mutex); std::lock_guard<std::mutex> lock(render_mutex);
if (update || newLoaded) { if (update) {
for(auto &scene : game_scenes) { for(auto &scene : game_scenes) {
scene.scene->updateSizeAndPosition(); scene.scene->updateSizeAndPosition();
} }
if(newLoaded) { if(update_count > 0) {
newLoaded = false; update_count--;
} else { } else {
update = false; update = false;
} }

View File

@ -5,16 +5,20 @@
#include "../objectids.hpp" #include "../objectids.hpp"
#include "../editor_visitor.hpp" #include "../editor_visitor.hpp"
#include <functional> #include <functional>
#include "../sprites.hpp"
bool __update_scenes_main_menu = false; bool __update_scenes_main_menu = false;
bool __quit_scenes_main_menu = false; bool __quit_scenes_main_menu = false;
bool __restart_scenes_main_menu = false;
bool __started_main_menu = false; bool __started_main_menu = false;
bool __include_resume = false;
uint64_t __cur_button_index_main_menu = -1; uint64_t __cur_button_index_main_menu = -1;
uint64_t __cur_button_index_main_menu_down = -1; uint64_t __cur_button_index_main_menu_down = -1;
std::vector<std::shared_ptr<Button>> __buttons_main_menu{}; std::vector<std::shared_ptr<Button>> __buttons_main_menu{};
std::shared_ptr<SDLPP::RectangleRender> __mouse_main_menu{}; std::shared_ptr<SDLPP::RectangleRender> __mouse_main_menu{};
extern void loadLevel(const std::string &level); extern void loadLevel(const std::string &level);
extern void loadLastLevel();
void quitMainMenu() { void quitMainMenu() {
g_quit = true; g_quit = true;
@ -24,6 +28,11 @@ void resumeMainMenu() {
__quit_scenes_main_menu = true; __quit_scenes_main_menu = true;
} }
void restartMainMenu() {
__quit_scenes_main_menu = true;
__restart_scenes_main_menu = true;
}
void quitMainMenuCallback(void * /*UNUSED*/, Button * /*UNUSED*/) { void quitMainMenuCallback(void * /*UNUSED*/, Button * /*UNUSED*/) {
quitMainMenu(); quitMainMenu();
} }
@ -32,9 +41,14 @@ void resumeMainMenuCallback(void * /*UNUSED*/, Button * /*UNUSED*/) {
resumeMainMenu(); resumeMainMenu();
} }
void restartMainMenuCallback(void * /*UNUSED*/, Button * /*UNUSED*/) {
restartMainMenu();
}
void resetGlobals() { void resetGlobals() {
__update_scenes_main_menu = false; __update_scenes_main_menu = false;
__quit_scenes_main_menu = false; __quit_scenes_main_menu = false;
__restart_scenes_main_menu = false;
__started_main_menu = false; __started_main_menu = false;
__cur_button_index_main_menu_down = -1; __cur_button_index_main_menu_down = -1;
__mouse_main_menu.reset(); __mouse_main_menu.reset();
@ -42,7 +56,7 @@ void resetGlobals() {
} }
void showLoadMenu(void */*UNUSED*/, Button */*UNUSED*/) { void showLoadMenu(void */*UNUSED*/, Button */*UNUSED*/) {
auto loadMenu = createLoadScene(__buttons_main_menu.back()->getRenderer(), "levels", loadLevel, false); auto loadMenu = createLoadScene(__buttons_main_menu.back()->getRenderer(), "levels", loadLevel, false, false);
std::lock_guard<std::mutex> lock(render_mutex); std::lock_guard<std::mutex> lock(render_mutex);
game_scenes.pop_back(); game_scenes.pop_back();
resetGlobals(); resetGlobals();
@ -50,11 +64,10 @@ void showLoadMenu(void */*UNUSED*/, Button */*UNUSED*/) {
} }
void __updateSelectedButton_MainMenu(uint64_t new_index) { void __updateSelectedButton_MainMenu(uint64_t new_index) {
if (new_index != __cur_button_index_main_menu && if (new_index != (uint64_t)-1) {
new_index != (uint64_t)-1) {
__buttons_main_menu[new_index]->setHighlight(); __buttons_main_menu[new_index]->setHighlight();
if (__cur_button_index_main_menu != (uint64_t)-1) { if (__cur_button_index_main_menu != (uint64_t)-1 && new_index != __cur_button_index_main_menu) {
__buttons_main_menu[__cur_button_index_main_menu] __buttons_main_menu[__cur_button_index_main_menu]
->unsetHighlight(); ->unsetHighlight();
} }
@ -65,7 +78,11 @@ void __updateSelectedButton_MainMenu(uint64_t new_index) {
void handleKeyUpMainMenu(SDL_Keycode key, SDLPP::Scene & /*UNUSED*/) { void handleKeyUpMainMenu(SDL_Keycode key, SDLPP::Scene & /*UNUSED*/) {
switch (key) { switch (key) {
case SDLK_ESCAPE: case SDLK_ESCAPE:
if(__include_resume) {
resumeMainMenu(); resumeMainMenu();
} else {
quitMainMenu();
}
break; break;
case SDLK_DOWN: case SDLK_DOWN:
case SDLK_s: case SDLK_s:
@ -95,10 +112,10 @@ void handleKeyUpMainMenu(SDL_Keycode key, SDLPP::Scene & /*UNUSED*/) {
} }
std::shared_ptr<SDLPP::Scene> std::shared_ptr<SDLPP::Scene>
createSceneMainMenu(std::shared_ptr<SDLPP::Renderer> &renderer, bool include_resume) { createSceneMainMenu(std::shared_ptr<SDLPP::Renderer> &renderer, bool include_restart, bool include_resume, bool transparent_bg) {
auto scene = std::make_shared<SDLPP::Scene>(renderer); auto scene = std::make_shared<SDLPP::Scene>(renderer);
auto bg = std::make_shared<SDLPP::RectangleRender>(0, 0, 10, 10, renderer, auto bg = std::make_shared<SDLPP::RectangleRender>(0, 0, 10, 10, renderer,
"#00000088", true); transparent_bg ? "#00000088" : MARIO_OVERWORLD_COLORKEY, true);
bg->setPermanent(); bg->setPermanent();
bg->setId(1); bg->setId(1);
scene->addObject(bg); scene->addObject(bg);
@ -133,15 +150,24 @@ createSceneMainMenu(std::shared_ptr<SDLPP::Renderer> &renderer, bool include_res
__buttons_main_menu.back()->setPermanent(); __buttons_main_menu.back()->setPermanent();
__buttons_main_menu.back()->setButtonIndex(__buttons_main_menu.size() - 1); __buttons_main_menu.back()->setButtonIndex(__buttons_main_menu.size() - 1);
} }
if(include_restart || include_resume) {
__buttons_main_menu.emplace_back(std::make_shared<Button>( __buttons_main_menu.emplace_back(std::make_shared<Button>(
0.2, 0.4, 0.6, 0.1, renderer, "LOAD", default_button_theme, 0.2, 0.4, 0.6, 0.1, renderer, "RESTART", default_button_theme,
restartMainMenuCallback, nullptr));
__buttons_main_menu.back()->setAlignment(SDLPP::OBJ_CENTER,
SDLPP::OBJ_CENTER);
__buttons_main_menu.back()->setPermanent();
__buttons_main_menu.back()->setButtonIndex(__buttons_main_menu.size() - 1);
}
__buttons_main_menu.emplace_back(std::make_shared<Button>(
0.2, 0.55, 0.6, 0.1, renderer, "LOAD", default_button_theme,
showLoadMenu, nullptr)); showLoadMenu, nullptr));
__buttons_main_menu.back()->setAlignment(SDLPP::OBJ_CENTER, __buttons_main_menu.back()->setAlignment(SDLPP::OBJ_CENTER,
SDLPP::OBJ_CENTER); SDLPP::OBJ_CENTER);
__buttons_main_menu.back()->setPermanent(); __buttons_main_menu.back()->setPermanent();
__buttons_main_menu.back()->setButtonIndex(__buttons_main_menu.size() - 1); __buttons_main_menu.back()->setButtonIndex(__buttons_main_menu.size() - 1);
__buttons_main_menu.emplace_back(std::make_shared<Button>( __buttons_main_menu.emplace_back(std::make_shared<Button>(
0.2, 0.7, 0.6, 0.1, renderer, "QUIT", default_button_theme, 0.2, 0.85, 0.6, 0.1, renderer, "QUIT", default_button_theme,
quitMainMenuCallback, nullptr)); quitMainMenuCallback, nullptr));
__buttons_main_menu.back()->setAlignment(SDLPP::OBJ_CENTER, __buttons_main_menu.back()->setAlignment(SDLPP::OBJ_CENTER,
SDLPP::OBJ_CENTER); SDLPP::OBJ_CENTER);
@ -166,6 +192,9 @@ void additionalRenderMainMenu(std::shared_ptr<SDLPP::Scene> & /*UNUSED*/) {
} }
if (__quit_scenes_main_menu) { if (__quit_scenes_main_menu) {
game_scenes.pop_back(); game_scenes.pop_back();
if(__restart_scenes_main_menu) {
loadLastLevel();
}
resetGlobals(); resetGlobals();
} }
} }
@ -218,9 +247,10 @@ void pollEventsMainMenu(std::shared_ptr<SDLPP::Scene> &scene) {
} }
SceneStruct SceneStruct
createGameMainMenuScene(std::shared_ptr<SDLPP::Renderer> &renderer, bool include_resume) { createGameMainMenuScene(std::shared_ptr<SDLPP::Renderer> &renderer, bool include_restart, bool include_resume, bool transparent_background) {
__include_resume = include_resume;
SceneStruct ret{}; SceneStruct ret{};
ret.scene = createSceneMainMenu(renderer, include_resume); ret.scene = createSceneMainMenu(renderer, include_restart, include_resume, transparent_background);
ret.additionalRender = additionalRenderMainMenu; ret.additionalRender = additionalRenderMainMenu;
ret.doInput = pollEventsMainMenu; ret.doInput = pollEventsMainMenu;
__update_scenes_main_menu = true; __update_scenes_main_menu = true;

View File

@ -9,7 +9,7 @@
extern std::mutex render_mutex; extern std::mutex render_mutex;
extern std::vector<SceneStruct> game_scenes; extern std::vector<SceneStruct> game_scenes;
SceneStruct createGameMainMenuScene(std::shared_ptr<SDLPP::Renderer> &renderer, bool include_resume = true); SceneStruct createGameMainMenuScene(std::shared_ptr<SDLPP::Renderer> &renderer, bool include_restart = true, bool include_resume = true, bool transparent_background = true);
SceneStruct createGameRetryScene(std::shared_ptr<SDLPP::Renderer> &renderer); SceneStruct createGameRetryScene(std::shared_ptr<SDLPP::Renderer> &renderer);
#endif #endif

View File

@ -8,6 +8,7 @@
#include "../objectids.hpp" #include "../objectids.hpp"
#include "../editor_visitor.hpp" #include "../editor_visitor.hpp"
#include "../filesystem.hpp" #include "../filesystem.hpp"
#include "../sprites.hpp"
bool __update_scenes_load_dialog = false; bool __update_scenes_load_dialog = false;
bool __quit_scenes_load_dialog = false; bool __quit_scenes_load_dialog = false;
@ -123,10 +124,10 @@ void addLevelButton(const std::string &path, const std::string &file,
std::shared_ptr<SDLPP::Scene> std::shared_ptr<SDLPP::Scene>
createSceneLoadDialog(std::shared_ptr<SDLPP::Renderer> &renderer, createSceneLoadDialog(std::shared_ptr<SDLPP::Renderer> &renderer,
const std::string &path) { const std::string &path, bool transparent_bg) {
auto scene = std::make_shared<SDLPP::Scene>(renderer); auto scene = std::make_shared<SDLPP::Scene>(renderer);
auto bg = std::make_shared<SDLPP::RectangleRender>(0, 0, 10, 10, renderer, auto bg = std::make_shared<SDLPP::RectangleRender>(0, 0, 10, 10, renderer,
"#000000BB", true); transparent_bg ? "#000000BB" : MARIO_OVERWORLD_COLORKEY, true);
bg->setPermanent(); bg->setPermanent();
bg->setId(1); bg->setId(1);
scene->addObject(bg); scene->addObject(bg);
@ -161,7 +162,7 @@ createSceneLoadDialog(std::shared_ptr<SDLPP::Renderer> &renderer,
scene->addObject(button); scene->addObject(button);
} }
auto font_config = std::make_shared<SDLPP::FontConfiguration>( auto font_config = std::make_shared<SDLPP::FontConfiguration>(
g_text_config->getFont(), "#000000", "#282828", 0.05); g_text_config->getFont(), "#000000", "#FFFFFFAA", 0.05);
auto dialog_text = std::make_shared<SDLPP::TextRenderer>( auto dialog_text = std::make_shared<SDLPP::TextRenderer>(
0.1, 0.15, 0.8, 0.3, renderer, "LEVELS", font_config, 0.1, 0.15, 0.8, 0.3, renderer, "LEVELS", font_config,
SDLPP_TEXT_CENTER); SDLPP_TEXT_CENTER);
@ -263,11 +264,11 @@ SceneStruct
createLoadScene(std::shared_ptr<SDLPP::Renderer> renderer, createLoadScene(std::shared_ptr<SDLPP::Renderer> renderer,
const std::string &path, const std::string &path,
std::function<void(const std::string &)> finalizer, std::function<void(const std::string &)> finalizer,
bool pop_at_finish) { bool pop_at_finish, bool transparent_bg) {
__load_dialog_finalizer = std::move(finalizer); __load_dialog_finalizer = std::move(finalizer);
__pop_at_finish_load_dialog = pop_at_finish; __pop_at_finish_load_dialog = pop_at_finish;
SceneStruct ret{}; SceneStruct ret{};
ret.scene = createSceneLoadDialog(renderer, path); ret.scene = createSceneLoadDialog(renderer, path, transparent_bg);
ret.additionalRender = __additionalRender_LoadDialog; ret.additionalRender = __additionalRender_LoadDialog;
ret.doInput = __pollEvents_LoadDialog; ret.doInput = __pollEvents_LoadDialog;
__update_scenes_load_dialog = true; __update_scenes_load_dialog = true;

View File

@ -19,6 +19,6 @@ SceneStruct createOkScene(std::shared_ptr<SDLPP::Renderer> renderer,
SceneStruct createLoadScene(std::shared_ptr<SDLPP::Renderer> renderer, SceneStruct createLoadScene(std::shared_ptr<SDLPP::Renderer> renderer,
const std::string &path, const std::string &path,
std::function<void(const std::string &)> finalizer, std::function<void(const std::string &)> finalizer,
bool pop_at_finish = true); bool pop_at_finish = true, bool transparent_bg = true);
#endif #endif

View File

@ -50,14 +50,11 @@ void MarioVisitor::visit(const SDLPP::RenderObject &obj) {
} }
break; break;
case DEATH_ID: case DEATH_ID:
// TODO remove death? _death = true;
death = true;
_quit = true;
break; break;
case GOOMBA_ID: case GOOMBA_ID:
if (from != MARIO_FLOOR_DETECT && from != MARIO_ENEMY_DETECT) { if (from != MARIO_FLOOR_DETECT && from != MARIO_ENEMY_DETECT) {
death = true; _death = true;
_quit = true;
} else { } else {
_bounce = true; _bounce = true;
} }

View File

@ -8,17 +8,17 @@
class MarioVisitor : public SDLPP::Visitor { class MarioVisitor : public SDLPP::Visitor {
public: public:
MarioVisitor(bool is_jumping, SDLPP::Scene &scene, bool &quit, MarioVisitor(bool is_jumping, SDLPP::Scene &scene, bool &death,
int &coin_count, int &coin_count,
std::vector<std::shared_ptr<MarioBlock>> &moving_objects) std::vector<std::shared_ptr<MarioBlock>> &moving_objects)
: jumping(is_jumping), _scene(scene), _quit(quit), : jumping(is_jumping), _scene(scene), _death(death),
_coin_count(coin_count), _moving_objects(moving_objects) {} _coin_count(coin_count), _moving_objects(moving_objects) {}
void visit(const SDLPP::RenderObject &obj) override; void visit(const SDLPP::RenderObject &obj) override;
bool isOnGround() const { bool isOnGround() const {
return onGround; return onGround;
} }
bool isDead() const { bool isDead() const {
return death; return _death;
} }
bool isStopped() const { bool isStopped() const {
return stop; return stop;
@ -111,7 +111,6 @@ public:
private: private:
bool onGround = false; bool onGround = false;
double groundY = 0; double groundY = 0;
bool death = false;
bool stop = false; bool stop = false;
double newX{}; double newX{};
uint64_t from = -1; uint64_t from = -1;
@ -126,7 +125,7 @@ private:
SDLPP::Vec2D<double> movement_blockage; SDLPP::Vec2D<double> movement_blockage;
std::shared_ptr<MarioBlock> coin_block = nullptr; std::shared_ptr<MarioBlock> coin_block = nullptr;
SDLPP::Scene &_scene; SDLPP::Scene &_scene;
bool &_quit; bool &_death;
int &_coin_count; int &_coin_count;
bool mushroom = false; bool mushroom = false;
std::vector<std::shared_ptr<MarioBlock>> &_moving_objects; std::vector<std::shared_ptr<MarioBlock>> &_moving_objects;

View File

@ -5,7 +5,7 @@
#include "goomba_visitor.hpp" #include "goomba_visitor.hpp"
std::shared_ptr<SDLPP::Visitor> std::shared_ptr<SDLPP::Visitor>
getVisitor(const MarioBlock &block, SDLPP::Scene &scene, bool &quit, getVisitor(const MarioBlock &block, SDLPP::Scene &scene, bool &death,
int &coin_count, int &coin_count,
std::vector<std::shared_ptr<MarioBlock>> &moving_objects) { std::vector<std::shared_ptr<MarioBlock>> &moving_objects) {
std::shared_ptr<SDLPP::Visitor> result{}; std::shared_ptr<SDLPP::Visitor> result{};
@ -13,7 +13,7 @@ getVisitor(const MarioBlock &block, SDLPP::Scene &scene, bool &quit,
case MARIO_ID: case MARIO_ID:
result = std::static_pointer_cast<SDLPP::Visitor>( result = std::static_pointer_cast<SDLPP::Visitor>(
std::make_shared<MarioVisitor>(block.getMovement().getY() < 0, std::make_shared<MarioVisitor>(block.getMovement().getY() < 0,
scene, quit, coin_count, scene, death, coin_count,
moving_objects)); moving_objects));
break; break;
case MUSHROOM_ID: case MUSHROOM_ID: