34 Commits

Author SHA1 Message Date
87399213b3 Malutki refactor 2024-12-12 22:22:01 +01:00
f1dc19e795 Bomber i wiazkowiec nie wylaza poza ekran 2024-12-12 00:11:24 +01:00
168ba2e477 5 przeciwnikow, do poprawy lewa strona mapy przy poruszaniu i teksturki 2024-12-11 23:52:06 +01:00
38fd71b8e6 5 przeciwnikow, jakos to dziala 2024-12-11 23:47:20 +01:00
1c0e5d0293 wiazkowiec strzela, gora dol 2024-12-11 23:00:19 +01:00
c898aa0d81 wiazkowiec strzela, gora dol 2024-12-11 23:00:07 +01:00
b257837d18 Bomber nie chce trzymac sie granic mapy da faq 2024-12-11 18:06:26 +01:00
17c372fad9 Kamikadze poprawnie zadaje orbazenia graczowi, problemem byla za mala odleglosc 2024-12-11 17:58:32 +01:00
0c706625d2 Kamikadze wybucha nawet bez gracza 2024-12-11 17:49:31 +01:00
c1a24a701b Kamikadze sledzi gracza 2024-12-11 17:43:43 +01:00
41945b3d88 Cos usprawnione i nasrane 2024-12-11 16:51:56 +01:00
2234e4d973 Dodanie bombera 2024-12-11 16:33:24 +01:00
81b04bae0f Dziuala 3 strzlowiec 2024-12-10 20:20:05 +01:00
77eb83c2c3 enemy kolizja rakiet 2024-12-09 23:36:50 +01:00
a81cf284d0 Strzela z kolizja 2024-12-09 23:09:44 +01:00
13066709a7 Niby strzela, ale bez kolizji 2024-12-09 17:36:57 +01:00
44f4556fda Jakieś działające gówno
Ale nie strzela chujek
2024-12-09 16:49:18 +01:00
c655409596 Jakieś działające gówno
Ale nie strzela chujek
2024-12-09 16:48:31 +01:00
e2e44ff1ba Mac and Linux fix 2024-12-06 19:43:17 +01:00
b6830c305b ObjectItem class added to accordance of diagram class 2024-12-05 12:46:03 +01:00
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
208 changed files with 1968 additions and 275 deletions

View File

@@ -19,14 +19,35 @@ 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
headers/ObjectItem.hpp
sources/ObjectItem.cpp
sources/Enemy.cpp
headers/Enemy.h
headers/AdvancedEnemy.h
sources/AdvancedEnemy.cpp
headers/Bomber.h
sources/Bomber.cpp
headers/Kamikadze.h
sources/Kamikadze.cpp
headers/wiazkowiec.h
sources/Wiazkowiec.cpp
headers/Beam.h
sources/Beam.cpp
)
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)

View File

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
assets/img/enemy/bomber.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
assets/img/enemy/enemy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

BIN
assets/img/hearts/heart.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 782 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

View File

@@ -4,15 +4,12 @@
#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:
Actor(int x, int y, std::string path);
Actor(int x, int y, const sf::Texture& texture);
void loadTexture(std::string path);

39
headers/AdvancedEnemy.h Normal file
View File

@@ -0,0 +1,39 @@
#ifndef ADVANCED_ENEMY_H
#define ADVANCED_ENEMY_H
#include "Enemy.h"
#include <cmath>
enum class DirectionA {
Up,
Down,
Left,
Right
};
class AdvancedEnemy : public Actor {
public:
AdvancedEnemy(int x, int y, const sf::Texture& texture, const sf::Texture& bulletTexture);
void shoot() override;
void move(float deltaX, float deltaY) override;
void moveLeft() override;
void moveRight() override;
void moveUp() override;
void moveDown() override;
void update();
bool isAlive() const;
void takeDamage();
void updateDirection();
private:
sf::Clock shootClock;
sf::Texture enemyBulletTexture;
float movementSpeed = 2.0f;
bool alive = true;
DirectionA direction = DirectionA::Down;
};
#endif // ADVANCED_ENEMY_H

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

29
headers/Beam.h Normal file
View File

@@ -0,0 +1,29 @@
#ifndef LOTOSTATEK_BEAM_H
#define LOTOSTATEK_BEAM_H
#include <SFML/Graphics.hpp>
#include "Position.h"
class Beam {
public:
Beam(float x, float y, float width, float height, const sf::Color& color);
void draw(sf::RenderWindow &window);
void update();
void render(sf::RenderWindow& window);
sf::FloatRect getBounds() const;
bool isVisible() const;
void setVisible(bool visible);
private:
sf::RectangleShape beamShape;
bool visible;
sf::Texture beamTexture;
sf::Sprite beamSprite;
};
#endif // LOTOSTATEK_BEAM_H

