Merge remote-tracking branch 'origin/5PrzeciwnikowWmiareDziala'
# Conflicts: # headers/Plansza.h # sources/Plansza.cpp
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
|
||||
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
39
headers/AdvancedEnemy.h
Normal 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
|
||||
29
headers/Beam.h
Normal file
29
headers/Beam.h
Normal 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
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
|
||||
@@ -8,6 +8,8 @@ class Bullet : public Projectile {
|
||||
public:
|
||||
Bullet(float x, float y, sf::Texture &texture) : Projectile(x,y, texture) {};
|
||||
void update() override;
|
||||
private:
|
||||
float directionY;
|
||||
};
|
||||
|
||||
|
||||
|
||||
39
headers/Enemy.h
Normal file
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
|
||||
46
headers/Kamikadze.h
Normal file
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
|
||||
@@ -1,27 +1,37 @@
|
||||
#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 "Meteor.h"
|
||||
#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 "Meteor.h"
|
||||
#include "Plansza.h"
|
||||
#include "Size.h"
|
||||
|
||||
class Plansza {
|
||||
public:
|
||||
Plansza(unsigned int windowHeight,unsigned int windowWidth, sf::RenderWindow *mainWindow);
|
||||
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 update_score();
|
||||
void spawn_enemy();
|
||||
void setOutOfBounds(bool status);
|
||||
void spawn_advanced_enemy();
|
||||
void spawn_wiazkowiec();
|
||||
void spawn_bomber();
|
||||
void spawn_kamikadze();
|
||||
private:
|
||||
Size size;
|
||||
Background background;
|
||||
@@ -29,8 +39,30 @@ private:
|
||||
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 scoreClock;
|
||||
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;
|
||||
sf::Font font;
|
||||
|
||||
@@ -3,12 +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);
|
||||
@@ -17,12 +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<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
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ class Rocket : public Projectile{
|
||||
public:
|
||||
Rocket(float x, float y, sf::Texture &texture) : Projectile(x,y, texture) {};
|
||||
void update() override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
54
headers/Wiazkowiec.h
Normal file
54
headers/Wiazkowiec.h
Normal 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
|
||||
Reference in New Issue
Block a user