Refactor of structs
Refactored Size and Position Placed them in different .h files
This commit is contained in:
@@ -4,11 +4,8 @@
|
||||
#include "SFML/Graphics/Sprite.hpp"
|
||||
#include "SFML/Graphics/Texture.hpp"
|
||||
#include "Bullet.h"
|
||||
#include "Position.h"
|
||||
|
||||
struct Position {
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
class Actor {
|
||||
public:
|
||||
|
||||
@@ -3,13 +3,9 @@
|
||||
|
||||
#include "SFML/Graphics/Texture.hpp"
|
||||
#include "SFML/Graphics/Sprite.hpp"
|
||||
#include "Position.h"
|
||||
|
||||
class Meteor {
|
||||
struct Position {
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
public:
|
||||
Meteor(float x, float y, sf::Texture &texture);
|
||||
sf::Sprite &getSprite();
|
||||
|
||||
@@ -1,28 +1,24 @@
|
||||
#ifndef PLANSZA_H
|
||||
#define PLANSZA_H
|
||||
|
||||
|
||||
#include "Meteor.h"
|
||||
#include "RandomNumberGenerator.h"
|
||||
#include "SFML/System/Clock.hpp"
|
||||
#include "Size.h"
|
||||
|
||||
class Plansza {
|
||||
struct Size {
|
||||
int height;
|
||||
int width;
|
||||
};
|
||||
public:
|
||||
Plansza(unsigned int windowHeight, unsigned int windowWidth);
|
||||
void spawn_meteor();
|
||||
Size getSize();
|
||||
std::vector<Meteor> &getMeteors();
|
||||
void spawn_meteor();
|
||||
void update_meteors();
|
||||
private:
|
||||
std::vector<Meteor> meteors;
|
||||
Size size;
|
||||
sf::Texture meteorTexture1;
|
||||
sf::Texture meteorTexture2;
|
||||
sf::Clock spawnClock;
|
||||
std::vector<Meteor> meteors;
|
||||
};
|
||||
|
||||
#endif //PLANSZA_H
|
||||
|
||||
9
headers/Position.h
Normal file
9
headers/Position.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef LOTOSTATEK_POSITION_H
|
||||
#define LOTOSTATEK_POSITION_H
|
||||
|
||||
struct Position {
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
#endif //LOTOSTATEK_POSITION_H
|
||||
@@ -2,13 +2,9 @@
|
||||
#define PROJECTILE_H
|
||||
|
||||
#include <SFML/Graphics/Sprite.hpp>
|
||||
#include "Position.h"
|
||||
|
||||
class Projectile {
|
||||
struct Position {
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
public:
|
||||
Projectile(float x, float y, sf::Texture &texture);
|
||||
sf::Sprite &getSprite();
|
||||
@@ -18,7 +14,7 @@ public:
|
||||
protected:
|
||||
static sf::Texture texture;
|
||||
sf::Sprite sprite;
|
||||
Position position{};
|
||||
Position position;
|
||||
float speed;
|
||||
bool outOfBounds;
|
||||
~Projectile() = default;
|
||||
|
||||
9
headers/Size.h
Normal file
9
headers/Size.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#ifndef LOTOSTATEK_SIZE_H
|
||||
#define LOTOSTATEK_SIZE_H
|
||||
|
||||
struct Size {
|
||||
int height;
|
||||
int width;
|
||||
};
|
||||
|
||||
#endif //LOTOSTATEK_SIZE_H
|
||||
Reference in New Issue
Block a user