14 Commits

Author SHA1 Message Date
087a8d7672 Merge remote-tracking branch 'refs/remotes/origin/refactor'
# Conflicts:
#	main.cpp
2024-12-04 23:46:09 +01:00
9d4af21d4d Migrated the whole main loop
The main loop of the game is now contained in Plansza class
2024-12-04 22:12:30 +01:00
5eda245ccc Plansza to be continued (WIP) 2024-12-04 16:04:25 +01:00
72e2116dc7 Refactor of structs
Refactored Size and Position
Placed them in different .h files
2024-12-04 14:47:50 +01:00
7ecb90af1f Directory structure refactor 2024-12-04 12:26:10 +01:00
29d3c11fd1 SFML przeniesiono do innego folderu 2024-12-04 11:47:47 +01:00
5ccb29f27b fix 2024-12-02 15:51:01 +01:00
2341c2fa6d New Projectiles class
Refactor of Bullet class
Different method of shooting.
2024-12-01 17:44:25 +01:00
2f6c98f4be start 2024-11-29 14:53:58 +01:00
d20fb3043b Przeszkadzało to w zmienianiu brancha 2024-11-27 23:48:08 +01:00
fec3de86d3 Delete cmake-build-debug/LotoStatek.exe 2024-11-27 10:32:07 +01:00
c7dbca9eb3 gitignore 2024-11-26 16:09:38 +01:00
559d946cab Restrukt classes WIP 2024-11-26 16:05:57 +01:00
6996490f3c little actor.h refactor 2024-11-26 13:15:31 +01:00
184 changed files with 322 additions and 238 deletions

View File

@@ -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()

View File

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 667 KiB

After

Width:  |  Height:  |  Size: 667 KiB

View File

Before

Width:  |  Height:  |  Size: 402 KiB

After

Width:  |  Height:  |  Size: 402 KiB

View File

Before

Width:  |  Height:  |  Size: 489 B

After

Width:  |  Height:  |  Size: 489 B

View File

Before

Width:  |  Height:  |  Size: 503 B

After

Width:  |  Height:  |  Size: 503 B

View File

@@ -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:

View File

@@ -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();

View File

@@ -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;
};

View File

@@ -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();

View File

@@ -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

View File

@@ -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
View 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
View 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
View 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
View File

@@ -0,0 +1,9 @@
#ifndef LOTOSTATEK_SIZE_H
#define LOTOSTATEK_SIZE_H
struct Size {
int height;
int width;
};
#endif //LOTOSTATEK_SIZE_H

Some files were not shown because too many files have changed in this diff Show More