75 Commits

Author SHA1 Message Date
ff562d4d92 usunięcie zduplikowanego wpisu 2025-01-15 23:21:54 +01:00
898671a72a Poprawiono kolizje bomb z pociskami gracza 2025-01-15 21:58:20 +01:00
0ea80559e5 Boss poprawnie reaguje z rakietami 2025-01-15 19:40:08 +01:00
6a833f5698 Merge remote-tracking branch 'origin/BossV1' into BossV1 2025-01-14 15:38:14 +01:00
2539892b71 Boss nie wylazi 2025-01-14 15:38:02 +01:00
17a1d3689b todo added 2025-01-14 14:45:13 +01:00
8b8bfc9aed Merge remote-tracking branch 'origin/BossV1' into BossV1 2025-01-14 14:11:42 +01:00
b833a21dbb Tekstura bossa 2025-01-14 14:09:28 +01:00
2e02b17cc7 dodano laser 2025-01-14 14:09:18 +01:00
7d2b8bd9a2 Kolizja wiazki dodana 2025-01-14 13:52:58 +01:00
baced5f971 Kolizja wiazki dodana 2025-01-14 13:52:05 +01:00
629b1279a9 Boss utworzony, strzela, bombuje, wiazkuje(#KolizjaToDo) 2025-01-13 23:59:18 +01:00
62808a9fbf Zaimplementowano pauze 2025-01-09 12:11:56 +01:00
5ad7cc9d1e Merge branch 'powerup' 2025-01-07 10:32:50 +01:00
4d2283d15e powerups fully implemented 2025-01-06 16:17:38 +01:00
236ddd828d Merge branch 'refactor' 2025-01-06 11:51:33 +01:00
b1b5858fb6 Dziala powerup na prędkość poruszania się 2025-01-06 01:31:59 +01:00
3d83a3a767 powerup init commit 2025-01-05 18:35:39 +01:00
6b45443c75 Laser naprawiono 2025-01-05 18:20:19 +01:00
3e2d37cf72 Update README.md 2025-01-03 17:28:54 +01:00
c4c83382c3 Do poprawy centrowanie lasera i strzelanie w lewo i w prawo 2024-12-20 23:38:37 +01:00
0a5a26208a wip 2024-12-20 19:39:18 +01:00
76203a8b29 refactor 2024-12-19 16:01:21 +01:00
36984b859f Naprawiono laser, przerobiono na wskaźniki. Do refactoringu i poprawy sprite'a 2024-12-19 15:14:14 +01:00
15a8d82176 fix serduszek 2024-12-14 20:47:02 +01:00
5459b97e74 poprawniony spawn serduszek 2024-12-14 20:38:50 +01:00
94eddb457f Implementacja naliczania punktów za zabicie wrogów 2024-12-14 20:32:08 +01:00
9432cd94fe Zaimplementowane menu i wybieranie skinów statku 2024-12-14 20:21:46 +01:00
34424da9d6 refactor ciąg dalszy 2024-12-13 20:13:52 +01:00
80a4b1b397 Złączono i wszystko działa, ale trzeba zrobić mocny refactor Planszy bo za dużo niewiadomo skąd biorących się pętli 2024-12-13 20:05:11 +01:00
fdf67f4bc2 Merge remote-tracking branch 'origin/serduszka'
# Conflicts:
#	CMakeLists.txt
#	headers/Actor.h
#	headers/Plansza.h
#	headers/Player.h
#	sources/Plansza.cpp
#	sources/Player.cpp
2024-12-13 19:48:39 +01:00
8b4b25747e Zmiana sposobu tworzenia gracza.
Użyto singleton pattern.
Zmieniono konstruktor klasy Plansza
2024-12-13 13:36:41 +01:00
3f4a937257 Zamiana tekstur 2024-12-13 09:34:40 +01:00
d87143d98b Drobne poprawki 2024-12-13 09:16:03 +01:00
1298bab79a Usunięcie zbędnych rzeczy 2024-12-12 22:51:25 +01:00
9929a5dd40 Merge remote-tracking branch 'origin/5PrzeciwnikowWmiareDziala'
# Conflicts:
#	headers/Plansza.h
#	sources/Plansza.cpp
2024-12-12 22:28:09 +01:00
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
da33fcc718 Adjustin hearts to be in right upper corner due to score counter in left upper corner 2024-12-10 20:37:10 +01:00
74c739a09e Dodano podstawowy licznik 2024-12-10 20:30:31 +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
71f8ebe285 Statek miga
przy uderzeniu w meteoryt
2024-12-06 15:16:57 +01:00
2f9e0ba236 Serduszka działają
do zrobienia jeszcze animacja uderzenia się w meteoryt (miganie) i wybuch statku przy uderzeniu się w meteoryt po raz trzeci
2024-12-06 12:24:39 +01:00
3b637508e1 Added heart and spawn of them 2024-12-05 14:52:00 +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
231 changed files with 2899 additions and 312 deletions

View File

@@ -19,14 +19,41 @@ 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
headers/Heart.hpp
sources/Heart.cpp
headers/PowerUp.h
sources/PowerUp.cpp
sources/Boss.cpp
headers/Boss.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)

