game/sdlpp/sdlpp_linerenderer.hpp

60 lines
2.3 KiB
C++
Raw Normal View History

2020-11-21 19:57:40 +00:00
#ifndef SDLPP_HPP_LINE_RENDERER
#define SDLPP_HPP_LINE_RENDERER
#include "sdlpp_common.hpp"
#include "sdlpp_line.hpp"
2020-11-21 19:57:40 +00:00
#include "sdlpp_renderobject.hpp"
#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 );
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 );
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;
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;
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:
virtual void copyTo( std::shared_ptr< RenderObject > other ) override;
2020-11-21 19:57:40 +00:00
void updateXY();
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