diff --git a/source/weapons.cpp b/source/weapons.cpp new file mode 100644 index 0000000..81ac36d --- /dev/null +++ b/source/weapons.cpp @@ -0,0 +1,18 @@ +#include "weapons.h" + +void Weapon::init(int type, int pType, int pSpeed, int rof, int dmg, std::vector *projectiles) { + type_ = type; + projectileType_ = pType; + projectileSpeed_ = pSpeed; + rof_ = rof; + damage_ = dmg; + projectiles_ = projectiles; +} + +void Weapon::fire(Player player, Point map, int size, std::vector *obstacles) { + (*projectiles_).push_back(new BaseProjectile(player, damage_, map, size, projectileType_, obstacles, projectileSpeed_)); +} + +int Weapon::getRof() { + return rof_; +} diff --git a/source/weapons.h b/source/weapons.h new file mode 100644 index 0000000..43f32d9 --- /dev/null +++ b/source/weapons.h @@ -0,0 +1,33 @@ +#ifndef WEAPONS_H_ +#define WEAPONS_H_ + +#include "point.h" +#include "projectiles.h" +#include "entities.h" + +#include + +class Weapon { + int type_; + int projectileType_; + int projectileSpeed_; + int rof_; + int damage_; + std::vector *projectiles_; + +public: + Weapon() + : type_(0), + projectileType_(0), + projectileSpeed_(10), + rof_(4), + damage_(0), + projectiles_(NULL) + {} + + void init(int type, int pType, int pSpeed, int rof, int dmg, std::vector *projectiles); + void fire(Player player, Point map, int size, std::vector *obstacles); + int getRof(); +} + +#endif