View File

@@ -1 +1,11 @@
Tu będzie lotoł statek
The space-invaders type game created for university project.
The main character is a "Ship", with which you are fighting enemies that have different abilities, for example laser beams or "Kamikaze" that will try to explode at you.
Your character has only 3 HP that are showed in right upper corner.
There are 5 different types of enemies:
1. The simpliest one - just shoots you with one bullet
2. The advanced enemy - shoots you with the same bullet, but shooted 3 at the one piece of time
3. The "Kamikaze" will explode at you once reaches you, dealing 2 hp damage.
4. The Laser enemy will shoot you with laser beam both sideways and up and down direction, dealing 1 hp damage.
5. The bomber - will leave bombs all around map which will deal 1 hp damage once exploded.

View File

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

BIN
assets/img/boss/Boss.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 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: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 782 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 958 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 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

BIN
assets/img/wiazka/laser.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 773 B

BIN
assets/ship/nova.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

BIN
assets/ship/pulsar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

BIN
assets/ship/zenith.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 221 KiB

View File

@@ -4,21 +4,19 @@
#include "SFML/Graphics/Sprite.hpp"
#include "SFML/Graphics/Texture.hpp"
#include "Bullet.h"
#include "Position.h"
#include "SFML/System/Clock.hpp"
struct Position {
int x;
int y;
};
class Actor {
public:
Actor(int x, int y, std::string path);
void loadTexture(std::string path);
Actor(int x, int y, const sf::Texture& texture);
virtual ~Actor() = default;
sf::Sprite& getSprite();
unsigned int getHP();
Position getPosition();
std::vector<Bullet>& getBullets();
virtual void move(float deltaX, float deltaY) = 0;
virtual void moveLeft() = 0;
@@ -27,23 +25,23 @@ public:
virtual void moveDown() = 0;
virtual void shoot() = 0;
std::vector<Bullet>& getBullets();
void updateBullets();
void setMovingSpeed(float speed);
void dealDamage();
void healUP();
protected:
Position position;
sf::Sprite actorSprite;
sf::Texture actorTexture;
sf::Texture bulletTextureLeft;
sf::Texture bulletTextureRight;
Position position;
unsigned int hp;
sf::Texture bulletTexture;
sf::Texture rocketTexture;
std::vector<Bullet> bullets;
sf::Clock damageDealClock;
int hp;
unsigned int damage;
unsigned int firerate;
float moving_speed;
std::vector<Bullet> bullets;
};
#endif //ACTOR_H

37
headers/AdvancedEnemy.h Normal file
View File

@@ -0,0 +1,37 @@
#ifndef ADVANCED_ENEMY_H
#define ADVANCED_ENEMY_H
#include "Enemy.h"
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();

