stash
This commit is contained in:
commit
065d543d4d
262 changed files with 38368 additions and 0 deletions
47
Weapon.h
Normal file
47
Weapon.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
//
|
||||
// Created by Benjamin on 4/20/2021.
|
||||
//
|
||||
|
||||
#ifndef SFML_TEMPLATE_WEAPON_H
|
||||
#define SFML_TEMPLATE_WEAPON_H
|
||||
|
||||
#include "Projectile.h"
|
||||
#include "GameSprite.h"
|
||||
#include <iostream>
|
||||
|
||||
class Weapon {
|
||||
protected:
|
||||
int frameDelay, currentFrame;
|
||||
Shootable projectile;
|
||||
|
||||
Weapon() {
|
||||
frameDelay = 0;
|
||||
currentFrame = 0;
|
||||
|
||||
projectile = Shootable();
|
||||
};
|
||||
|
||||
explicit Weapon(int _frameDelay) : Weapon() {
|
||||
frameDelay = _frameDelay;
|
||||
}
|
||||
public:
|
||||
virtual Shootable* shoot(const Ship* shooter) {
|
||||
return new Shootable(projectile);
|
||||
}
|
||||
|
||||
void recharge() {
|
||||
if (currentFrame < frameDelay) {
|
||||
currentFrame++;
|
||||
}
|
||||
}
|
||||
|
||||
bool canShoot() const {
|
||||
return currentFrame == frameDelay;
|
||||
}
|
||||
|
||||
Shootable& getProjectile() {
|
||||
return projectile;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //SFML_TEMPLATE_WEAPON_H
|
||||
Loading…
Add table
Add a link
Reference in a new issue