Dodane regulacja prędkości i płynejsze poruszanie się

This commit is contained in:
2024-11-16 15:22:21 +01:00
parent 88fa5901b6
commit a190e81ba2
7 changed files with 99 additions and 49 deletions
+4 -6
View File
@@ -30,12 +30,10 @@ public:
std::vector<Bullet>& getBullets();
void updateBullets() {
for (auto& bullet : bullets) {
if(bullet.getStatus()) {
bullets.erase(bullets.begin());
}
}
void updateBullets();
void setMovingSpeed(float speed) {
moving_speed = speed;
}
protected:
+2 -4
View File
@@ -1,9 +1,9 @@
#ifndef LOTOSTATEK_BULLET_H
#define LOTOSTATEK_BULLET_H
#include "SFML/Graphics/Sprite.hpp"
#include "SFML/Graphics/Texture.hpp"
class Bullet {
struct Position {
int x;
@@ -15,9 +15,7 @@ public:
void update();
sf::Sprite& getSprite();
void setSpeed(float speed);
bool getStatus() const {
return outOfBounds;
}
bool getStatus() const;
private:
sf::Sprite bulletSprite;
sf::Texture bulletTexture;
+8 -1
View File
@@ -7,8 +7,15 @@
class Player : public Actor {
public:
Player(int x, int y, std::string path);
void shoot();
void setFirerate(unsigned int firerate);
void move(float deltaX, float deltaY);
void moveLeft();
void moveRight();
void moveUp();
void moveDown();
private:
std::chrono::steady_clock::time_point lastShotTime = std::chrono::steady_clock::now();
};