Upload files to "/"
This commit is contained in:
parent
3a493c1485
commit
a0bda5cdac
3 changed files with 149 additions and 97 deletions
48
player.hpp
48
player.hpp
|
|
@ -1,33 +1,45 @@
|
|||
|
||||
#pragma once
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <vector>
|
||||
#include "platform.hpp"
|
||||
|
||||
|
||||
//float velocityY;
|
||||
//float gravity;
|
||||
//float jumpStrength;
|
||||
//bool isOnGround;
|
||||
|
||||
|
||||
class Player {
|
||||
sf::RectangleShape shape;
|
||||
float speed;
|
||||
float velocityY;
|
||||
float jumpStrength;
|
||||
bool onGround;
|
||||
float gravity;
|
||||
float groundLevel;
|
||||
bool facingRight;
|
||||
|
||||
private:
|
||||
sf::RectangleShape shape; // форма гравця
|
||||
float speed; //швидкість гравця
|
||||
float velocityY; // швидкість по вертикалі
|
||||
float jumpStrength; // сила стрибка
|
||||
bool onGround; //чи стоїть на землі
|
||||
float gravity; // сила гравітації
|
||||
float groundLevel; // висота "землі"
|
||||
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);
|
||||
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; }
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue