diff --git a/main.cpp b/main.cpp index d9f5f85d000fa36c5760d31b5f314668b757dc02..0b63288d9ad6f78aa133dde576712b39509f8f73 100644 --- a/main.cpp +++ b/main.cpp @@ -16,10 +16,21 @@ //constexpr double PI = 3.14159265358979323846; // <kruegerzo72182 bool debug = false; +bool spawnTroopers = true; float trooperTimer = 0.0f; +float trooperSpawnTime = 3.0f; +int trooperSpawnX = 120; +int trooperSpawnY = 170; +int trooperSpawnCount = 1; // +1 float bomberTimer = 25.0f; +float bomberSpawnTime = 30.0f; +float tankTimer = 15.0f; +float tankSpawnTime = 25.0f; +float difficultyTimer = 0.0f; +float difficultyChangeTime = 60.0f; int screenWidth = 320; int screenHeigth = 320; +int difficulty = 0; // global helper funktion to add "buildings" void addBuilding(float x, float y, int size, Level &level_ptr) @@ -62,26 +73,38 @@ public: } else { platform.set_title( - "Player X: " + - std::to_string(std::lround(player_.getLeft())) + + "<Player X: " + + std::to_string(std::lround(player_.getTopLeft().X)) + " --- Player Y: " + - std::to_string(std::lround(player_.getTop())) + std::to_string(std::lround(player_.getTopLeft().Y)) + + " --- difficulty: " + std::to_string(difficulty) + + " --- trooperSpawnCount: " + std::to_string(trooperSpawnCount) + + " --- debug>" ); } } // hoffmanncl72341> // <kruegerzo72182 //Spawn the troopers from the trooperspawner - trooperTimer = trooperTimer + frame_time.count(); - if(level.getEnemySpawnCount() != 0){ - if(trooperTimer > 3.0f){ - level.enemyVector_PushBack(level.getTrooperSpawn()); - trooperTimer = 0.0f; + if(spawnTroopers){ + trooperTimer = trooperTimer + frame_time.count(); + if(level.getEnemySpawnCount() != 0){ + if(trooperTimer > trooperSpawnTime){ + level.enemyVector_PushBack(level.getTrooperSpawn()); + trooperTimer = 0.0f; + } } - } + else{ + spawnTroopers = false; + level.fillTrooperSpawner(static_cast<float>(trooperSpawnX), static_cast<float>(trooperSpawnY), trooperSpawnCount); + } + } + if(true){ + + } //Spawn bombers from different directions endlessly bomberTimer = bomberTimer + frame_time.count(); - if(bomberTimer > 30.0f){ + if(bomberTimer > bomberSpawnTime){ int direction = rand() % 4; float bombX; float bombY; @@ -106,7 +129,60 @@ public: } level.enemyVector_PushBack(std::make_unique<Bomber>(Bomber(bombX, bombY, direction, 0))); bomberTimer = 0.0f; - } + if(difficulty < 25) + { + bomberSpawnTime = bomberSpawnTime - difficulty; + } + } + if(bomberSpawnTime < 4){ + bomberSpawnTime = 5; + } + + tankTimer = tankTimer + frame_time.count(); + if(tankTimer > tankSpawnTime){ + int direction = 0; + int position = rand() % 6; + float tankX; + float tankY; + switch ( position ) { + case 1: + tankX = static_cast<float>(50); + tankY = static_cast<float>(150); + direction = 0; + break; + case 2: + tankX = static_cast<float>(200); + tankY = static_cast<float>(160); + direction = 2; + break; + case 3: + tankX = static_cast<float>(270); + tankY = static_cast<float>(50); + direction = 1; + break; + case 4: + tankX = static_cast<float>(15); + tankY = static_cast<float>(225); + direction = 3; + break; + case 5: + tankX = static_cast<float>(170); + tankY = static_cast<float>(210); + direction = 2; + break; + default: + tankX = static_cast<float>(20); + tankY = static_cast<float>(25); + direction = 3; + break; + } + level.enemyVector_PushBack(std::make_unique<Tank>(Tank(tankX, tankY, direction, 0))); + tankTimer = 0.0f; + if(difficulty < 25) + { + //tankSpawnTime = tankSpawnTime - difficulty; + } + } // kruegerzo72182> if(!GameOverFlag) //Hauerch71498 @@ -120,7 +196,18 @@ public: // enemy movement GameOverFlag = (level.doDoSteps(frame_time) == false); - + + difficultyTimer = difficultyTimer + frame_time.count(); + if((difficultyTimer > difficultyChangeTime)) + { + difficulty++; + difficultyTimer = 0.0f; + spawnTroopers = true; + if(trooperSpawnCount < 11 && difficulty%4 == 0){ + trooperSpawnCount = trooperSpawnCount + 2; + } + } + // Output to the console, Gamelogic should happen before this auto const &levelBuffer = level.draw(); if(GameOverFlag) {