18
headers/Beam.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef LOTOSTATEK_BEAM_H
#define LOTOSTATEK_BEAM_H
#include <SFML/Graphics.hpp>
class Beam {
public:
Beam() = default;
Beam(int x, int y, const sf::Texture &texture);
sf::Sprite getSprite();
void setRotation(float angle);
private:
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

72
headers/Boss.h Normal file
View File

@@ -0,0 +1,72 @@
#ifndef BOSS_H
#define BOSS_H
#include "Actor.h"
#include "Bullet.h"
#include "Beam.h"
#include <vector>
#include <SFML/Graphics.hpp>
enum class BossDirection {
Up,
Down,
Left,
Right
};
class Boss : public Actor {
public:
Boss(int x, int y, const sf::Texture &bossTexture, const sf::Texture &bulletTexture, sf::Texture BombaTexture,
sf::RenderWindow *window);
void setPlanszaHeight(int height, int width);
void moveLeft() override;
void moveRight() override;
void moveUp() override;
void moveDown() override;
void shoot() override;
void dropBomb();
void shootLaser();
void move(float deltaX, float deltaY) override;
void update();
void takeDamage();
bool isAlive() const;
std::vector<Bullet>& getBullets() { return bullets; }
std::vector<Bullet>& getBombs() { return bombs; }
bool isShooting() const { return laserBeam != nullptr; }
Beam* getBeam() const { return laserBeam; }
private:
float movementSpeed = 5.5f;
BossDirection direction = BossDirection::Down;
sf::Clock shootClock;
sf::Clock bombClock;
sf::Clock laserClock;
sf::Clock directionClock;
sf::Clock beamDurationClock;
float beamDuration = 1.0f;
sf::Texture bulletTexture;
sf::Texture BombaTexture;
sf::Texture beamTexture;
sf::RenderWindow* window;
Beam* laserBeam = nullptr;
std::vector<Bullet> bullets;
std::vector<Bullet> bombs;
int planszaHeight = 800;
int planszaWidth = 600;
bool isStationary = false;
void setRandomDirection();
void handleBounds();
};
#endif // BOSS_H

View File

@@ -1,27 +1,12 @@
#ifndef LOTOSTATEK_BULLET_H
#define LOTOSTATEK_BULLET_H
#include "SFML/Graphics/Sprite.hpp"
#include "SFML/Graphics/Texture.hpp"
class Bullet {
struct Position {
int x;
int y;
};
#include "Projectile.h"
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;
};

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

13
headers/Heart.hpp Normal file
View File

@@ -0,0 +1,13 @@
#ifndef LOTOSTATEK_HEART_HPP
#define LOTOSTATEK_HEART_HPP
#include "SFML/Graphics/Texture.hpp"
#include "ObjectItem.hpp"
class Heart : public ObjectItem {
public:
Heart(float x, float y, sf::Texture &texture_);
void update() override;
};
#endif //LOTOSTATEK_HEART_HPP

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();
Meteor(float x, float y, sf::Texture &texture_);
void update();
// ~Meteor();
private:
sf::Texture meteorTexture;
sf::Sprite meteorSprite;
Position meteorPosition;
float meteorRotationSpeed;
float meteorSpeed;
bool outOfBounds;
static unsigned int counter;
};

25
headers/ObjectItem.hpp Normal file
View File

@@ -0,0 +1,25 @@
#ifndef LOTOSTATEK_OBJECTITEM_HPP
#define LOTOSTATEK_OBJECTITEM_HPP
#include "SFML/Graphics/Sprite.hpp"
#include "Position.h"
#include "SFML/Graphics/Texture.hpp"
class ObjectItem {
public:
virtual ~ObjectItem() = default;
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,121 @@
#ifndef PLANSZA_H
#define PLANSZA_H
#include "SFML/System/Clock.hpp"
#include "SFML/Graphics/RenderWindow.hpp"
#include "Meteor.h"
#include "RandomNumberGenerator.h"
#include "SFML/System/Clock.hpp"
#include "Enemy.h"
#include "AdvancedEnemy.h"
#include "Bomber.h"
#include "Kamikadze.h"
#include "Wiazkowiec.h"
#include "Player.h"
#include "Background.h"
#include "AudioManager.h"
#include "Plansza.h"
#include "Heart.hpp"
#include "PowerUp.h"
#include "Size.h"
#include "Boss.h"
enum ships{
nova,
pulsar,
zenith,
none
};
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, ships selectedShip);
Size getSize();
std::vector<Meteor> &getMeteors();
void spawn_meteor();
void spawn_hearts();
void spawn_power_up();
void update_meteors();
void update_hearts();
void update_power_ups();
void update();
void update_score();
void check_PowerUp_collisions();
void check_Heart_collisions();
void check_Meteor_collisions();
void spawn_player();
void spawn_enemy();
void spawn_advanced_enemy();
void spawn_wiazkowiec();
void spawn_boss();
void spawn_bomber();
void spawn_kamikadze();
~Plansza() {
delete ship;
delete boss;
}
static ships selectedShip;
static unsigned int score;
sf::Font font;
private:
std::vector<Meteor> meteors;
Background background;
AudioManager audioManager;
Player *ship;
Size size;
sf::RenderWindow *window;
sf::Clock meteorSpawnClock;
sf::Clock heartSpawnClock;
sf::Clock powerUpSpawnClock;
sf::Clock movingSpeedPUTimer;
sf::Clock fireratePUTimer;
sf::Clock tripleShotPUTimer;
sf::Clock spawnClock;
sf::Clock scoreClock;
sf::Clock shooterSpawnClock;
sf::Clock enemySpawnClock;
sf::Clock AenemySpawnClock;
sf::Clock BomberSpawnClock;
sf::Clock KamikadzeSpawnClock;
sf::Clock WiazkowiecSpawnClock;
sf::Texture playerTexture;
sf::Texture playerBulletTexture;
sf::Texture playerRocketTexture;
sf::Texture enemyTexture;
sf::Texture enemyBulletTexture;
sf::Texture advancedEnemyTexture;
sf::Texture BomberEnemyTexture;
sf::Texture BombaTexture;
sf::Texture BossTexture;
sf::Texture KamikadzeTexture;
sf::Texture WiazkowiecTexture;
sf::Texture WiazkaTexture;
sf::Texture meteorTexture1;
sf::Texture meteorTexture2;
sf::Clock spawnClock;
sf::Texture heartTexture;
sf::Texture heartTextureGray;
sf::Texture movingSpeedPowerUpTexture;
sf::Texture fireratePowerUpTexture;
sf::Texture tripleShotPowerUpTexture;
std::vector<Enemy> enemies;
std::vector<AdvancedEnemy> AEnemies;
std::vector<Bomber> BEnemies;
std::vector<Kamikadze> KEnemies;
std::vector<Wiazkowiec> WEnemies;
std::vector<Meteor> meteors;
std::vector<Heart> hearts;
std::vector<sf::Sprite> heartStats;
std::vector<PowerUp> powerUps;
Boss* boss = nullptr; // Wskaźnik na bossa
sf::Clock bossSpawnClock; // Zegar do spawnowania bossa
bool bossSpawned = false; // Flaga informująca, czy boss został już zespawnowany
bool gameOver = false;
unsigned int nextBossScoreThreshold = 1; // Próg punktowy dla spawnu bossa
};
#endif //PLANSZA_H

