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
|
|
@ -10,15 +10,17 @@
|
|||
|
||||
class ProjectileWeapon : public Weapon {
|
||||
public:
|
||||
ProjectileWeapon(Projectile _proj, int frameDelay) : Weapon(frameDelay) {
|
||||
ProjectileWeapon(Projectile _proj, const sf::SoundBuffer& buffer, float volume, double effectiveAngle, int frameDelay) : Weapon(frameDelay, effectiveAngle, buffer, volume) {
|
||||
projectile = std::move(_proj);
|
||||
}
|
||||
|
||||
Shootable* shoot(const Ship* shooter) {
|
||||
Shootable* shoot(const Ship* shooter) override {
|
||||
currentFrame = 0;
|
||||
|
||||
noise.play();
|
||||
|
||||
projectile.setDirection(shooter->getDirection());
|
||||
projectile.setPosition(shooter->getPosition());
|
||||
projectile.setPosition(shooter->getXPos() + shooter->getLocalBounds().width/4 * shooter->getScale().x * cos(shooter->getDirection()*GameSprite::PI/180), shooter->getYPos() - shooter->getLocalBounds().width/4 * shooter->getScale().x * sin(shooter->getDirection()*GameSprite::PI/180));
|
||||
projectile.setShooter((GameSprite *) shooter);
|
||||
|
||||
Shootable *copied = new Shootable(projectile);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue