added collisions
This commit is contained in:
+10
-12
@@ -1,36 +1,34 @@
|
||||
#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, float thickness, sf::Color inside_color, sf::Color border_color);
|
||||
bool find_intersection(Entity &entity);
|
||||
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 top_left;
|
||||
float bottom_left;
|
||||
float top_right;
|
||||
float bottom_right;
|
||||
float border_thickness;
|
||||
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, float velocity_x, sf::Color inside_color, sf::Color border_color);
|
||||
sf::Vector2<float> m_velocity;
|
||||
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
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
#ifndef GLOBALS_HPP
|
||||
#define GLOBALS_HPP
|
||||
#define WIDTH 600
|
||||
#define HEIGHT 400
|
||||
#define WIDTH 608
|
||||
#define HEIGHT 416
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user