View File

@@ -3,11 +3,23 @@
#include <chrono>
#include <SFML/System/Clock.hpp>
#include "Actor.h"
#include "Rocket.h"
class Player : public Actor {
// Zgodnie z refactoring.guru singleton pattern
// https://refactoring.guru/design-patterns/singleton/cpp/example
protected:
Player(int x, int y, const sf::Texture &texture);
static Player* player_;
public:
Player(int x, int y, std::string path);
Player(Player &other) = delete;
void operator=(const Player &) = delete;
static Player* getInstance(int x, int y, const sf::Texture &texture);
// Tu się kończy definicja singletona
void shoot() override;
void alternate_shoot();
void setFirerate(unsigned int firerate);
@@ -16,10 +28,24 @@ public:
void moveRight() override;
void moveUp() override;
void moveDown() override;
void takeDamage();
void setTripleShot(bool toogle);
void update();
std::vector<Rocket>& getRockets();
void loadTexture();
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;
sf::Color originalColor;
sf::Clock immortalityClock; // Zegar kontrolujący czas nieśmiertelności
float immortalityDuration = 1.5f; // Czas trwania nieśmiertelności w sec
bool isImmortal = false; // flaga na immortal
bool tripleShot = false; // flaga na potrójny strzał
};

19
headers/Position.h Normal file
View File

@@ -0,0 +1,19 @@
#ifndef LOTOSTATEK_POSITION_H
#define LOTOSTATEK_POSITION_H
struct Position {
int x;
int y;
};
struct PositionU {
unsigned int x;
unsigned int y;
};
struct PositionF {
float x;
float y;
};
#endif //LOTOSTATEK_POSITION_H

25
headers/PowerUp.h Normal file
View File

@@ -0,0 +1,25 @@
#ifndef POWERUP_H
#define POWERUP_H
#include "ObjectItem.hpp"
class PowerUp : public ObjectItem {
public:
enum Type {
movingSpeedUp,
firerateUp,
tripleShotUp
};
PowerUp(float x, float y, sf::Texture &texture, Type type);
void update() override;
Type getType() const {
return type_;
}
private:
Type type_;
};
#endif //POWERUP_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

59
headers/Wiazkowiec.h Normal file
View File

@@ -0,0 +1,59 @@
#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, sf::RenderWindow *window);
void move(float deltaX, float deltaY) override;
void moveLeft() override;
void moveRight() override;
void moveUp() override;
void moveDown() override;
void takeDamage();
void setRandomDirection();
void checkIfBeamShootOutOfBounds();
void update();
void shoot() override;
void render(sf::RenderWindow &window);
bool isAlive() const;
bool isShooting() const;
void setPlanszaHeight(int height, int width);
Beam* getBeam() const;
private:
sf::Texture WiazkaTexture;
sf::Texture beamTexture;
sf::Clock shootClock;
sf::Clock shootingClock;
DirectionW direction = DirectionW::Down;
Beam *beam; // wskaźnik na wiązkę
sf::RenderWindow *window_ptr;
void spawnBeam(); // Tworzy wiązkę
int planszaHeight = 800;
int planszaWidth = 600;
float beamDuration = 1.0f;
float movementSpeed = 2.0f;
bool shooting = false;
bool alive = true;
};
#endif //WIAZKOWIEC_H

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