Motor de sprites/animacions/surfaces i jugador centrat (v0.2.0)
This commit is contained in:
1 parent
7bb1edd08a
commit
de5a670fdb
34 files changed
+16137
-81
No files matched your search
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include <SDL3/SDL.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "core/rendering/sprite/sprite.hpp"
|
||||
|
||||
class Surface;
|
||||
|
||||
class MovingSprite : public Sprite {
|
||||
public:
|
||||
MovingSprite();
|
||||
explicit MovingSprite(std::shared_ptr<Surface> surface);
|
||||
MovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos);
|
||||
MovingSprite(std::shared_ptr<Surface> surface, SDL_FRect pos, SDL_FlipMode flip);
|
||||
~MovingSprite() override = default;
|
||||
|
||||
void update(float delta_time) override;
|
||||
void render() override;
|
||||
void clear() override;
|
||||
|
||||
[[nodiscard]] auto getPosX() const -> float { return x_; }
|
||||
[[nodiscard]] auto getPosY() const -> float { return y_; }
|
||||
[[nodiscard]] auto getVelX() const -> float { return vx_; }
|
||||
[[nodiscard]] auto getVelY() const -> float { return vy_; }
|
||||
[[nodiscard]] auto getAccelX() const -> float { return ax_; }
|
||||
[[nodiscard]] auto getAccelY() const -> float { return ay_; }
|
||||
|
||||
void setPos(SDL_FRect rect);
|
||||
void setPos(float x, float y);
|
||||
void setPosX(float value);
|
||||
void setPosY(float value);
|
||||
void setVelX(float value) { vx_ = value; }
|
||||
void setVelY(float value) { vy_ = value; }
|
||||
void setAccelX(float value) { ax_ = value; }
|
||||
void setAccelY(float value) { ay_ = value; }
|
||||
|
||||
void setFlip(SDL_FlipMode flip) { flip_ = flip; }
|
||||
auto getFlip() -> SDL_FlipMode { return flip_; }
|
||||
void flip() { flip_ = (flip_ == SDL_FLIP_HORIZONTAL) ? SDL_FLIP_NONE : SDL_FLIP_HORIZONTAL; }
|
||||
|
||||
protected:
|
||||
void move(float delta_time);
|
||||
|
||||
float x_{0.0F};
|
||||
float y_{0.0F};
|
||||
float vx_{0.0F};
|
||||
float vy_{0.0F};
|
||||
float ax_{0.0F};
|
||||
float ay_{0.0F};
|
||||
SDL_FlipMode flip_{SDL_FLIP_NONE};
|
||||
};
|
||||
Reference in new issue
Block a user