Archived
Meteory są w tym samym stanie co w poprzednim commit, tylko, że teraz są zdefiniowane w osobnej klasie "Plansza"
This commit is contained in:
+3
-3
@@ -12,15 +12,15 @@ class Bullet {
|
||||
|
||||
public:
|
||||
Bullet(float x, float y, sf::Texture &texture);
|
||||
void update();
|
||||
sf::Sprite& getSprite();
|
||||
sf::Sprite &getSprite();
|
||||
void setSpeed(float speed);
|
||||
bool getStatus() const;
|
||||
void update();
|
||||
private:
|
||||
sf::Sprite bulletSprite;
|
||||
sf::Texture bulletTexture;
|
||||
float bulletSpeed;
|
||||
Position bulletPosition;
|
||||
float bulletSpeed;
|
||||
bool outOfBounds;
|
||||
};
|
||||
|
||||
|
||||
+4
-3
@@ -9,15 +9,16 @@ class Meteor {
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
public:
|
||||
Meteor(int x, int y, sf::Texture &texture);
|
||||
sf::Sprite & getSprite();
|
||||
Meteor(float x, float y, sf::Texture &texture);
|
||||
sf::Sprite &getSprite();
|
||||
bool getStatus();
|
||||
void update();
|
||||
private:
|
||||
sf::Texture meteorTexture;
|
||||
sf::Sprite meteorSprite;
|
||||
Position position;
|
||||
Position meteorPosition;
|
||||
float meteorSpeed;
|
||||
bool outOfBounds;
|
||||
};
|
||||
|
||||
+17
-3
@@ -2,11 +2,25 @@
|
||||
#define PLANSZA_H
|
||||
|
||||
|
||||
#include "Meteor.h"
|
||||
#include "RandomNumberGenerator.h"
|
||||
|
||||
class Plansza {
|
||||
|
||||
struct Size {
|
||||
int height;
|
||||
int width;
|
||||
};
|
||||
public:
|
||||
Plansza(int windowHeight, int windowWidth);
|
||||
void spawn_meteor();
|
||||
Size getSize();
|
||||
std::vector<Meteor> &getMeteors();
|
||||
void update_meteors();
|
||||
private:
|
||||
std::vector<Meteor> meteors;
|
||||
Size size;
|
||||
sf::Texture meteorTexture;
|
||||
RandomNumberGenerator random;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //PLANSZA_H
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#ifndef LOTOSTATEK_RANDOMNUMBERGENERATOR_H
|
||||
#define LOTOSTATEK_RANDOMNUMBERGENERATOR_H
|
||||
|
||||
#include <random>
|
||||
|
||||
class RandomNumberGenerator {
|
||||
private:
|
||||
std::random_device rd;
|
||||
std::mt19937 gen;
|
||||
std::uniform_int_distribution<> dis;
|
||||
|
||||
public:
|
||||
RandomNumberGenerator() : gen(rd()), dis(0, 599) {}
|
||||
|
||||
int getRandomNumber() {
|
||||
return dis(gen);
|
||||
}
|
||||
};
|
||||
|
||||
#endif //LOTOSTATEK_RANDOMNUMBERGENERATOR_H
|
||||
Reference in New Issue
Block a user