diff options
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | src/entity.hpp | 2 | ||||
-rw-r--r-- | src/gameplay.cpp | 3 | ||||
-rw-r--r-- | src/weapon.cpp | 19 | ||||
-rw-r--r-- | src/weapon.hpp | 9 | ||||
-rw-r--r-- | src/wp_shotty.cpp | 22 | ||||
-rw-r--r-- | src/wp_shotty.hpp | 23 |
8 files changed, 61 insertions, 26 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 111e2cf..d213ea3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ add_executable(${PROJECT_NAME} src/window.cpp src/gameplay.cpp src/weapon.cpp + src/wp_shotty.cpp src/terrain.cpp src/entity.cpp) @@ -36,10 +36,10 @@ cmake .. ## TODO ### Weapons -- reload -- visual representation of mag -- more weapons (gravity gun ?) +- [DONE]reload +- [DONE]visual representation of mag +- [TODO]more weapons (gravity gun ?) ### Maps - more -- terrain +- terrain ? diff --git a/src/entity.hpp b/src/entity.hpp index a38edcf..6c803df 100644 --- a/src/entity.hpp +++ b/src/entity.hpp @@ -25,7 +25,7 @@ class Entity { double furyTime; double reloadTime; Vector2 direction; - Weapon * wp; + AWeapon * wp; Image img; Texture2D idleTex; Texture2D hurtTex; diff --git a/src/gameplay.cpp b/src/gameplay.cpp index dbfd4af..effd26d 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -13,6 +13,7 @@ #include <raylib.h> #include "weapon.hpp" +#include "wp_shotty.hpp" Game::Game(std::string const & path) : current(path) { @@ -73,7 +74,7 @@ Game::Game(std::string const & path) : current(path) player->radius = 10; player->victims = 0; player->fury = 0; - player->wp = new Weapon(10, 10, 10, + player->wp = new wp_shotty(10, 10, 10, SHOTTY_BANG, SHOTTY_RELOAD); player->idleTex = LoadTexture(MUCHACHO_TEX); diff --git a/src/weapon.cpp b/src/weapon.cpp index 62e6150..f357b40 100644 --- a/src/weapon.cpp +++ b/src/weapon.cpp @@ -10,7 +10,7 @@ #include <iostream> -Weapon::Weapon(float const & rg, unsigned int const & dmg, unsigned int const & mag, const char *s, const char *r) : +AWeapon::AWeapon(float const & rg, unsigned int const & dmg, unsigned int const & mag, const char *s, const char *r) : range(rg), damage(dmg), max(mag) { InitAudioDevice(); @@ -21,24 +21,11 @@ Weapon::Weapon(float const & rg, unsigned int const & dmg, unsigned int const & barrel = max; } -Weapon::~Weapon() {} +AWeapon::~AWeapon() {} -void Weapon::refill() +void AWeapon::refill() { std::cout << "reload" << std::endl; PlaySound(reload); barrel = max; } - -int Weapon::bang() -{ - if (barrel == 0) - { - return (1); - } else { - barrel--; - std::cout << "BANG : " << barrel << "shots left" << std::endl; - PlaySound(shot); - return (0); - } -} diff --git a/src/weapon.hpp b/src/weapon.hpp index 1f4393d..e43b7da 100644 --- a/src/weapon.hpp +++ b/src/weapon.hpp @@ -11,7 +11,8 @@ #include "raylib.h" -class Weapon { +class AWeapon { +protected: Sound shot; Sound reload; @@ -22,10 +23,10 @@ class Weapon { unsigned int const &damage; public: - Weapon(float const &rg, unsigned int const &dmg, unsigned int const & mag, const char *s, const char *r); - ~Weapon(); + AWeapon(float const &rg, unsigned int const &dmg, unsigned int const & mag, const char *s, const char *r); + ~AWeapon(); - int bang(); + virtual int bang() = 0; void refill(); bool empty; diff --git a/src/wp_shotty.cpp b/src/wp_shotty.cpp new file mode 100644 index 0000000..13ab834 --- /dev/null +++ b/src/wp_shotty.cpp @@ -0,0 +1,22 @@ +#include "wp_shotty.hpp" + +#include <iostream> + +wp_shotty::wp_shotty(float const &rg, unsigned int const &dmg, unsigned int const & mag, const char *s, const char *r) + : AWeapon(rg, dmg, mag, s, r) +{} + + + +int wp_shotty::bang() +{ + if (barrel == 0) + { + return (1); + } else { + barrel--; + std::cout << "BANG : " << barrel << "shots left" << std::endl; + PlaySound(shot); + return (0); + } +} diff --git a/src/wp_shotty.hpp b/src/wp_shotty.hpp new file mode 100644 index 0000000..a01891f --- /dev/null +++ b/src/wp_shotty.hpp @@ -0,0 +1,23 @@ +/*********************************/ +/* THRESHOLD ( // */ +/* shotty ( )/ */ +/* by salade )(/ */ +/* ________________ ( /) */ +/* ()__)____________))))) :^} */ +/*********************************/ + +#ifndef WP_SHOTTY_H_ +#define WP_SHOTTY_H_ + +#include "weapon.hpp" + +class wp_shotty : public AWeapon { + public: + wp_shotty(float const &rg, unsigned int const &dmg, unsigned int const & mag, const char *s, const char *r); + ~wp_shotty(); + + int bang() ; +}; + + +#endif |