wiazkowiec strzela, gora dol
This commit is contained in:
25
headers/Beam.h
Normal file
25
headers/Beam.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#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 update();
|
||||
void render(sf::RenderWindow& window);
|
||||
|
||||
sf::FloatRect getBounds() const;
|
||||
|
||||
bool isVisible() const;
|
||||
void setVisible(bool visible);
|
||||
|
||||
|
||||
private:
|
||||
sf::RectangleShape beamShape;
|
||||
bool visible;
|
||||
};
|
||||
|
||||
#endif // LOTOSTATEK_BEAM_H
|
||||
@@ -6,6 +6,8 @@
|
||||
#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"
|
||||
@@ -44,6 +46,7 @@ private:
|
||||
sf::Texture meteorTexture1;
|
||||
sf::Texture meteorTexture2;
|
||||
sf::Texture enemyBulletTexture;
|
||||
sf::Texture WiazkaTexture;
|
||||
sf::Texture BombaTexture;
|
||||
sf::Texture playerTexture;
|
||||
sf::Texture playerBulletTexture;
|
||||
@@ -52,16 +55,19 @@ private:
|
||||
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;
|
||||
};
|
||||
|
||||
51
headers/Wiazkowiec.h
Normal file
51
headers/Wiazkowiec.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#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;
|
||||
|
||||
|
||||
private:
|
||||
sf::Clock shootClock;
|
||||
sf::Texture WiazkaTexture;
|
||||
float movementSpeed = 2.0f;
|
||||
bool alive = true;
|
||||
DirectionW direction = DirectionW::Down;
|
||||
Beam beam; // Wiązka
|
||||
bool shooting = false; // Czy obecnie strzela
|
||||
sf::Clock shootingClock; // Zegar kontrolujący czas strzału
|
||||
float beamDuration = 1.0f; // Czas trwania widoczności wiązki (w sekundach)
|
||||
|
||||
void spawnBeam(); // Tworzy wiązkę
|
||||
};
|
||||
|
||||
#endif //WIAZKOWIEC_H
|
||||
Reference in New Issue
Block a user