Files
engine/include/elements.hpp
T

42 lines
1.4 KiB
C++

#ifndef PLAYER_HPP
#define PLAYER_HPP
#include <SFML/Graphics/Color.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/System/Vector2.hpp>
#include "globals.hpp"
enum class CollisionDir { None, Left, Right, Top, Bottom };
class Entity {
public:
Entity(sf::Vector2<float> size, sf::Vector2<float> pos, sf::Vector2f velocity, float border_thickness, sf::Color inside_color = sf::Color::Black, sf::Color border_color = sf::Color::White);
CollisionDir find_intersection(Entity &entity);
void set_velocity(sf::Vector2f velocity);
void set_velocity_x(int velocity);
void set_velocity_y(int velocity);
sf::Vector2<float> get_velocity();
sf::RectangleShape rect;
protected:
sf::Vector2f _velocity;
sf::Color _inside_color;
sf::Color _border_color;
float _border_thickness;
};
class Player : public Entity {
public:
Player(sf::Vector2<float> size, sf::Vector2<float> pos, sf::Vector2f velocity, float border_thickness, float gravity, float max_acceleration, sf::Color inside_color, sf::Color border_color);
float m_acceleration;
float m_jump_strength;
bool m_jumping;
void handle_movment();
bool get_jumping();
void horizontal_no_out_of_bounds(Entity &base);
void vertical_no_out_of_bounds(Entity &base);
bool vertical_top_collision(Entity *wall_list[MAX_ROWS][MAX_COLS]);
bool vertical_bottom_collision(Entity *wall_list[MAX_ROWS][MAX_COLS]);
};
#endif