#ifndef PLAYER_HPP #define PLAYER_HPP #include "data.hpp" #include "globals.hpp" #include "scheduler.hpp" #include #include #include #include enum class CollisionDir { None, Left, Right, Top, Bottom }; class Entity; class Object; class Player; class Object { public: Object(ObjectData data); CollisionDir find_intersection(Object& entity); sf::RectangleShape rect; }; class Entity : public Object { public: Entity(EntityData data) : Object(data), _velocity(data.velocity) {}; void set_velocity(sf::Vector2f velocity); void set_velocity_x(int velocity); void set_velocity_y(int velocity); sf::Vector2 get_velocity(); protected: sf::Vector2f _velocity; }; class Player : public Entity { public: Player(PlayerData data, float gravity) : Entity(data), dash_length(data.dash_length), max_vertical_acceleration(data.max_vertical_acceleration), gravity(gravity) {}; float max_vertical_acceleration; float dash_length; float gravity; bool m_jumping { false }; bool m_dash { false }; sf::RectangleShape bounding_box { { 0, 100 } }; void initialize_bounding_box(); void update_bounding_box(); void check_bounding_box(std::array, MAX_ROWS> wall_list); void handle_movment(Timer& dash); void handle_gravity(); bool get_jumping(); void horizontal_no_out_of_bounds(); void vertical_no_out_of_bounds(Entity& base); bool get_horizontal_collision(std::array, MAX_ROWS>); bool get_vertical_top_collision(std::array, MAX_ROWS>); bool get_vertical_bottom_collision(std::array, MAX_ROWS>); private: bool get_vertical_bottom_collision_by_offset(std::array, MAX_ROWS>); sf::Vector2f _min_velocity { 0, 0 }; }; #endif