Merge remote-tracking branch 'refs/remotes/origin/refactor'
# Conflicts: # main.cpp
@@ -19,14 +19,20 @@ add_executable(LotoStatek main.cpp
|
||||
sources/Bullet.cpp
|
||||
headers/Meteor.h
|
||||
sources/Meteor.cpp
|
||||
headers/RandomNumberGenerator.h)
|
||||
headers/RandomNumberGenerator.h
|
||||
headers/Projectile.h
|
||||
sources/Projectile.cpp
|
||||
headers/Rocket.h
|
||||
sources/Rocket.cpp
|
||||
headers/Size.h
|
||||
headers/Position.h)
|
||||
|
||||
if(WIN32)
|
||||
set(SFML_ROOT "${CMAKE_SOURCE_DIR}/SFML")
|
||||
set(SFML_ROOT "${CMAKE_SOURCE_DIR}/lib/SFML")
|
||||
# set(SFML_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/SFML/include")
|
||||
file(GLOB BINARY_DEP_DLLS "${SFML_INCLUDE_DIR}/../bin/*.dll")
|
||||
file(COPY ${BINARY_DEP_DLLS} DESTINATION ${CMAKE_BINARY_DIR})
|
||||
include_directories("${CMAKE_SOURCE_DIR}/SFML/bin" "${CMAKE_SOURCE_DIR}/SFML/include" "${CMAKE_SOURCE_DIR}/SFML/lib/cmake/SFML") # dodane
|
||||
include_directories("${CMAKE_SOURCE_DIR}/lib/SFML/bin" "${CMAKE_SOURCE_DIR}/lib/SFML/include" "${CMAKE_SOURCE_DIR}/lib/SFML/lib/cmake/SFML") # dodane
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules") # dodane
|
||||
find_package(SFML 2.6.2 COMPONENTS graphics window system audio REQUIRED)
|
||||
if(SFML_FOUND)
|
||||
@@ -34,9 +40,9 @@ if(WIN32)
|
||||
target_link_libraries(LotoStatek ${SFML_LIBRARIES})
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
find_package(SFML 2.6.2 COMPONENTS graphics window system REQUIRED)
|
||||
find_package(lib/SFML 2.6.2 COMPONENTS graphics window system REQUIRED)
|
||||
target_link_libraries(LotoStatek sfml-graphics sfml-window sfml-audio sfml-system)
|
||||
elseif(LINUX)
|
||||
find_package(SFML 2.6.2 COMPONENTS graphics window system REQUIRED)
|
||||
find_package(lib/SFML 2.6.2 COMPONENTS graphics window system REQUIRED)
|
||||
target_link_libraries(LotoStatek sfml-graphics sfml-window sfml-audio sfml-system)
|
||||
endif()
|
||||
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 667 KiB After Width: | Height: | Size: 667 KiB |
|
Before Width: | Height: | Size: 402 KiB After Width: | Height: | Size: 402 KiB |
|
Before Width: | Height: | Size: 489 B After Width: | Height: | Size: 489 B |
|
Before Width: | Height: | Size: 503 B After Width: | Height: | Size: 503 B |
@@ -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:
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
class AudioManager {
|
||||
public:
|
||||
AudioManager() = default;
|
||||
bool loadBackgroundMusic(const std::string& filePath);
|
||||
void playBackgroundMusic(float volume = 50.f, bool loop = true);
|
||||
void stopBackgroundMusic();
|
||||
|
||||
@@ -1,27 +1,13 @@
|
||||
#ifndef LOTOSTATEK_BULLET_H
|
||||
#define LOTOSTATEK_BULLET_H
|
||||
|
||||
#include "SFML/Graphics/Sprite.hpp"
|
||||
#include "Projectile.h"
|
||||
#include "SFML/Graphics/Texture.hpp"
|
||||
|
||||
class Bullet {
|
||||
struct Position {
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
class Bullet : public Projectile {
|
||||
public:
|
||||
Bullet(float x, float y, sf::Texture &texture);
|
||||
sf::Sprite &getSprite();
|
||||
void setSpeed(float speed);
|
||||
bool getStatus() const;
|
||||
void update();
|
||||
private:
|
||||
sf::Sprite bulletSprite;
|
||||
sf::Texture bulletTexture;
|
||||
Position bulletPosition;
|
||||
float bulletSpeed;
|
||||
bool outOfBounds;
|
||||
Bullet(float x, float y, sf::Texture &texture) : Projectile(x,y, texture) {};
|
||||
void update() override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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,36 @@
|
||||
#ifndef PLANSZA_H
|
||||
#define PLANSZA_H
|
||||
|
||||
|
||||
#include "Meteor.h"
|
||||
#include "RandomNumberGenerator.h"
|
||||
#include "SFML/System/Clock.hpp"
|
||||
#include "SFML/Graphics/RenderWindow.hpp"
|
||||
#include "Size.h"
|
||||
|
||||
#include "Player.h"
|
||||
#include "Background.h"
|
||||
#include "AudioManager.h"
|
||||
#include "Meteor.h"
|
||||
#include "Plansza.h"
|
||||
|
||||
class Plansza {
|
||||
struct Size {
|
||||
int height;
|
||||
int width;
|
||||
};
|
||||
public:
|
||||
Plansza(unsigned int windowHeight, unsigned int windowWidth);
|
||||
void spawn_meteor();
|
||||
Plansza(unsigned int windowHeight,unsigned int windowWidth, sf::RenderWindow *mainWindow);
|
||||
Size getSize();
|
||||
std::vector<Meteor> &getMeteors();
|
||||
void spawn_meteor();
|
||||
void update_meteors();
|
||||
void update();
|
||||
private:
|
||||
std::vector<Meteor> meteors;
|
||||
Size size;
|
||||
Background background;
|
||||
Player ship;
|
||||
AudioManager audioManager;
|
||||
sf::Texture meteorTexture1;
|
||||
sf::Texture meteorTexture2;
|
||||
sf::Clock spawnClock;
|
||||
std::vector<Meteor> meteors;
|
||||
sf::RenderWindow *window;
|
||||
};
|
||||
|
||||
#endif //PLANSZA_H
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <chrono>
|
||||
#include "Actor.h"
|
||||
#include "Rocket.h"
|
||||
|
||||
class Player : public Actor {
|
||||
public:
|
||||
@@ -16,10 +17,12 @@ public:
|
||||
void moveRight() override;
|
||||
void moveUp() override;
|
||||
void moveDown() override;
|
||||
std::vector<Rocket>& getRockets();
|
||||
private:
|
||||
std::chrono::steady_clock::time_point lastShotTime = std::chrono::steady_clock::now();
|
||||
std::vector<Bullet> rightBullets;
|
||||
|
||||
std::vector<Rocket> rockets;
|
||||
sf::Texture rocketTexture;
|
||||
sf::Texture bulletTexture;
|
||||
};
|
||||
|
||||
|
||||
|
||||
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
|
||||
23
headers/Projectile.h
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef PROJECTILE_H
|
||||
#define PROJECTILE_H
|
||||
|
||||
#include <SFML/Graphics/Sprite.hpp>
|
||||
#include "Position.h"
|
||||
|
||||
class Projectile {
|
||||
public:
|
||||
Projectile(float x, float y, sf::Texture &texture);
|
||||
sf::Sprite &getSprite();
|
||||
void setSpeed(float speed);
|
||||
bool isOutOfBounds() const;
|
||||
virtual void update() = 0;
|
||||
protected:
|
||||
static sf::Texture texture;
|
||||
sf::Sprite sprite;
|
||||
Position position;
|
||||
float speed;
|
||||
bool outOfBounds;
|
||||
~Projectile() = default;
|
||||
};
|
||||
|
||||
#endif //PROJECTILE_H
|
||||
14
headers/Rocket.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef ROCKET_H
|
||||
#define ROCKET_H
|
||||
#include "Projectile.h"
|
||||
|
||||
|
||||
class Rocket : public Projectile{
|
||||
public:
|
||||
Rocket(float x, float y, sf::Texture &texture) : Projectile(x,y, texture) {};
|
||||
void update() override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //ROCKET_H
|
||||
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
|
||||