aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/weapon.cpp9
-rw-r--r--src/weapon.hpp7
-rw-r--r--src/wp_assaultrifle.cpp2
-rw-r--r--src/wp_shotty.cpp7
4 files changed, 19 insertions, 6 deletions
diff --git a/src/weapon.cpp b/src/weapon.cpp
index f7426d6..34f7a12 100644
--- a/src/weapon.cpp
+++ b/src/weapon.cpp
@@ -10,8 +10,13 @@
#include <iostream>
-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)
+AWeapon::AWeapon(float const & rg,
+ unsigned int const & dmg,
+ unsigned int const & mag,
+ double const & cd,
+ const char *s,
+ const char *r) :
+ range(rg), damage(dmg), max(mag), cooldown(cd)
{
shot = LoadSound(s);
reload = LoadSound(r);
diff --git a/src/weapon.hpp b/src/weapon.hpp
index cce6c50..36ac542 100644
--- a/src/weapon.hpp
+++ b/src/weapon.hpp
@@ -30,7 +30,12 @@ protected:
unsigned int const &damage;
public:
- AWeapon(float const &rg, unsigned int const &dmg, unsigned int const & mag, const char *s, const char *r);
+ AWeapon(float const &rg,
+ unsigned int const &dmg,
+ unsigned int const & mag,
+ double const & cooldown,
+ const char *s,
+ const char *r);
~AWeapon();
virtual int bang(std::vector<Entity> * enemies, Vector2 playerDirection, Vector2 playerPosition, int * victims) = 0;
diff --git a/src/wp_assaultrifle.cpp b/src/wp_assaultrifle.cpp
index e91073b..7438b23 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(100, 10, 30, s, r)
+ : AWeapon(100, 10, 30, 0.0, s, r)
{}
diff --git a/src/wp_shotty.cpp b/src/wp_shotty.cpp
index cdb6898..580450e 100644
--- a/src/wp_shotty.cpp
+++ b/src/wp_shotty.cpp
@@ -7,19 +7,22 @@
#include "entity.hpp"
wp_shotty::wp_shotty(const char *s, const char *r)
- : AWeapon(10, 10, 10, s, r)
+ : AWeapon(10, 10, 10, 1.0, s, r)
{}
int wp_shotty::bang(std::vector<Entity> * enemies, Vector2 playerDirection, Vector2 playerPosition, int * victims)
{
- if (barrel == 0)
+ if (barrel == 0 ||
+ GetTime() < (t + cooldown))
{
return (1);
} else {
barrel--;
PlaySound(shot);
+ t = GetTime();
+ std::cout << "current time : " << t << "supposed time before next shot : " << (t + cooldown) << std::endl;
// here
//
auto rot1 = Vector2Rotate(playerDirection, -0.2f);