Refactor to use objects for terrain/mod creation, added coin modifier

This commit is contained in:
2021-07-23 00:08:05 +02:00
parent 79d9f266b4
commit 3be728843a
15 changed files with 1384 additions and 127 deletions
+12
View File
@@ -24,6 +24,8 @@ std::shared_ptr< Mario > mario = nullptr;
std::shared_ptr< SDLPP::RectangleRender > leftStop = nullptr;
std::shared_ptr< SDLPP::Renderer > renderer = nullptr;
std::shared_ptr< SDLPP::TextRenderer > fps = nullptr;
std::shared_ptr< SDLPP::TextRenderer > coins = nullptr;
int coin_count = 0;
std::mutex render_mutex;
@@ -136,6 +138,10 @@ void doInput( std::shared_ptr< SDLPP::Scene > scene ) {
quit = true;
}
mario->handleVisitor(mv);
if ( mv.hasCoin() ) {
coin_count++;
coins->changeText(std::to_string(coin_count) + " COINS");
}
// if player is > 0.7 of playground, move everything left
auto playerX = mario->getRect().x;
@@ -217,6 +223,12 @@ int main() {
fps->setHidden(true);
scene->addObject(fps);
coins = std::make_shared<SDLPP::TextRenderer>(0.2, 0, 0.78, 0.1, renderer, font, "0 COINS", "#FFFFFF", "#000000", 0.1, SDLPP_TEXT_RIGHT);
coins->setAlignment(SDLPP::OBJ_START, SDLPP::OBJ_START);
coins->setId(0);
coins->setPermanent();
scene->addObject(coins);
FPSmanager gFPS;
SDL_initFramerate( &gFPS );
SDL_setFramerate( &gFPS, 60 );