Trying to switch to more object-oriented

This commit is contained in:
2021-03-12 22:33:46 +01:00
parent fbe122a5b9
commit 258ce51cfe
32 changed files with 693 additions and 249 deletions
+13 -15
View File
@@ -2,7 +2,9 @@
#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 {
@@ -14,6 +16,11 @@ public:
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;
@@ -21,7 +28,8 @@ public:
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 std::pair< double, double > getPos() const 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;
@@ -35,26 +43,16 @@ public:
virtual std::shared_ptr< RenderObject > copySelf() override;
virtual SDL_Rect getRect() override;
virtual std::pair< std::pair< double, double >,
std::pair< double, double > >
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();
double og_x1;
double og_y1;
double x1_;
double y1_;
double og_x2;
double og_y2;
double x2_;
double y2_;
int pixel_x1{};
int pixel_y1{};
int pixel_x2{};
int pixel_y2{};
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;
std::tuple< int, int, int, int > _color;
};