45
headers/Bomber.h Normal file
View File

@@ -0,0 +1,45 @@
//
// Created by k on 11.12.2024.
//
#ifndef BOMBER_H
#define BOMBER_H
#include "Enemy.h"
#include "Actor.h"
enum class DirectionB {
Up,
Down,
Left,
Right
};
class Bomber : public Actor {
public:
Bomber(int x, int y, const sf::Texture& texture, const sf::Texture& bulletTexture);
void shoot() override;
void move(float deltaX, float deltaY) override;
void moveLeft() override;
void moveRight() override;
void moveUp() override;
void moveDown() override;
void setRandomDirection();
void update();
bool isAlive() const;
void takeDamage();
void updateDirection();
void setPlanszaHeight(float height, float width);
private:
float planszaHeight = 800.f;
float planszaWidth = 600.f;
sf::Clock shootClock;
sf::Texture BombaTexture;
float movementSpeed = 2.0f;
bool alive = true;
DirectionB direction = DirectionB::Down;
};
#endif //BOMBER_H

View File

@@ -1,27 +1,15 @@
#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();
Bullet(float x, float y, sf::Texture &texture) : Projectile(x,y, texture) {};
void update() override;
private:
sf::Sprite bulletSprite;
sf::Texture bulletTexture;
Position bulletPosition;
float bulletSpeed;
bool outOfBounds;
float directionY;
};

39
headers/Enemy.h Normal file
View File

@@ -0,0 +1,39 @@
#ifndef ENEMY_H
#define ENEMY_H
#include "Actor.h"
#include "SFML/System/Clock.hpp"
enum class Direction {
Up,
Down,
Left,
Right
};
class Enemy : public Actor {
public:
Enemy(int x, int y, const sf::Texture& texture) ;
void shoot() override;
void move(float deltaX, float deltaY) override;
void moveLeft() override;
void moveRight() override;
void moveUp() override;
void moveDown() override;
void update();
bool isAlive() const;
void takeDamage();
void updateDirection();
private:
sf::Clock shootClock;
sf::Texture enemyBulletTexture;
float movementSpeed = 2.0f;
bool alive = true;
Direction direction = Direction::Down;
};
#endif // ENEMY_H

46
headers/Kamikadze.h Normal file
View File

@@ -0,0 +1,46 @@
#ifndef KAMIKADZE_H
#define KAMIKADZE_H
#include "Enemy.h"
#include "Actor.h"
#include "Player.h"
enum class DirectionK {
Up,
Down,
Left,
Right
};
class Kamikadze : public Actor {
public:
Kamikadze(int x, int y, const sf::Texture& texture);
void move(float deltaX, float deltaY) override;
void moveLeft() override;
void moveRight() override;
void moveUp() override;
void moveDown() override;
void setRandomDirection();
void shoot() override;
void update(const sf::Vector2f& playerPosition);
bool isAlive() const;
bool isExploding() const;
void takeDamage();
void updateDirection();
void followPlayer(const sf::Vector2f &playerPosition);
void explode(const sf::Vector2f &playerPosition, bool &playerHit);
private:
bool exploding = false;
sf::Clock explosionClock;
sf::Clock shootClock;
float movementSpeed = 2.0f;
bool alive = true;
DirectionK direction = DirectionK::Down;
};
#endif //KAMIKADZE_H

View File

