Adding code for weapons
This commit is contained in:
parent
2c1e7f1f4e
commit
1faf1d0881
18
source/weapons.cpp
Normal file
18
source/weapons.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include "weapons.h"
|
||||
|
||||
void Weapon::init(int type, int pType, int pSpeed, int rof, int dmg, std::vector<BaseProjectile*> *projectiles) {
|
||||
type_ = type;
|
||||
projectileType_ = pType;
|
||||
projectileSpeed_ = pSpeed;
|
||||
rof_ = rof;
|
||||
damage_ = dmg;
|
||||
projectiles_ = projectiles;
|
||||
}
|
||||
|
||||
void Weapon::fire(Player player, Point map, int size, std::vector<SDL_Rect> *obstacles) {
|
||||
(*projectiles_).push_back(new BaseProjectile(player, damage_, map, size, projectileType_, obstacles, projectileSpeed_));
|
||||
}
|
||||
|
||||
int Weapon::getRof() {
|
||||
return rof_;
|
||||
}
|
||||
33
source/weapons.h
Normal file
33
source/weapons.h
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef WEAPONS_H_
|
||||
#define WEAPONS_H_
|
||||
|
||||
#include "point.h"
|
||||
#include "projectiles.h"
|
||||
#include "entities.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class Weapon {
|
||||
int type_;
|
||||
int projectileType_;
|
||||
int projectileSpeed_;
|
||||
int rof_;
|
||||
int damage_;
|
||||
std::vector<BaseProjectile*> *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<BaseProjectile*> *projectiles);
|
||||
void fire(Player player, Point map, int size, std::vector<SDL_Rect> *obstacles);
|
||||
int getRof();
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue
Block a user