added weapon sounds and AI doesnt shoot if not in range
This commit is contained in:
parent
d1a7053149
commit
8016bab3e8
8 changed files with 48 additions and 13 deletions
13
Weapon.h
13
Weapon.h
|
|
@ -7,12 +7,15 @@
|
|||
|
||||
#include "Projectile.h"
|
||||
#include "GameSprite.h"
|
||||
#include <SFML/Audio.hpp>
|
||||
#include <iostream>
|
||||
|
||||
class Weapon {
|
||||
protected:
|
||||
int frameDelay, currentFrame;
|
||||
Shootable projectile;
|
||||
sf::Sound noise;
|
||||
double effectiveAngle;
|
||||
|
||||
Weapon() {
|
||||
frameDelay = 0;
|
||||
|
|
@ -21,8 +24,12 @@ protected:
|
|||
projectile = Shootable();
|
||||
};
|
||||
|
||||
explicit Weapon(int _frameDelay) : Weapon() {
|
||||
explicit Weapon(int _frameDelay, double _effectiveAngle, const sf::SoundBuffer& _buffer, float volume) : Weapon() {
|
||||
effectiveAngle = _effectiveAngle;
|
||||
frameDelay = _frameDelay;
|
||||
|
||||
noise.setBuffer(_buffer);
|
||||
noise.setVolume(volume);
|
||||
}
|
||||
public:
|
||||
virtual Shootable* shoot(const Ship* shooter) {
|
||||
|
|
@ -42,6 +49,10 @@ public:
|
|||
Shootable& getProjectile() {
|
||||
return projectile;
|
||||
}
|
||||
|
||||
double getEffectiveAngle() const {
|
||||
return effectiveAngle;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //SFML_TEMPLATE_WEAPON_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue