Compare commits
75 Commits
0e1b53fc9b
...
BossV1
| Author | SHA1 | Date | |
|---|---|---|---|
| ff562d4d92 | |||
| 898671a72a | |||
| 0ea80559e5 | |||
| 6a833f5698 | |||
| 2539892b71 | |||
| 17a1d3689b | |||
| 8b8bfc9aed | |||
| b833a21dbb | |||
| 2e02b17cc7 | |||
| 7d2b8bd9a2 | |||
| baced5f971 | |||
| 629b1279a9 | |||
| 62808a9fbf | |||
| 5ad7cc9d1e | |||
| 4d2283d15e | |||
| 236ddd828d | |||
| b1b5858fb6 | |||
| 3d83a3a767 | |||
| 6b45443c75 | |||
| 3e2d37cf72 | |||
| c4c83382c3 | |||
| 0a5a26208a | |||
| 76203a8b29 | |||
| 36984b859f | |||
| 15a8d82176 | |||
| 5459b97e74 | |||
| 94eddb457f | |||
| 9432cd94fe | |||
| 34424da9d6 | |||
| 80a4b1b397 | |||
| fdf67f4bc2 | |||
| 8b4b25747e | |||
| 3f4a937257 | |||
| d87143d98b | |||
| 1298bab79a | |||
| 9929a5dd40 | |||
| 87399213b3 | |||
| f1dc19e795 | |||
| 168ba2e477 | |||
| 38fd71b8e6 | |||
| 1c0e5d0293 | |||
| c898aa0d81 | |||
| b257837d18 | |||
| 17c372fad9 | |||
| 0c706625d2 | |||
| c1a24a701b | |||
| 41945b3d88 | |||
| 2234e4d973 | |||
| da33fcc718 | |||
| 74c739a09e | |||
| 81b04bae0f | |||
| 77eb83c2c3 | |||
| a81cf284d0 | |||
| 13066709a7 | |||
| 44f4556fda | |||
| c655409596 | |||
| e2e44ff1ba | |||
| 71f8ebe285 | |||
| 2f9e0ba236 | |||
| 3b637508e1 | |||
| b6830c305b | |||
| 087a8d7672 | |||
| 9d4af21d4d | |||
| 5eda245ccc | |||
| 72e2116dc7 | |||
| 7ecb90af1f | |||
| 29d3c11fd1 | |||
| 5ccb29f27b | |||
| 2341c2fa6d | |||
| 2f6c98f4be | |||
| d20fb3043b | |||
| fec3de86d3 | |||
| c7dbca9eb3 | |||
| 559d946cab | |||
| 6996490f3c |
@@ -19,14 +19,41 @@ add_executable(LotoStatek main.cpp
|
|||||||
sources/Bullet.cpp
|
sources/Bullet.cpp
|
||||||
headers/Meteor.h
|
headers/Meteor.h
|
||||||
sources/Meteor.cpp
|
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)
|
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")
|
# set(SFML_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/SFML/include")
|
||||||
file(GLOB BINARY_DEP_DLLS "${SFML_INCLUDE_DIR}/../bin/*.dll")
|
file(GLOB BINARY_DEP_DLLS "${SFML_INCLUDE_DIR}/../bin/*.dll")
|
||||||
file(COPY ${BINARY_DEP_DLLS} DESTINATION ${CMAKE_BINARY_DIR})
|
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
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules") # dodane
|
||||||
find_package(SFML 2.6.2 COMPONENTS graphics window system audio REQUIRED)
|
find_package(SFML 2.6.2 COMPONENTS graphics window system audio REQUIRED)
|
||||||
if(SFML_FOUND)
|
if(SFML_FOUND)
|
||||||
|
|||||||
12
README.md
@@ -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.
|
||||||
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
BIN
assets/img/boss/Boss.png
Normal file
|
After Width: | Height: | Size: 58 KiB |
BIN
assets/img/bullets/bomba.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
|
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 |
BIN
assets/img/bullets/enemy_bullet.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/img/bullets/old/bomba.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
assets/img/bullets/old/enemy_bullet.png
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
BIN
assets/img/enemy/advanced_enemy.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
assets/img/enemy/bomber.png
Normal file
|
After Width: | Height: | Size: 32 KiB |
BIN
assets/img/enemy/enemy.png
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
assets/img/enemy/kamikadze.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
assets/img/enemy/old/advanced_enemy.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
assets/img/enemy/old/bomber.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
assets/img/enemy/old/enemy.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
assets/img/enemy/old/kamikadze.png
Normal file
|
After Width: | Height: | Size: 6.1 KiB |
BIN
assets/img/enemy/old/wiazkowiec.png
Normal file
|
After Width: | Height: | Size: 7.9 KiB |
BIN
assets/img/enemy/wiazkowiec.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
assets/img/hearts/heart.png
Normal file
|
After Width: | Height: | Size: 782 B |
BIN
assets/img/hearts/heart_gray.png
Normal file
|
After Width: | Height: | Size: 958 B |
|
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 |
BIN
assets/img/powerups/TripleShotPU.png
Normal file
|
After Width: | Height: | Size: 9.3 KiB |
BIN
assets/img/powerups/fireratePU.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
assets/img/powerups/movingSpeedPU.png
Normal file
|
After Width: | Height: | Size: 7.0 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 |
BIN
assets/img/wiazka/laser.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 773 B |
BIN
assets/ship/nova.png
Normal file
|
After Width: | Height: | Size: 154 KiB |
BIN
assets/ship/pulsar.png
Normal file
|
After Width: | Height: | Size: 188 KiB |
BIN
assets/ship/zenith.png
Normal file
|
After Width: | Height: | Size: 221 KiB |
@@ -4,21 +4,19 @@
|
|||||||
#include "SFML/Graphics/Sprite.hpp"
|
#include "SFML/Graphics/Sprite.hpp"
|
||||||
#include "SFML/Graphics/Texture.hpp"
|
#include "SFML/Graphics/Texture.hpp"
|
||||||
#include "Bullet.h"
|
#include "Bullet.h"
|
||||||
|
#include "Position.h"
|
||||||
|
#include "SFML/System/Clock.hpp"
|
||||||
|
|
||||||
struct Position {
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Actor {
|
class Actor {
|
||||||
public:
|
public:
|
||||||
Actor(int x, int y, std::string path);
|
Actor(int x, int y, const sf::Texture& texture);
|
||||||
|
virtual ~Actor() = default;
|
||||||
void loadTexture(std::string path);
|
|
||||||
|
|
||||||
sf::Sprite& getSprite();
|
sf::Sprite& getSprite();
|
||||||
|
unsigned int getHP();
|
||||||
Position getPosition();
|
Position getPosition();
|
||||||
|
std::vector<Bullet>& getBullets();
|
||||||
|
|
||||||
virtual void move(float deltaX, float deltaY) = 0;
|
virtual void move(float deltaX, float deltaY) = 0;
|
||||||
virtual void moveLeft() = 0;
|
virtual void moveLeft() = 0;
|
||||||
@@ -27,23 +25,23 @@ public:
|
|||||||
virtual void moveDown() = 0;
|
virtual void moveDown() = 0;
|
||||||
virtual void shoot() = 0;
|
virtual void shoot() = 0;
|
||||||
|
|
||||||
std::vector<Bullet>& getBullets();
|
|
||||||
|
|
||||||
void updateBullets();
|
void updateBullets();
|
||||||
|
|
||||||
void setMovingSpeed(float speed);
|
void setMovingSpeed(float speed);
|
||||||
|
void dealDamage();
|
||||||
|
void healUP();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Position position;
|
||||||
sf::Sprite actorSprite;
|
sf::Sprite actorSprite;
|
||||||
sf::Texture actorTexture;
|
sf::Texture actorTexture;
|
||||||
sf::Texture bulletTextureLeft;
|
sf::Texture bulletTexture;
|
||||||
sf::Texture bulletTextureRight;
|
sf::Texture rocketTexture;
|
||||||
Position position;
|
std::vector<Bullet> bullets;
|
||||||
unsigned int hp;
|
sf::Clock damageDealClock;
|
||||||
|
int hp;
|
||||||
unsigned int damage;
|
unsigned int damage;
|
||||||
unsigned int firerate;
|
unsigned int firerate;
|
||||||
float moving_speed;
|
float moving_speed;
|
||||||
std::vector<Bullet> bullets;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //ACTOR_H
|
#endif //ACTOR_H
|
||||||
|
|||||||
37
headers/AdvancedEnemy.h
Normal 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
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
class AudioManager {
|
class AudioManager {
|
||||||
public:
|
public:
|
||||||
|
AudioManager() = default;
|
||||||
bool loadBackgroundMusic(const std::string& filePath);
|
bool loadBackgroundMusic(const std::string& filePath);
|
||||||
void playBackgroundMusic(float volume = 50.f, bool loop = true);
|
void playBackgroundMusic(float volume = 50.f, bool loop = true);
|
||||||
void stopBackgroundMusic();
|
void stopBackgroundMusic();
|
||||||
|
|||||||
18
headers/Beam.h
Normal 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
@@ -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
@@ -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
|
||||||
@@ -1,27 +1,12 @@
|
|||||||
#ifndef LOTOSTATEK_BULLET_H
|
#ifndef LOTOSTATEK_BULLET_H
|
||||||
#define 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:
|
public:
|
||||||
Bullet(float x, float y, sf::Texture &texture);
|
Bullet(float x, float y, sf::Texture &texture) : Projectile(x,y, texture) {};
|
||||||
sf::Sprite &getSprite();
|
void update() override;
|
||||||
void setSpeed(float speed);
|
|
||||||
bool getStatus() const;
|
|
||||||
void update();
|
|
||||||
private:
|
|
||||||
sf::Sprite bulletSprite;
|
|
||||||
sf::Texture bulletTexture;
|
|
||||||
Position bulletPosition;
|
|
||||||
float bulletSpeed;
|
|
||||||
bool outOfBounds;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
39
headers/Enemy.h
Normal 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
@@ -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
@@ -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
|
||||||
@@ -3,27 +3,13 @@
|
|||||||
|
|
||||||
#include "SFML/Graphics/Texture.hpp"
|
#include "SFML/Graphics/Texture.hpp"
|
||||||
#include "SFML/Graphics/Sprite.hpp"
|
#include "SFML/Graphics/Sprite.hpp"
|
||||||
|
#include "Position.h"
|
||||||
|
#include "ObjectItem.hpp"
|
||||||
|
|
||||||
class Meteor {
|
class Meteor : public ObjectItem {
|
||||||
struct Position {
|
|
||||||
int x;
|
|
||||||
int y;
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Meteor(float x, float y, sf::Texture &texture);
|
Meteor(float x, float y, sf::Texture &texture_);
|
||||||
sf::Sprite &getSprite();
|
|
||||||
bool getStatus();
|
|
||||||
void update();
|
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
@@ -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
|
||||||
@@ -1,28 +1,121 @@
|
|||||||
#ifndef PLANSZA_H
|
#ifndef PLANSZA_H
|
||||||
#define PLANSZA_H
|
#define PLANSZA_H
|
||||||
|
|
||||||
|
#include "SFML/System/Clock.hpp"
|
||||||
|
#include "SFML/Graphics/RenderWindow.hpp"
|
||||||
|
|
||||||
#include "Meteor.h"
|
#include "Meteor.h"
|
||||||
#include "RandomNumberGenerator.h"
|
#include "Enemy.h"
|
||||||
#include "SFML/System/Clock.hpp"
|
#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 {
|
class Plansza {
|
||||||
struct Size {
|
|
||||||
int height;
|
|
||||||
int width;
|
|
||||||
};
|
|
||||||
public:
|
public:
|
||||||
Plansza(unsigned int windowHeight, unsigned int windowWidth);
|
Plansza(unsigned int windowHeight, unsigned int windowWidth, sf::RenderWindow *mainWindow, ships selectedShip);
|
||||||
void spawn_meteor();
|
|
||||||
Size getSize();
|
Size getSize();
|
||||||
std::vector<Meteor> &getMeteors();
|
std::vector<Meteor> &getMeteors();
|
||||||
|
void spawn_meteor();
|
||||||
|
void spawn_hearts();
|
||||||
|
void spawn_power_up();
|
||||||
void update_meteors();
|
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:
|
private:
|
||||||
std::vector<Meteor> meteors;
|
Background background;
|
||||||
|
AudioManager audioManager;
|
||||||
|
Player *ship;
|
||||||
Size size;
|
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 meteorTexture1;
|
||||||
sf::Texture meteorTexture2;
|
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
|
#endif //PLANSZA_H
|
||||||
|
|||||||
@@ -3,11 +3,23 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <SFML/System/Clock.hpp>
|
||||||
|
|
||||||
#include "Actor.h"
|
#include "Actor.h"
|
||||||
|
#include "Rocket.h"
|
||||||
|
|
||||||
class Player : public Actor {
|
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:
|
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 shoot() override;
|
||||||
void alternate_shoot();
|
void alternate_shoot();
|
||||||
void setFirerate(unsigned int firerate);
|
void setFirerate(unsigned int firerate);
|
||||||
@@ -16,10 +28,24 @@ public:
|
|||||||
void moveRight() override;
|
void moveRight() override;
|
||||||
void moveUp() override;
|
void moveUp() override;
|
||||||
void moveDown() override;
|
void moveDown() override;
|
||||||
|
void takeDamage();
|
||||||
|
void setTripleShot(bool toogle);
|
||||||
|
|
||||||
|
void update();
|
||||||
|
std::vector<Rocket>& getRockets();
|
||||||
|
|
||||||
|
void loadTexture();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::chrono::steady_clock::time_point lastShotTime = std::chrono::steady_clock::now();
|
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
|
||||||