diff options
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | meta/maps/stage_1_boss.bfm | 2 | ||||
-rw-r--r-- | meta/maps/stage_2_start.bfm | 2 | ||||
-rw-r--r-- | src/gameplay.cpp | 15 | ||||
-rw-r--r-- | src/gameplay.hpp | 4 | ||||
-rw-r--r-- | src/projectile.cpp | 11 | ||||
-rw-r--r-- | src/projectile.hpp | 14 | ||||
-rw-r--r-- | src/weapon.cpp | 10 | ||||
-rw-r--r-- | src/weapon.hpp | 9 | ||||
-rw-r--r-- | src/wp_assaultrifle.cpp | 6 | ||||
-rw-r--r-- | src/wp_assaultrifle.hpp | 1 | ||||
-rw-r--r-- | src/wp_enemyslingshot.cpp | 6 | ||||
-rw-r--r-- | src/wp_enemyslingshot.hpp | 1 | ||||
-rw-r--r-- | src/wp_nadelauncher.cpp | 39 | ||||
-rw-r--r-- | src/wp_nadelauncher.hpp | 23 | ||||
-rw-r--r-- | src/wp_shotty.cpp | 6 | ||||
-rw-r--r-- | src/wp_shotty.hpp | 1 |
17 files changed, 119 insertions, 32 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 95b6ce5..bf266c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,7 @@ add_executable(${PROJECT_NAME} src/wp_shotty.cpp src/wp_assaultrifle.cpp src/wp_enemyslingshot.cpp + src/wp_nadelauncher.cpp src/terrain.cpp src/entity.cpp) diff --git a/meta/maps/stage_1_boss.bfm b/meta/maps/stage_1_boss.bfm index 57cae07..226beae 100644 --- a/meta/maps/stage_1_boss.bfm +++ b/meta/maps/stage_1_boss.bfm @@ -1,5 +1,5 @@ BOSS 1 10 -MINIONS 2 100 +MINIONS 2 20 WAVES 1 2 NEXT stage_1_boss.bfm BACKGROUND ../meta/media/sprites/stage_1_bossbg.png diff --git a/meta/maps/stage_2_start.bfm b/meta/maps/stage_2_start.bfm index 756acb6..e03469b 100644 --- a/meta/maps/stage_2_start.bfm +++ b/meta/maps/stage_2_start.bfm @@ -1,5 +1,5 @@ BOSS 2 10 -MINIONS 2 50 +MINIONS 2 20 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 276d9e9..0e089ad 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -19,6 +19,7 @@ #include "window.hpp" #include "wp_assaultrifle.hpp" #include "wp_enemyslingshot.hpp" +#include "wp_nadelauncher.hpp" #include "wp_shotty.hpp" Level* Game::parse(std::string const& path) { @@ -76,6 +77,7 @@ Game::Game(std::string const& path) { AWeapon* shotty = new wp_shotty(SHOTTY_BANG, SHOTTY_RELOAD); AWeapon* ar = new wp_assaultrifle(AR_BANG, SHOTTY_RELOAD); + AWeapon* nadelauncher = new wp_nadelauncher(AR_BANG, SHOTTY_RELOAD); AWeapon* sling = new wp_enemysling(SHOTTY_BANG, SHOTTY_RELOAD); for (auto i = 0; i < level->nMinion; i++) { @@ -105,6 +107,7 @@ Game::Game(std::string const& path) { player->fury = 0; player->wp[0] = shotty; player->wp[1] = ar; + player->wp[2] = nadelauncher; player->currentWeapon = player->wp[0]; player->idleTex = LoadTexture(MUCHACHO_TEX); @@ -130,7 +133,6 @@ void Game::draw() { auto left = std::to_string(enemies->size()); for (auto& en : *enemies) { - DrawCircle(en.posX, en.posY, en.radius, GREEN); if (en.hp <= 0) DrawTextureEx(en.hurtTex, (Vector2){en.posX - en.radius, en.posY - en.radius}, @@ -142,7 +144,7 @@ void Game::draw() { } if (en.hp > 1) { for (auto j = 0; j < en.hp; j++) { - DrawRectangle(en.posX + (10 * j), en.posY - 100, 10, 10, + DrawRectangle((en.posX - 50) + (10 * j), en.posY - 100, 10, 10, COOLPURPLE); } } @@ -166,9 +168,9 @@ void Game::draw() { i++) { // draw weapon ammo DrawRectangle(40 + (i * 20), SCREENHEIGHT - 60, 10, 30, RED); } - for (auto i = 0; i < enemies->size(); i++) { - if (enemies->at(i).hp >= 2) { - } + + for (auto& pr : *projectiles) { + DrawCircle(pr.posX, pr.posY, pr.radius, COOLPURPLE); } } @@ -331,6 +333,9 @@ int Game::shoot() const { return (0); } player->currentWeapon->bang(enemies, player); + if (player->currentWeapon->hasProjectiles) { + projectiles->push_back(player->currentWeapon->getProjectile()); + } if (player->currentWeapon->empty == true) { player->reloadTime = GetTime(); } diff --git a/src/gameplay.hpp b/src/gameplay.hpp index da85c51..94b713f 100644 --- a/src/gameplay.hpp +++ b/src/gameplay.hpp @@ -11,11 +11,13 @@ #include "entity.hpp" #include "map.hpp" +#include "projectile.hpp" #include "terrain.hpp" #include "window.hpp" #include <raylib.h> #include <iostream> +#include <list> #include <vector> // sound defines @@ -56,6 +58,8 @@ class Game { std::vector<Entity>* enemies; + std::list<Projectile>* projectiles; + Entity* player; Level* level; diff --git a/src/projectile.cpp b/src/projectile.cpp index e65222e..e69de29 100644 --- a/src/projectile.cpp +++ b/src/projectile.cpp @@ -1,11 +0,0 @@ -#include "projectile.hpp" -#include <raylib.h> - -Projectile::Projectile(Vector2 const& dir, Vector2 const& pos) - : direction(dir), position(pos) {} - -Projectile::~Projectile() {} - -Projectile* Projectile::getProjectile() { - return (this); -} diff --git a/src/projectile.hpp b/src/projectile.hpp index e25e5f4..3c0a1b6 100644 --- a/src/projectile.hpp +++ b/src/projectile.hpp @@ -3,13 +3,11 @@ #include <raylib.h> -class Projectile { - Vector2 const& direction; - Vector2 const& position; - - public: - Projectile(Vector2 const& direction, Vector2 const& position); - ~Projectile(); -}; +typedef struct Projectile { + int posX, posY; + Vector2 dir; + float radius; + float damage; +} Projectile; #endif /* PROJECTILE_H */ diff --git a/src/weapon.cpp b/src/weapon.cpp index 4e56117..fb871ed 100644 --- a/src/weapon.cpp +++ b/src/weapon.cpp @@ -16,8 +16,14 @@ AWeapon::AWeapon(float const rg, double const& cd, const char* s, const char* r, - std::string const& nm) - : range(rg), damage(dmg), max(mag), cooldown(cd), name(nm) { + std::string const& nm, + bool const& hasProj) + : range(rg), + damage(dmg), + max(mag), + cooldown(cd), + name(nm), + hasProjectiles(hasProj) { shot = LoadSound(s); reload = LoadSound(r); SetSoundVolume(shot, 0.3f); diff --git a/src/weapon.hpp b/src/weapon.hpp index d7f8df3..5e8fde4 100644 --- a/src/weapon.hpp +++ b/src/weapon.hpp @@ -9,6 +9,7 @@ #ifndef WEAPON_H_ #define WEAPON_H_ +#include "projectile.hpp" #include "raylib.h" #include <iostream> @@ -30,6 +31,8 @@ class AWeapon { unsigned int const damage; const std::string name; + Projectile projectile; + public: AWeapon(float const rg, // range unsigned int const& dmg, // damage @@ -37,14 +40,18 @@ class AWeapon { double const& cooldown, // duh const char* s, // shot sound path const char* r, // reload sound path - std::string const& nm); // name + std::string const& nm, // name + bool const& hasProj); // projectiles ? yea/nay ~AWeapon(); virtual int bang(std::vector<Entity>* enemies, Entity* player) = 0; void refill(); + virtual Projectile const& getProjectile() const = 0; + bool empty; unsigned int barrel; + bool hasProjectiles; }; #endif // WEAPON_H_ diff --git a/src/wp_assaultrifle.cpp b/src/wp_assaultrifle.cpp index 0be3d5b..f985d78 100644 --- a/src/wp_assaultrifle.cpp +++ b/src/wp_assaultrifle.cpp @@ -7,7 +7,7 @@ #include "entity.hpp" wp_assaultrifle::wp_assaultrifle(const char* s, const char* r) - : AWeapon(300.0f, 1, 30, 0.0, s, r, "ar") {} + : AWeapon(300.0f, 1, 30, 0.0, s, r, "ar", false) {} int wp_assaultrifle::bang(std::vector<Entity>* enemies, Entity* player) { if (barrel == 0) { @@ -66,3 +66,7 @@ int wp_assaultrifle::bang(std::vector<Entity>* enemies, Entity* player) { return (0); } } + +Projectile const& wp_assaultrifle::getProjectile() const { + return (projectile); +} diff --git a/src/wp_assaultrifle.hpp b/src/wp_assaultrifle.hpp index 89ce8e6..9c66d91 100644 --- a/src/wp_assaultrifle.hpp +++ b/src/wp_assaultrifle.hpp @@ -17,6 +17,7 @@ class wp_assaultrifle : public AWeapon { ~wp_assaultrifle(); int bang(std::vector<Entity>* enemies, Entity* player); + Projectile const& getProjectile() const; }; #endif diff --git a/src/wp_enemyslingshot.cpp b/src/wp_enemyslingshot.cpp index 068f404..2a212d6 100644 --- a/src/wp_enemyslingshot.cpp +++ b/src/wp_enemyslingshot.cpp @@ -8,7 +8,7 @@ #include "gameplay.hpp" wp_enemysling::wp_enemysling(const char* s, const char* r) - : AWeapon(300.0f, 10, 10, 0.0, s, r, "sling") {} + : AWeapon(300.0f, 10, 10, 0.0, s, r, "sling", false) {} int wp_enemysling::bang(std::vector<Entity>* enemies, Entity* baddie) { if (barrel == 0) { @@ -39,3 +39,7 @@ int wp_enemysling::bang(std::vector<Entity>* enemies, Entity* baddie) { return (0); } } + +Projectile const& wp_enemysling::getProjectile() const { + return (projectile); +} diff --git a/src/wp_enemyslingshot.hpp b/src/wp_enemyslingshot.hpp index bcaec09..92fff7f 100644 --- a/src/wp_enemyslingshot.hpp +++ b/src/wp_enemyslingshot.hpp @@ -17,6 +17,7 @@ class wp_enemysling : public AWeapon { ~wp_enemysling(); int bang(std::vector<Entity>* enemies, Entity* player); + Projectile const& getProjectile() const; }; #endif diff --git a/src/wp_nadelauncher.cpp b/src/wp_nadelauncher.cpp new file mode 100644 index 0000000..7352b42 --- /dev/null +++ b/src/wp_nadelauncher.cpp @@ -0,0 +1,39 @@ +#include "wp_nadelauncher.hpp" + +#include <raylib.h> +#include <raymath.h> +#include <iostream> + +#include "entity.hpp" +#include "projectile.hpp" + +wp_nadelauncher::wp_nadelauncher(const char* s, const char* r) + : AWeapon(300.0f, 1, 30, 0.0, s, r, "nade", true) {} + +int wp_nadelauncher::bang(std::vector<Entity>* enemies, Entity* player) { + if (barrel == 0) { + return (1); + } else { + Projectile* proj = new Projectile(); + proj->dir = player->direction; + proj->radius = player->radius; + proj->posX = player->posX; + proj->posY = player->posY; + + barrel--; + PlaySound(shot); + t = GetTime(); + // here + // + // + // there + if (barrel == 0) { + empty = true; + } + return (0); + } +} + +Projectile const& wp_nadelauncher::getProjectile() const { + return (projectile); +} diff --git a/src/wp_nadelauncher.hpp b/src/wp_nadelauncher.hpp new file mode 100644 index 0000000..2619936 --- /dev/null +++ b/src/wp_nadelauncher.hpp @@ -0,0 +1,23 @@ +/*********************************/ +/* THRESHOLD ( // */ +/* rifle ( )/ */ +/* by salade )(/ */ +/* ________________ ( /) */ +/* ()__)____________))))) :^} */ +/*********************************/ + +#ifndef WP_NADELAUNCHER_H_ +#define WP_NADELAUNCHER_H_ + +#include "weapon.hpp" + +class wp_nadelauncher : public AWeapon { + public: + wp_nadelauncher(const char* s, const char* r); + ~wp_nadelauncher(); + + int bang(std::vector<Entity>* enemies, Entity* player); + Projectile const& getProjectile() const; +}; + +#endif diff --git a/src/wp_shotty.cpp b/src/wp_shotty.cpp index 7d61ab3..f314e54 100644 --- a/src/wp_shotty.cpp +++ b/src/wp_shotty.cpp @@ -7,7 +7,7 @@ #include "entity.hpp" wp_shotty::wp_shotty(const char* s, const char* r) - : AWeapon(100.0f, 3, 10, 0.5, s, r, "shotty") {} + : AWeapon(100.0f, 3, 10, 0.5, s, r, "shotty", false) {} int wp_shotty::bang(std::vector<Entity>* enemies, Entity* player) { if (barrel == 0 || GetTime() < (t + cooldown)) { @@ -66,3 +66,7 @@ int wp_shotty::bang(std::vector<Entity>* enemies, Entity* player) { return (0); } } + +Projectile const& wp_shotty::getProjectile() const { + return (projectile); +} diff --git a/src/wp_shotty.hpp b/src/wp_shotty.hpp index c7d4074..a9383cc 100644 --- a/src/wp_shotty.hpp +++ b/src/wp_shotty.hpp @@ -17,6 +17,7 @@ class wp_shotty : public AWeapon { ~wp_shotty(); int bang(std::vector<Entity>* enemies, Entity* player); + Projectile const& getProjectile() const; }; #endif |