Niby strzela, ale bez kolizji

This commit is contained in:
2024-12-09 17:36:57 +01:00
parent 44f4556fda
commit 13066709a7
10 changed files with 128 additions and 6 deletions

View File

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

View File

@@ -4,6 +4,13 @@
#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, std::string path);
@@ -14,12 +21,19 @@ public:
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

14
headers/EnemyBullet.h Normal file
View File

@@ -0,0 +1,14 @@
#ifndef ENEMY_BULLET_H
#define ENEMY_BULLET_H
#include "Projectile.h"
class EnemyBullet : public Projectile {
public:
EnemyBullet(float x, float y, sf::Texture &texture);
void update() override;
void setOutOfBounds(bool status);
};
#endif // ENEMY_BULLET_H

View File

@@ -25,6 +25,7 @@ public:
void update_meteors();
void update();
void spawn_enemy();
void setOutOfBounds(bool status);
private:
Size size;
Background background;