57 lines
2.0 KiB
C++
57 lines
2.0 KiB
C++
#ifndef SDLPP_HPP_COLLISION
|
|
#define SDLPP_HPP_COLLISION
|
|
|
|
#include "sdlpp_common.hpp"
|
|
#include "sdlpp_renderer.hpp"
|
|
#include "sdlpp_vector.hpp"
|
|
#include "sdlpp_line.hpp"
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
namespace SDLPP {
|
|
class SDLPPSCOPE CollisionPolygon {
|
|
public:
|
|
CollisionPolygon( double x, double y );
|
|
CollisionPolygon( const Vec2D< double > &input );
|
|
CollisionPolygon( double x, double y, uint64_t id );
|
|
CollisionPolygon( const Vec2D< double > &input, uint64_t id );
|
|
virtual ~CollisionPolygon() {}
|
|
virtual bool colidesWith( const CollisionPolygon &other ) const = 0;
|
|
virtual bool isCircle() const = 0;
|
|
virtual bool isInfinite() const;
|
|
virtual void setInfinite();
|
|
virtual int topmost() const = 0;
|
|
virtual int bottommost() const = 0;
|
|
virtual int leftmost() const = 0;
|
|
virtual int rightmost() const = 0;
|
|
virtual void updateCollision( int x, int y, int w, int h,
|
|
uint64_t objectId );
|
|
virtual void render( Renderer &renderer, const SDL_Color &color,
|
|
const SDL_Color &outline_color ) = 0;
|
|
virtual void render( Renderer &renderer, const SDL_Color &color ) = 0;
|
|
virtual void render( Renderer &renderer ) = 0;
|
|
int getX() const;
|
|
int getY() const;
|
|
void setColor( const std::string &color );
|
|
void setOutlineColor( const std::string &color );
|
|
virtual std::shared_ptr< CollisionPolygon > copySelf() = 0;
|
|
virtual std::vector< Line< int > > getLines() const = 0;
|
|
uint64_t getId();
|
|
void setId( uint64_t id );
|
|
|
|
protected:
|
|
Vec2D< double > original;
|
|
Vec2D< int > position;
|
|
bool infinite = false;
|
|
SDL_Color sdl_color = { 0, 0, 0, 0 };
|
|
SDL_Color sdl_outline = { 0, 0, 0, 0 };
|
|
uint64_t _id = -1;
|
|
};
|
|
|
|
SDLPPSCOPE bool infinityIntersection( const SDLPP::CollisionPolygon &infinite,
|
|
const SDLPP::CollisionPolygon &other );
|
|
SDLPPSCOPE bool intersects( const SDLPP::CollisionPolygon &p1,
|
|
const SDLPP::CollisionPolygon &p2 );
|
|
} // namespace SDLPP
|
|
#endif
|