data driving walls
This commit is contained in:
+33
-14
@@ -3,25 +3,44 @@
|
||||
|
||||
#include "globals.hpp"
|
||||
#include "scheduler.hpp"
|
||||
#include "data.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;
|
||||
class Wall;
|
||||
class Player;
|
||||
|
||||
class Wall {
|
||||
public:
|
||||
Wall(ObjectData data);
|
||||
ObjectData data;
|
||||
sf::Vector2<float> size;
|
||||
sf::Vector2<float> pos;
|
||||
sf::Color interior_color;
|
||||
sf::Color exterior_color;
|
||||
float edge;
|
||||
|
||||
CollisionDir find_intersection(Entity& entity);
|
||||
sf::RectangleShape rect;
|
||||
};
|
||||
|
||||
class Entity {
|
||||
public:
|
||||
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);
|
||||
sf::Color inside_color = sf::Color::Black, sf::Color border_color = sf::Color::White);
|
||||
|
||||
CollisionDir find_intersection(Wall& 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:
|
||||
protected:
|
||||
sf::Vector2f _velocity;
|
||||
sf::Color _inside_color;
|
||||
sf::Color _border_color;
|
||||
@@ -29,26 +48,26 @@ class Entity {
|
||||
};
|
||||
|
||||
class Player : public Entity {
|
||||
public:
|
||||
public:
|
||||
Player(sf::Vector2<float> size, sf::Vector2<float> pos, sf::Vector2f velocity, float border_thickness,
|
||||
float gravity, float max_acceleration, float dash_distance, sf::Color inside_color,
|
||||
sf::Color border_color);
|
||||
float gravity, float max_acceleration, float dash_distance, sf::Color inside_color,
|
||||
|
||||
sf::Color border_color);
|
||||
float m_acceleration;
|
||||
float m_jump_strength;
|
||||
float m_dash_distance;
|
||||
bool m_jumping;
|
||||
bool m_dash;
|
||||
Times timers;
|
||||
void handle_movment();
|
||||
void handle_movment(Timer &dash);
|
||||
void handle_gravity();
|
||||
bool get_jumping();
|
||||
void horizontal_no_out_of_bounds(Entity& base);
|
||||
void horizontal_no_out_of_bounds();
|
||||
void vertical_no_out_of_bounds(Entity& base);
|
||||
bool get_horizontal_collision(std::array<std::array<Entity*, MAX_COLS>, MAX_ROWS>);
|
||||
bool get_vertical_top_collision(std::array<std::array<Entity*, MAX_COLS>, MAX_ROWS>);
|
||||
bool get_vertical_bottom_collision(std::array<std::array<Entity*, MAX_COLS>, MAX_ROWS>);
|
||||
bool get_horizontal_collision(std::array<std::array<Wall*, MAX_COLS>, MAX_ROWS>);
|
||||
bool get_vertical_top_collision(std::array<std::array<Wall*, MAX_COLS>, MAX_ROWS>);
|
||||
bool get_vertical_bottom_collision(std::array<std::array<Wall*, MAX_COLS>, MAX_ROWS>);
|
||||
|
||||
private:
|
||||
private:
|
||||
bool get_vertical_bottom_collision_by_offset(std::array<std::array<Entity*, MAX_COLS>, MAX_ROWS>);
|
||||
sf::Vector2f _min_velocity;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user