@@ -3,27 +3,13 @@
#include "SFML/Graphics/Texture.hpp"
#include "SFML/Graphics/Sprite.hpp"
#include "Position.h"
#include "ObjectItem.hpp"
class Meteor {
struct Position {
int x;
int y;
};
class Meteor : public ObjectItem {
public:
Meteor(float x, float y, sf::Texture &texture);
sf::Sprite &getSprite();
bool getStatus();
void update();
// ~Meteor();
private:
sf::Texture meteorTexture;
sf::Sprite meteorSprite;
Position meteorPosition;
float meteorRotationSpeed;
float meteorSpeed;
bool outOfBounds;
static unsigned int counter;
};

24
headers/ObjectItem.hpp Normal file
View File

@@ -0,0 +1,24 @@
#ifndef LOTOSTATEK_OBJECTITEM_HPP
#define LOTOSTATEK_OBJECTITEM_HPP
#include "SFML/Graphics/Sprite.hpp"
#include "Position.h"
#include "SFML/Graphics/Texture.hpp"
class ObjectItem {
public:
ObjectItem(float x, float y, sf::Texture &texture);
sf::Sprite &getSprite();
bool getStatus();
virtual void update() = 0;
protected:
sf::Texture texture;
sf::Sprite sprite;
Position position;
float rotationSpeed;
float movingSpeed;
bool outOfBounds;
static unsigned int counter;
};
#endif //LOTOSTATEK_OBJECTITEM_HPP

View File

@@ -1,28 +1,75 @@
#ifndef PLANSZA_H
#define PLANSZA_H
#include "Meteor.h"
#include "Enemy.h"
#include "AdvancedEnemy.h"
#include "Bomber.h"
#include "Kamikadze.h"
#include "Wiazkowiec.h"
#include "Beam.h"
#include "RandomNumberGenerator.h"
#include "SFML/System/Clock.hpp"
#include "SFML/Graphics/RenderWindow.hpp"
#include "Size.h"
#include <memory>
#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,
const sf::Texture& playerTexture, const sf::Texture& playerBulletTexture, const sf::Texture& playerRocketTexture);
Size getSize();
std::vector<Meteor> &getMeteors();
void spawn_meteor();
void update_meteors();
void update();
void spawn_enemy();
void setOutOfBounds(bool status);
void spawn_advanced_enemy();
void spawn_wiazkowiec();
void spawn_bomber();
void spawn_kamikadze();
private:
std::vector<Meteor> meteors;
Size size;
Background background;
Player ship;
AudioManager audioManager;
sf::Texture meteorTexture1;
sf::Texture meteorTexture2;
sf::Texture enemyBulletTexture;
sf::Texture WiazkaTexture;
sf::Texture BombaTexture;
sf::Texture playerTexture;
sf::Texture playerBulletTexture;
sf::Texture playerRocketTexture;
sf::Texture enemyTexture;
sf::Texture advancedEnemyTexture;
sf::Texture BomberEnemyTexture;
sf::Texture KamikadzeTexture;
sf::Texture WiazkowiecTexture;
sf::Clock spawnClock;
sf::Clock shooterSpawnClock;
std::vector<Enemy> enemies;
std::vector<AdvancedEnemy> AEnemies;
std::vector<Bomber> BEnemies;
std::vector<Kamikadze> KEnemies;
std::vector<Wiazkowiec> WEnemies;
sf::Clock enemySpawnClock;
sf::Clock AenemySpawnClock;
sf::Clock BomberSpawnClock;
sf::Clock KamikadzeSpawnClock;
sf::Clock WiazkowiecSpawnClock;
std::vector<Meteor> meteors;
sf::RenderWindow *window;
};
#endif //PLANSZA_H

View File

@@ -3,11 +3,15 @@
#include <chrono>
#include <SFML/System/Clock.hpp>
#include "Actor.h"
#include "Rocket.h"
class Player : public Actor {
public:
Player(int x, int y, std::string path);
Player(int x, int y, const sf::Texture& texture, const sf::Texture& bulletTexture, const sf::Texture& rocketTexture);
void setTextures(const sf::Texture& shipTexture, const sf::Texture& bulletTexture, const sf::Texture& rocketTexture);
void shoot() override;
void alternate_shoot();
void setFirerate(unsigned int firerate);
@@ -16,10 +20,19 @@ public:
void moveRight() override;
void moveUp() override;
void moveDown() override;
void takeDamage();
bool isAlive() const;
void update();
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;
int health = 3; // Liczba punktów życia gracza
sf::Texture bulletTexture;
bool isImmortal = false; // flaga na immortal
sf::Clock immortalityClock; // Zegar kontrolujący czas nieśmiertelności
float immortalityDuration = 1.5f; // Czas trwania nieśmiertelności w sec
};

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

15
headers/Rocket.h Normal file
View File

@@ -0,0 +1,15 @@
#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

54
headers/Wiazkowiec.h Normal file
View File

@@ -0,0 +1,54 @@
#ifndef WIAZKOWIEC_H
#define WIAZKOWIEC_H
#include "Enemy.h"
#include "Actor.h"
#include "Beam.h"
enum class DirectionW {
Up,
Down,
Left,
Right
};
class Wiazkowiec : public Actor {
public:
Wiazkowiec(int x, int y, const sf::Texture& texture);
void shoot() override;
void move(float deltaX, float deltaY) override;
void moveLeft() override;
void moveRight() override;
void moveUp() override;
void moveDown() override;
void setRandomDirection();
void update();
void render(sf::RenderWindow &window);
bool isAlive() const;
void takeDamage();
void updateDirection();
bool isShooting() const;
const Beam& getBeam() const;
void setPlanszaHeight(float height, float width);
void setMapBounds(float width, float height);
private:
float planszaHeight = 800.f;
float planszaWidth = 600.f;
sf::Clock shootClock;
sf::Texture WiazkaTexture;
float movementSpeed = 2.0f;
bool alive = true;
DirectionW direction = DirectionW::Down;
Beam beam; // Wiązka
bool shooting = false;
sf::Clock shootingClock;
float beamDuration = 1.0f;
void spawnBeam(); // Tworzy wiązkę
};
#endif //WIAZKOWIEC_H

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