35 lines
1.0 KiB
C++
35 lines
1.0 KiB
C++
#ifndef PLAYER_HPP
|
|
#define PLAYER_HPP
|
|
|
|
#include <SFML/Graphics/Color.hpp>
|
|
#include <SFML/Graphics/RectangleShape.hpp>
|
|
#include <SFML/System/Vector2.hpp>
|
|
|
|
|
|
enum class CollisionDir { None, Left, Right, Top, Bottom };
|
|
class Entity {
|
|
public:
|
|
Entity(sf::Vector2<float> size, sf::Vector2<float> starting_position, sf::Vector2f initial_velocity, float thickness, sf::Color inside_color, sf::Color border_color = sf::Color::White);
|
|
CollisionDir find_intersection(Entity &entity);
|
|
sf::Vector2f velocity;
|
|
sf::RectangleShape rect;
|
|
|
|
protected:
|
|
sf::Color _inside_color;
|
|
sf::Color _border_color;
|
|
float _border_thickness;
|
|
};
|
|
|
|
class Player : public Entity {
|
|
public:
|
|
Player(sf::Vector2<float> size, sf::Vector2<float> starting_position, float acceleration, float initial_acceleration, float thickness, sf::Vector2f initial_velocity, sf::Color inside_color, sf::Color border_color = sf::Color::White);
|
|
float m_acceleration;
|
|
float m_jump_strength;
|
|
bool m_jumping;
|
|
void handle_movment();
|
|
sf::Vector2<float> get_velocity();
|
|
bool get_jumping();
|
|
};
|
|
|
|
#endif
|