53 lines
910 B
C++
53 lines
910 B
C++
#ifndef ACTOR_H
|
|
#define ACTOR_H
|
|
|
|
#include "SFML/Graphics/Sprite.hpp"
|
|
#include "SFML/Graphics/Texture.hpp"
|
|
#include "Bullet.h"
|
|
|
|
struct Position {
|
|
int x;
|
|
int y;
|
|
};
|
|
|
|
class Actor {
|
|
public:
|
|
Actor(int x, int y, std::string path);
|
|
|
|
void loadTexture(std::string path);
|
|
|
|
sf::Sprite& getSprite();
|
|
|
|
Position getPosition();
|
|
|
|
void move(float deltaX, float deltaY);
|
|
|
|
void moveLeft();
|
|
|
|
void moveRight();
|
|
|
|
void shoot();
|
|
|
|
std::vector<Bullet>& getBullets();
|
|
|
|
void updateBullets() {
|
|
for (auto& bullet : bullets) {
|
|
if(bullet.getStatus()) {
|
|
bullets.erase(bullets.begin());
|
|
}
|
|
}
|
|
}
|
|
|
|
protected:
|
|
sf::Sprite actorSprite;
|
|
sf::Texture actorTexture;
|
|
Position position;
|
|
unsigned int hp;
|
|
unsigned int damage;
|
|
unsigned int firerate;
|
|
float moving_speed;
|
|
std::vector<Bullet> bullets;
|
|
};
|
|
|
|
#endif //ACTOR_H
|