2020-11-21 19:57:40 +00:00
|
|
|
#ifndef SDLPP_HPP_RECT_RENDERER
|
|
|
|
#define SDLPP_HPP_RECT_RENDERER
|
|
|
|
|
|
|
|
#include "sdlpp_common.hpp"
|
|
|
|
#include "sdlpp_renderobject.hpp"
|
|
|
|
#include "sdlpp_rectcolider.hpp"
|
2020-12-18 15:02:02 +00:00
|
|
|
#include "sdlpp_circlecolider.hpp"
|
2020-11-21 19:57:40 +00:00
|
|
|
|
|
|
|
namespace SDLPP {
|
2020-11-22 22:37:55 +00:00
|
|
|
class SDLPPSCOPE RectangleRender : public RenderObject {
|
2020-11-21 19:57:40 +00:00
|
|
|
public:
|
|
|
|
RectangleRender() = delete;
|
|
|
|
virtual ~RectangleRender(){};
|
|
|
|
RectangleRender( double x, double y, double w, double h,
|
|
|
|
const std::shared_ptr< Renderer > &r );
|
|
|
|
RectangleRender( double x, double y, double w, double h,
|
|
|
|
const std::shared_ptr< Renderer > &r,
|
2021-03-07 12:06:08 +00:00
|
|
|
const std::shared_ptr< Texture > &t, int source_x,
|
|
|
|
int source_y, int source_width, int source_height );
|
|
|
|
RectangleRender( double x, double y, double w, double h,
|
|
|
|
const std::shared_ptr< Renderer > &r,
|
|
|
|
const std::shared_ptr< Texture > &t,
|
2021-03-07 13:06:55 +00:00
|
|
|
const SDL_Rect &source_rect = { -1, -1, -1, -1 } );
|
2020-11-21 19:57:40 +00:00
|
|
|
RectangleRender( double x, double y, double w, double h,
|
|
|
|
const std::shared_ptr< Renderer > &r,
|
|
|
|
const std::string &img_or_color, bool is_polygon = false );
|
2021-03-07 12:06:08 +00:00
|
|
|
RectangleRender( double x, double y, double w, double h,
|
|
|
|
const std::shared_ptr< Renderer > &r,
|
2021-03-07 13:06:55 +00:00
|
|
|
const std::string &img, int source_x, int source_y,
|
|
|
|
int source_width, int source_height );
|
2021-03-07 12:06:08 +00:00
|
|
|
RectangleRender( double x, double y, double w, double h,
|
|
|
|
const std::shared_ptr< Renderer > &r,
|
2021-03-07 13:06:55 +00:00
|
|
|
const std::string &img, const SDL_Rect &source_rect );
|
2021-03-12 21:33:46 +00:00
|
|
|
|
2021-03-13 17:36:29 +00:00
|
|
|
RectangleRender( const Vec2D< double > &top_left,
|
|
|
|
const Vec2D< double > &size,
|
2021-03-12 21:33:46 +00:00
|
|
|
const std::shared_ptr< Renderer > &r );
|
2021-03-13 17:36:29 +00:00
|
|
|
RectangleRender( const Vec2D< double > &top_left,
|
|
|
|
const Vec2D< double > &size,
|
2021-03-12 21:33:46 +00:00
|
|
|
const std::shared_ptr< Renderer > &r,
|
|
|
|
const std::shared_ptr< Texture > &t, int source_x,
|
|
|
|
int source_y, int source_width, int source_height );
|
2021-03-13 17:36:29 +00:00
|
|
|
RectangleRender( const Vec2D< double > &top_left,
|
|
|
|
const Vec2D< double > &size,
|
2021-03-12 21:33:46 +00:00
|
|
|
const std::shared_ptr< Renderer > &r,
|
|
|
|
const std::shared_ptr< Texture > &t,
|
|
|
|
const SDL_Rect &source_rect = { -1, -1, -1, -1 } );
|
2021-03-13 17:36:29 +00:00
|
|
|
RectangleRender( const Vec2D< double > &top_left,
|
|
|
|
const Vec2D< double > &size,
|
2021-03-12 21:33:46 +00:00
|
|
|
const std::shared_ptr< Renderer > &r,
|
|
|
|
const std::string &img_or_color, bool is_polygon = false );
|
2021-03-13 17:36:29 +00:00
|
|
|
RectangleRender( const Vec2D< double > &top_left,
|
|
|
|
const Vec2D< double > &size,
|
2021-03-12 21:33:46 +00:00
|
|
|
const std::shared_ptr< Renderer > &r,
|
|
|
|
const std::string &img, int source_x, int source_y,
|
|
|
|
int source_width, int source_height );
|
2021-03-13 17:36:29 +00:00
|
|
|
RectangleRender( const Vec2D< double > &top_left,
|
|
|
|
const Vec2D< double > &size,
|
2021-03-12 21:33:46 +00:00
|
|
|
const std::shared_ptr< Renderer > &r,
|
|
|
|
const std::string &img, const SDL_Rect &source_rect );
|
2020-11-21 19:57:40 +00:00
|
|
|
virtual void setColor( const std::string &color ) override;
|
|
|
|
virtual void setOutlineColor( const std::string &color ) override;
|
2021-03-07 12:06:08 +00:00
|
|
|
virtual void specialAction( int /*UNUSED*/ ) override {}
|
2020-11-21 19:57:40 +00:00
|
|
|
virtual void custom_move( int /*UNUSED*/ ) override {}
|
2021-03-13 17:36:29 +00:00
|
|
|
virtual std::pair< Vec2D< double >, Vec2D< double > >
|
|
|
|
getDoubleRect() 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 SDL_Rect getRect() override;
|
|
|
|
virtual std::shared_ptr< RenderObject > copySelf() override;
|
|
|
|
std::string getColor() const;
|
2021-05-02 12:03:26 +00:00
|
|
|
void setMinWidth( uint64_t width );
|
|
|
|
void setMinHeight( uint64_t height );
|
|
|
|
void setSize( Vec2D< double > size );
|
2020-11-21 19:57:40 +00:00
|
|
|
|
|
|
|
protected:
|
2021-03-07 12:06:08 +00:00
|
|
|
virtual void copyTo( std::shared_ptr< RenderObject > other ) override;
|
2021-03-13 17:36:29 +00:00
|
|
|
Vec2D< double > original_size;
|
|
|
|
Vec2D< double > size;
|
2020-11-21 19:57:40 +00:00
|
|
|
std::string color = "";
|
2021-05-02 12:03:26 +00:00
|
|
|
Vec2D< uint64_t > min_size = {0, 0};
|
2020-11-21 19:57:40 +00:00
|
|
|
};
|
|
|
|
} // end of namespace SDLPP
|
|
|
|
#endif
|