45 lines
1.1 KiB
C++
45 lines
1.1 KiB
C++
#pragma once
|
|
#include <SFML/Graphics.hpp>
|
|
#include <vector>
|
|
#include "platform.hpp"
|
|
|
|
class Player {
|
|
sf::RectangleShape shape;
|
|
float speed;
|
|
float velocityY;
|
|
float jumpStrength;
|
|
bool onGround;
|
|
float gravity;
|
|
float groundLevel;
|
|
bool facingRight;
|
|
|
|
std::vector<sf::Texture> runFrames;
|
|
sf::Texture idleFrame;
|
|
sf::Sprite sprite;
|
|
|
|
size_t currentFrame;
|
|
float animationTimer;
|
|
float animationSpeed;
|
|
bool isMoving;
|
|
|
|
void loadRunAnimation();
|
|
void loadIdleFrame();
|
|
|
|
public:
|
|
Player();
|
|
|
|
void update(float deltaTime, const std::vector<Platform>& platforms);
|
|
void draw(sf::RenderWindow& window);
|
|
|
|
// Геттери
|
|
sf::RectangleShape& getShape() { return shape; }
|
|
float getVelocityY() const { return velocityY; }
|
|
bool isOnGround() const { return onGround; }
|
|
|
|
// Сеттери
|
|
void setPosition(const sf::Vector2f& pos) { shape.setPosition(pos); }
|
|
void setVelocityY(float v) { velocityY = v; }
|
|
void setOnGround(bool val) { onGround = val; }
|
|
|
|
bool isFacingRight() const { return facingRight; }
|
|
};
|