From 69de11fcf110d2ff17157cd9b384c4e8a701f869 Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Mon, 17 Jan 2022 01:20:00 +0100 Subject: what ? --- meta/maps/stage_1_start.bfm | 2 +- src/gameplay.cpp | 6 +++--- src/main.cpp | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/meta/maps/stage_1_start.bfm b/meta/maps/stage_1_start.bfm index 43aeea8..167d83b 100644 --- a/meta/maps/stage_1_start.bfm +++ b/meta/maps/stage_1_start.bfm @@ -1,5 +1,5 @@ BOSS 0 0 ENEMIES 20 20 -WAVES 4 5 +WAVES 2 10 NEXT stage_1_1.bfm BACKGROUND ../meta/media/sprites/stage_1_regbg.png diff --git a/src/gameplay.cpp b/src/gameplay.cpp index bfa9190..543969a 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -215,12 +215,12 @@ int Game::tick() { en->posY += 2.1f; en->direction.y += 0.1f; } - if ((GetRandomValue(0, 100) == 50) && + if ((GetRandomValue(0, 100) == 50) && // make enemy fire at random intervals (en->currentWeapon != nullptr)) { - std::cout << "spawn enemy" << std::endl; en->currentWeapon->bang(enemies, &(*en)); nEnemies++; - return (0); + return (0); // NOTE: this return is here to make sure that we don't run into a segfault if + // adding an enemy to the vector reallocs and invalidates the iterator. } } else { if (en->posX >= SCREENWIDTH || en->posX <= 0 || diff --git a/src/main.cpp b/src/main.cpp index 40dae71..ffa7e30 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -25,7 +25,7 @@ int main(void) { auto nPick = 0; Texture2D background; Game* game = nullptr; - std::ofstream ifs("../meta/maps/savestate"); + std::ofstream saveOut("../meta/maps/savestate"); std::string path = "../meta/maps"; int i = 0; @@ -37,6 +37,7 @@ int main(void) { i++; } } + // Main game loop while (!WindowShouldClose()) /* Detect window close button or ESC key */ { @@ -82,7 +83,7 @@ int main(void) { if (IsKeyPressed(KEY_ENTER)) { std::string next("../meta/maps/"); next += game->getNext(); - ifs << game->getCurrent(); + saveOut << game->getCurrent(); delete game; CloseAudioDevice(); @@ -185,7 +186,7 @@ int main(void) { } EndDrawing(); } - ifs.close(); + saveOut.close(); CloseWindow(); return 0; } -- cgit v1.2.3