remade the collision system
This commit is contained in:
+9
-23
@@ -3,22 +3,16 @@
|
||||
|
||||
#include <SFML/Graphics/CircleShape.hpp>
|
||||
#include <SFML/Graphics/Color.hpp>
|
||||
#include <SFML/Graphics/Rect.hpp>
|
||||
#include <SFML/Graphics/RectangleShape.hpp>
|
||||
#include <SFML/System/Vector2.hpp>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
#include "data.hpp"
|
||||
#include "globals.hpp"
|
||||
#include "scheduler.hpp"
|
||||
|
||||
enum class CollisionDir
|
||||
{
|
||||
None,
|
||||
Left,
|
||||
Right,
|
||||
Top,
|
||||
Bottom
|
||||
};
|
||||
class Entity;
|
||||
class Object;
|
||||
class Player;
|
||||
@@ -27,9 +21,6 @@ class Object
|
||||
{
|
||||
public:
|
||||
Object(ObjectData data);
|
||||
// CollisionDir find_intersection(Object& entity);
|
||||
float find_horizontal_difference_from_interesection(Object& entity);
|
||||
float find_intersection(Object &entity);
|
||||
sf::RectangleShape rect;
|
||||
};
|
||||
|
||||
@@ -53,30 +44,25 @@ class Player : public Entity
|
||||
: Entity(data),
|
||||
max_dash_acceleration(data.max_vertical_acceleration),
|
||||
max_vertical_acceleration(data.max_vertical_acceleration),
|
||||
gravity(gravity), _min_velocity(data.velocity) {};
|
||||
gravity(gravity) {};
|
||||
float max_vertical_acceleration;
|
||||
float max_dash_acceleration;
|
||||
float gravity;
|
||||
bool m_jumping { false };
|
||||
std::unique_ptr<Object> bounding_box;
|
||||
void initialize_bounding_box();
|
||||
void update_bounding_box();
|
||||
int check_bounding_box(
|
||||
std::array<std::array<std::unique_ptr<Object>, MAX_COLS>, MAX_ROWS>& tilemap);
|
||||
void handle_movment(Timer& dash, std::array<std::array<std::unique_ptr<Object>, 19>, 13> &tilemap);
|
||||
void handle_movment(Timer& dash,
|
||||
std::array<std::array<std::unique_ptr<Object>, 19>, 13>& tilemap);
|
||||
void handle_gravity();
|
||||
bool get_jumping();
|
||||
void horizontal_no_out_of_bounds();
|
||||
void vertical_no_out_of_bounds();
|
||||
// bool get_horizontal_collision(
|
||||
// std::array<std::array<std::unique_ptr<Object>, MAX_COLS>, MAX_ROWS>& tilemap);
|
||||
// bool get_vertical_top_collision(
|
||||
// std::array<std::array<std::unique_ptr<Object>, MAX_COLS>, MAX_ROWS>& tilemap);
|
||||
bool get_horizontal_collision(
|
||||
std::array<std::array<std::unique_ptr<Object>, MAX_COLS>, MAX_ROWS>& tilemap);
|
||||
bool get_vertical_collision(
|
||||
std::array<std::array<std::unique_ptr<Object>, MAX_COLS>, MAX_ROWS>& tilemap);
|
||||
// bool get_vertical_bottom_collision(
|
||||
// std::array<std::array<std::unique_ptr<Object>, MAX_COLS>, MAX_ROWS>& tilemap);
|
||||
|
||||
private:
|
||||
sf::Vector2f _min_velocity { 0, 0 };
|
||||
std::string direction;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user