diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gameplay.cpp | 22 | ||||
-rw-r--r-- | src/main.cpp | 4 | ||||
-rw-r--r-- | src/projectile.cpp | 1 | ||||
-rw-r--r-- | src/projectile.hpp | 2 |
4 files changed, 17 insertions, 12 deletions
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 <raylib.h> +// FIXME: Unused class + typedef struct Projectile { int posX, posY; Vector2 dir; |