From d6a1ebe4a3ff32d5d672181028b2aabe5c78ac57 Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Mon, 6 Jun 2022 14:24:58 +0200 Subject: refactor --- meta/maps/map.h | 0 meta/maps/stage_1_boss.bfm | 2 +- meta/maps/stage_1_start.bfm | 10 ++++++++++ src/gameplay.cpp | 22 ++++++++++++---------- src/main.cpp | 4 ++-- src/projectile.cpp | 1 + src/projectile.hpp | 2 ++ 7 files changed, 28 insertions(+), 13 deletions(-) delete mode 100644 meta/maps/map.h diff --git a/meta/maps/map.h b/meta/maps/map.h deleted file mode 100644 index e69de29..0000000 diff --git a/meta/maps/stage_1_boss.bfm b/meta/maps/stage_1_boss.bfm index 226beae..0fd8b57 100644 --- a/meta/maps/stage_1_boss.bfm +++ b/meta/maps/stage_1_boss.bfm @@ -2,4 +2,4 @@ BOSS 1 10 MINIONS 2 20 WAVES 1 2 NEXT stage_1_boss.bfm -BACKGROUND ../meta/media/sprites/stage_1_bossbg.png +BACKGROUND ../meta/media/sprites/stage_1_regbg.png diff --git a/meta/maps/stage_1_start.bfm b/meta/maps/stage_1_start.bfm index 399088d..de476a4 100644 --- a/meta/maps/stage_1_start.bfm +++ b/meta/maps/stage_1_start.bfm @@ -3,3 +3,13 @@ MINIONS 10 20 WAVES 1 10 NEXT stage_1_1.bfm BACKGROUND ../meta/media/sprites/stage_1_regbg.png + +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 diff --git a/src/gameplay.cpp b/src/gameplay.cpp index b42daee..07902fc 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -80,6 +80,7 @@ Game::Game(std::string const& path) { AWeapon* nadelauncher = new wp_nadelauncher(AR_BANG, SHOTTY_RELOAD); AWeapon* sling = new wp_enemysling(SHOTTY_BANG, SHOTTY_RELOAD); + // init minions for (auto i = 0; i < level->nMinion; i++) { Entity en(level->mHp); en.radius = level->mRadius; @@ -88,6 +89,7 @@ Game::Game(std::string const& path) { en.currentWeapon = nullptr; enemies->push_back(en); } + // init bosses for (auto i = 0; i < level->nBoss; i++) { Entity en(level->bHp); en.radius = level->bRadius; @@ -97,6 +99,7 @@ Game::Game(std::string const& path) { en.hurtTex = LoadTexture(BOSS_TEX_HURT); enemies->push_back(en); // legacy code. TODO: remove AKchually no } + // init player player = new Entity(); player->posX = 0; player->posY = SCREENHEIGHT / 2.0f; @@ -112,20 +115,14 @@ Game::Game(std::string const& path) { player->idleTex = LoadTexture(MUCHACHO_TEX); crosshair = LoadTexture(CROSSHAIR_TEX); + nEnemies = level->nTotal; + + // needed for mouse position referencing frameWidth = player->idleTex.width; frameHeight = player->idleTex.height; - sourceRec = {0.0f, 0.0f, (float)frameWidth, (float)frameHeight}; - origin = {(float)frameWidth, (float)frameHeight}; - nEnemies = level->nTotal; -} - -Game::~Game() { - delete enemies; - delete player; - delete level; } // draw bad boys and player @@ -189,7 +186,6 @@ int Game::tick() { // baddie logic // - // std::cerr << "DEBUG: start baddie move loop \n"; for (auto en = enemies->begin(); en != enemies->end(); en++) { // std::cerr << "DEBUG: direction :" << en->direction.x<< "\n"; if (en->hp > 0) { @@ -350,3 +346,9 @@ std::string const& Game::getBackground() const { int const& Game::getKills() const { return player->victims; } + +Game::~Game() { + delete enemies; + delete player; + delete level; +} diff --git a/src/main.cpp b/src/main.cpp index 409c86e..4710b10 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -86,10 +86,10 @@ int main(void) { CloseAudioDevice(); if (game->getNext() != "0") { - delete game; + delete game; game = new Game(next); gs = GAMEPLAY; - std::cout << "next level " << next << std::endl; + std::cout << "next level " << next << std::endl; } } break; diff --git a/src/projectile.cpp b/src/projectile.cpp index e69de29..8f01474 100644 --- a/src/projectile.cpp +++ b/src/projectile.cpp @@ -0,0 +1 @@ +// FIXME: Unused class diff --git a/src/projectile.hpp b/src/projectile.hpp index 3c0a1b6..e7d8473 100644 --- a/src/projectile.hpp +++ b/src/projectile.hpp @@ -3,6 +3,8 @@ #include +// FIXME: Unused class + typedef struct Projectile { int posX, posY; Vector2 dir; -- cgit v1.2.3