Archived
Statek + Strzelanie (do naprawienia białe kwadraty)
This commit is contained in:
@@ -1,9 +1,52 @@
|
||||
#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
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef LOTOSTATEK_BULLET_H
|
||||
#define LOTOSTATEK_BULLET_H
|
||||
|
||||
|
||||
#include "SFML/Graphics/Sprite.hpp"
|
||||
#include "SFML/Graphics/Texture.hpp"
|
||||
class Bullet {
|
||||
struct Position {
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
public:
|
||||
Bullet(float x, float y);
|
||||
void update();
|
||||
sf::Sprite& getSprite();
|
||||
void setSpeed(float speed);
|
||||
bool getStatus() const {
|
||||
return outOfBounds;
|
||||
}
|
||||
private:
|
||||
sf::Sprite bulletSprite;
|
||||
sf::Texture bulletTexture;
|
||||
float bulletSpeed;
|
||||
Position bulletPosition;
|
||||
bool outOfBounds;
|
||||
};
|
||||
|
||||
|
||||
#endif //LOTOSTATEK_BULLET_H
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef LOTOSTATEK_PLAYER_H
|
||||
#define LOTOSTATEK_PLAYER_H
|
||||
|
||||
|
||||
#include "Actor.h"
|
||||
|
||||
class Player : public Actor {
|
||||
public:
|
||||
Player(int x, int y, std::string path);
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //LOTOSTATEK_PLAYER_H
|
||||
Reference in New Issue
Block a user