This repository has been archived by the owner on Sep 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cannon.h
109 lines (84 loc) · 2.24 KB
/
cannon.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#ifndef CANNON_H
#define CANNON_H
#include "entity.h"
#include "bullet.h"
#include "motion.h"
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include "iostream"
class Cannon
{
public:
Cannon();
~Cannon();
virtual void shoot();
std::vector<Bullet *> *getBulletList() const;
void setBulletList(std::vector<Bullet *> *value);
int getBulletDamage() const;
void setBulletDamage(int value);
int getBulletSpeed() const;
void setBulletSpeed(int value);
sf::Sprite *getOwnerSprite() const;
void setOwnerSprite(sf::Sprite *value);
bool getReverseDirection() const;
void setReverseDirection(bool value);
int getTexturesAmount() const;
void setTexturesAmount(int value);
sf::Texture *getBulletTexture() const;
void setBulletTexture(sf::Texture *value);
bool getIsLaser() const;
void setIsLaser(bool value);
protected:
int bulletDamage;
int bulletSpeed;
virtual void shootBullet(int speed, Motion *bulletMotion, float angle=0);
sf::Texture *bulletTexture;
int texturesAmount=2;
sf::Sprite *ownerSprite;
std::vector<Bullet *> *bulletList;
sf::Vector2f getCenterPosition();
bool reverseDirection=false;
int getDirection();
bool isLaser = false;
//sf::Vector2f ;
};
class SimpleCannon : public Cannon
{
public:
SimpleCannon();
void shoot();
};
class SprayCannon : public Cannon
{
public:
SprayCannon(int angle, int bulletsByshoot);
void shoot();
int getAngle() const;
void setAngle(int value);
int getBulletsByshoot() const;
void setBulletsByshoot(int value);
private:
int angle;
int bulletsByshoot;
};
class FollowerCannon : public Cannon
{
public:
FollowerCannon(sf::Sprite *owner,sf::Sprite *target);
void shoot();
sf::Sprite *getOwner() const;
void setOwner(sf::Sprite *value);
sf::Sprite *getTarget() const;
void setTarget(sf::Sprite *value);
private:
sf::Sprite *owner;
sf::Sprite *target;
void shootBullet(int speed);
};
namespace CannonFactory{
Cannon *createSimpleCannon();
Cannon *createSprayCannon(int angle, int bulletsByshoot);
Cannon *createFollowerCannon(sf::Sprite *owner,sf::Sprite *target);
Cannon *createLaserCannon();
}
#endif // CANNON_H