diff options
author | salaaad2 <arthurdurant263@gmail.com> | 2022-01-20 13:46:23 +0100 |
---|---|---|
committer | salaaad2 <arthurdurant263@gmail.com> | 2022-01-20 13:46:23 +0100 |
commit | 0443633f412726e73cbc803e5c091be58311bd88 (patch) | |
tree | e4f5fa2956296cbf7227742ebc03b308d4f86192 | |
parent | rework parsing and level mangment. commit often (diff) | |
download | threshold-0443633f412726e73cbc803e5c091be58311bd88.tar.gz threshold-0443633f412726e73cbc803e5c091be58311bd88.tar.bz2 threshold-0443633f412726e73cbc803e5c091be58311bd88.tar.xz threshold-0443633f412726e73cbc803e5c091be58311bd88.tar.zst threshold-0443633f412726e73cbc803e5c091be58311bd88.zip |
rework parsing and wave management
-rw-r--r-- | meta/maps/stage_1_start.bfm | 4 | ||||
-rw-r--r-- | meta/maps/stage_2_start.bfm | 2 | ||||
-rw-r--r-- | src/gameplay.cpp | 69 | ||||
-rw-r--r-- | src/gameplay.hpp | 3 |
4 files changed, 32 insertions, 46 deletions
diff --git a/meta/maps/stage_1_start.bfm b/meta/maps/stage_1_start.bfm index bfae4e5..399088d 100644 --- a/meta/maps/stage_1_start.bfm +++ b/meta/maps/stage_1_start.bfm @@ -1,5 +1,5 @@ BOSS 0 0 -MINIONS 20 20 -WAVES 2 10 +MINIONS 10 20 +WAVES 1 10 NEXT stage_1_1.bfm BACKGROUND ../meta/media/sprites/stage_1_regbg.png diff --git a/meta/maps/stage_2_start.bfm b/meta/maps/stage_2_start.bfm index bde292a..957fd5d 100644 --- a/meta/maps/stage_2_start.bfm +++ b/meta/maps/stage_2_start.bfm @@ -1,5 +1,5 @@ BOSS 1 10 -ENEMIES 2 50 +MINIONS 2 50 WAVES 1 2 NEXT stage_1_boss.bfm BACKGROUND ../meta/media/sprites/stage_1_bossbg.png diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 1ee867c..a522cba 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -25,23 +25,24 @@ Level* Game::parse(std::string const& path) { std::string tok; Level* ret = new Level(); - std::cout << "Init: reading level.file [" << path << "]" << std::endl; + std::cout << "INIT: reading level.file [" << path << "]" << std::endl; while (ifs >> tok) { if (tok == "MINIONS") { ifs >> tok; ret->nMinion = std::atoi(tok.c_str()); ifs >> tok; ret->mRadius = std::atoi(tok.c_str()); + ret->mHp = 1; } if (tok == "BOSS") { ifs >> tok; - ret->bHp = (tok == "0") ? 1 : 0; + ret->nBoss = (tok == "0") ? 0 : 1; ret->bRadius = ret->mRadius; } if (tok == "NEXT") { ifs >> tok; ret->next = tok; - std::cout << "next ret is " << next; + std::cout << "DEBUG: next level is " << ret->next; } if (tok == "WAVES") { ifs >> tok; @@ -55,11 +56,12 @@ Level* Game::parse(std::string const& path) { } } ret->nTotal = (ret->nBoss + ret->nGrunts + ret->nMinion); + ret->current = path; ifs.close(); return (ret); } -Game::Game(std::string const& path) : current(path) { +Game::Game(std::string const& path) { auto radius = 0; auto ehp = 0; @@ -72,25 +74,24 @@ Game::Game(std::string const& path) : current(path) { AWeapon* ar = new wp_assaultrifle(AR_BANG, SHOTTY_RELOAD); AWeapon* sling = new wp_enemysling(SHOTTY_BANG, SHOTTY_RELOAD); - for (auto i = 0; i < level->nTotal; i++) { - if (ehp == 1) { - Entity en(ehp); - en.radius = radius; - en.idleTex = LoadTexture(SBIRE_TEX_IDLE); - en.hurtTex = LoadTexture(SBIRE_TEX_HURT); - en.currentWeapon = nullptr; - enemies->push_back(en); - } else { - Entity en(ehp); - en.radius = radius; - en.wp[0] = sling; - en.currentWeapon = en.wp[0]; - en.idleTex = LoadTexture(BOSS_TEX_IDLE); - en.hurtTex = LoadTexture(BOSS_TEX_HURT); - enemies->push_back(en); // legacy code. TODO: remove AKchually no - } + for (auto i = 0; i < level->nMinion; i++) { + Entity en(level->mHp); + en.radius = level->mRadius; + en.idleTex = LoadTexture(SBIRE_TEX_IDLE); + en.hurtTex = LoadTexture(SBIRE_TEX_HURT); + en.currentWeapon = nullptr; + enemies->push_back(en); + } + for (auto i = 0; i < level->nBoss; i++) { + Entity en(level->bHp); + en.radius = level->bRadius; + en.wp[0] = sling; + en.currentWeapon = en.wp[0]; + en.idleTex = LoadTexture(BOSS_TEX_IDLE); + en.hurtTex = LoadTexture(BOSS_TEX_HURT); + enemies->push_back(en); // legacy code. TODO: remove AKchually no } - player = new Entity; + player = new Entity(); player->posX = 0; player->posY = SCREENHEIGHT / 2.0f; player->direction.x = 100; @@ -98,14 +99,13 @@ Game::Game(std::string const& path) : current(path) { player->radius = 10; player->victims = 0; player->fury = 0; - - crosshair = LoadTexture(CROSSHAIR_TEX); - player->wp[0] = shotty; player->wp[1] = ar; player->currentWeapon = player->wp[0]; player->idleTex = LoadTexture(MUCHACHO_TEX); + crosshair = LoadTexture(CROSSHAIR_TEX); + frameWidth = player->idleTex.width; frameHeight = player->idleTex.height; @@ -117,6 +117,7 @@ Game::Game(std::string const& path) : current(path) { Game::~Game() { delete enemies; delete player; + delete level; } // draw bad boys and player @@ -178,18 +179,6 @@ int Game::tick() { player->direction = v2; - if (player->victims == level.nPerWave && nWaves > 1) { - nWaves--; - for (int i = 0; i < level.nPerWave; i++) { - Entity en(1); - en.radius = 20; - en.idleTex = LoadTexture(SBIRE_TEX_IDLE); - en.hurtTex = LoadTexture(SBIRE_TEX_HURT); - en.currentWeapon = nullptr; - enemies->push_back(en); - } - } - // // end player logic // ----------------------------------- @@ -339,15 +328,15 @@ int Game::shoot() const { } std::string const& Game::getNext() const { - return next; + return level->next; } std::string const& Game::getCurrent() const { - return current; + return level->current; } std::string const& Game::getBackground() const { - return background; + return level->background; } int const& Game::getKills() const { diff --git a/src/gameplay.hpp b/src/gameplay.hpp index be07491..da85c51 100644 --- a/src/gameplay.hpp +++ b/src/gameplay.hpp @@ -58,9 +58,6 @@ class Game { Entity* player; - std::string next; // next level - std::string current; // next level - std::string background; // next level Level* level; int frameWidth; |