Dziuala 3 strzlowiec

This commit is contained in:
2024-12-10 20:20:05 +01:00
parent 77eb83c2c3
commit 81b04bae0f
12 changed files with 279 additions and 15 deletions

View File

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

38
headers/AdvancedEnemy.h Normal file
View File

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

@@ -13,7 +13,7 @@ enum class Direction {
class Enemy : public Actor {
public:
Enemy(int x, int y, std::string path);
Enemy(int x, int y, const sf::Texture& texture) ;
void shoot() override;
void move(float deltaX, float deltaY) override;

View File

@@ -3,10 +3,12 @@
#include "Meteor.h"
#include "Enemy.h"
#include "AdvancedEnemy.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"
@@ -16,7 +18,8 @@
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();
@@ -26,6 +29,9 @@ public:
void update();
void spawn_enemy();
void setOutOfBounds(bool status);
void spawn_advanced_enemy();
private:
Size size;
Background background;
@@ -33,10 +39,18 @@ private:
AudioManager audioManager;
sf::Texture meteorTexture1;
sf::Texture meteorTexture2;
sf::Texture enemyBulletTexture;
sf::Texture playerTexture;
sf::Texture playerBulletTexture;
sf::Texture playerRocketTexture;
sf::Texture enemyTexture;
sf::Texture advancedEnemyTexture;
sf::Clock spawnClock;
sf::Clock shooterSpawnClock;
std::vector<Enemy> enemies;
std::vector<AdvancedEnemy> AEnemies;
sf::Clock enemySpawnClock;
sf::Clock AenemySpawnClock;
std::vector<Meteor> meteors;
sf::RenderWindow *window;
};

View File

@@ -8,7 +8,8 @@
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);