60 lines
2.3 KiB
C++
60 lines
2.3 KiB
C++
#ifndef SDLPP_HPP_LINE_RENDERER
|
|
#define SDLPP_HPP_LINE_RENDERER
|
|
|
|
#include "sdlpp_common.hpp"
|
|
#include "sdlpp_line.hpp"
|
|
#include "sdlpp_renderobject.hpp"
|
|
#include "sdlpp_vector.hpp"
|
|
|
|
namespace SDLPP {
|
|
class SDLPPSCOPE LineRenderer : public RenderObject {
|
|
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 );
|
|
LineRenderer( const Line< double > &line,
|
|
const std::shared_ptr< Renderer > &r );
|
|
LineRenderer( const Line< double > &line,
|
|
const std::shared_ptr< Renderer > &r,
|
|
const std::string &color );
|
|
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;
|
|
virtual void setPos( const Vec2D< double > &vec ) override;
|
|
virtual Vec2D< double > getPos() const override;
|
|
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;
|
|
virtual std::pair< Vec2D< double >, Vec2D< double > >
|
|
getDoubleRect() const override;
|
|
void setOutlineColor( const std::string & /*UNUSED*/ ) override {}
|
|
|
|
protected:
|
|
virtual void copyTo( std::shared_ptr< RenderObject > other ) override;
|
|
void updateXY();
|
|
Line< double > original = { { 0, 0 }, { 0, 0 } };
|
|
Line< double > current = { { 0, 0 }, { 0, 0 } };
|
|
Line< int > pixel_line = { { 0, 0 }, { 0, 0 } };
|
|
bool centerx = false;
|
|
SDL_Color _color;
|
|
};
|
|
} // end of namespace SDLPP
|
|
#endif
|