2020-11-21 19:57:40 +00:00
|
|
|
#ifndef SDLPP_HPP_LINE_RENDERER
|
|
|
|
#define SDLPP_HPP_LINE_RENDERER
|
|
|
|
|
|
|
|
#include "sdlpp_common.hpp"
|
2021-03-12 21:33:46 +00:00
|
|
|
#include "sdlpp_line.hpp"
|
2020-11-21 19:57:40 +00:00
|
|
|
#include "sdlpp_renderobject.hpp"
|
2021-03-12 21:33:46 +00:00
|
|
|
#include "sdlpp_vector.hpp"
|
2020-11-21 19:57:40 +00:00
|
|
|
|
|
|
|
namespace SDLPP {
|
2020-11-22 22:37:55 +00:00
|
|
|
class SDLPPSCOPE LineRenderer : public RenderObject {
|
2020-11-21 19:57:40 +00:00
|
|
|
public:
|
|
|
|
LineRenderer() = delete;
|
|
|
|
virtual ~LineRenderer(){};
|
|
|
|
LineRenderer( double x1, double y1, double x2, double y2,
|
|
|
|
const std::shared_ptr< Renderer > &r );
|
|
|
|
LineRenderer( double x1, double y1, double x2, double y2,
|
|
|
|
const std::shared_ptr< Renderer > &r,
|
|
|
|
const std::string &color );
|
2021-03-13 17:36:29 +00:00
|
|
|
LineRenderer( const Line< double > &line,
|
2021-03-12 21:33:46 +00:00
|
|
|
const std::shared_ptr< Renderer > &r );
|
2021-03-13 17:36:29 +00:00
|
|
|
LineRenderer( const Line< double > &line,
|
2021-03-12 21:33:46 +00:00
|
|
|
const std::shared_ptr< Renderer > &r,
|
|
|
|
const std::string &color );
|
2020-11-21 19:57:40 +00:00
|
|
|
virtual void setColor( const std::string &color ) override;
|
|
|
|
virtual void specialAction( int /*UNUSED*/ ) override{};
|
|
|
|
virtual void render() override;
|
|
|
|
virtual void custom_move( int /*UNUSED*/ ) override {}
|
|
|
|
virtual void setPos( double x, double y ) override;
|
|
|
|
virtual void setPos( const std::pair< double, double > &pos ) override;
|
2021-03-13 17:36:29 +00:00
|
|
|
virtual void setPos( const Vec2D< double > &vec ) override;
|
|
|
|
virtual Vec2D< double > getPos() const override;
|
2020-11-21 19:57:40 +00:00
|
|
|
virtual int leftmost() override;
|
|
|
|
virtual int topmost() override;
|
|
|
|
virtual int rightmost() override;
|
|
|
|
virtual int bottommost() override;
|
|
|
|
virtual int collisionPushX() override;
|
|
|
|
virtual int collisionPushY() override;
|
|
|
|
virtual int collisionWidth() override;
|
|
|
|
virtual int collisionHeight() override;
|
|
|
|
virtual void updateSizeAndPosition() override;
|
|
|
|
virtual void centerX() override;
|
|
|
|
virtual std::shared_ptr< RenderObject > copySelf() override;
|
|
|
|
|
|
|
|
virtual SDL_Rect getRect() override;
|
2021-03-13 17:36:29 +00:00
|
|
|
virtual std::pair< Vec2D< double >, Vec2D< double > >
|
2020-11-21 19:57:40 +00:00
|
|
|
getDoubleRect() const override;
|
|
|
|
void setOutlineColor( const std::string & /*UNUSED*/ ) override {}
|
|
|
|
|
|
|
|
protected:
|
2021-03-13 17:36:29 +00:00
|
|
|
virtual void copyTo( std::shared_ptr< RenderObject > other ) override;
|
2020-11-21 19:57:40 +00:00
|
|
|
void updateXY();
|
2021-03-13 17:36:29 +00:00
|
|
|
Line< double > original = { { 0, 0 }, { 0, 0 } };
|
|
|
|
Line< double > current = { { 0, 0 }, { 0, 0 } };
|
|
|
|
Line< int > pixel_line = { { 0, 0 }, { 0, 0 } };
|
2020-11-21 19:57:40 +00:00
|
|
|
bool centerx = false;
|
2021-03-15 13:30:01 +00:00
|
|
|
SDL_Color _color;
|
2020-11-21 19:57:40 +00:00
|
|
|
};
|
|
|
|
} // end of namespace SDLPP
|
|
|
|
#endif
|