SDLPP: formatting, make compileable on Linux
This commit is contained in:
parent
d2cf54556e
commit
2f20661b5b
@ -3,7 +3,7 @@
|
||||
|
||||
namespace SDLPP {
|
||||
CircleColider::CircleColider( double x, double y, double rad )
|
||||
: CircleColider( { x, y }, rad ){};
|
||||
: CircleColider( { x, y }, rad ) {}
|
||||
|
||||
CircleColider::CircleColider( const Vec2D< double > ¢er, double rad )
|
||||
: CollisionPolygon( center ), original_rad( rad ) {}
|
||||
|
@ -65,7 +65,8 @@ void CircleRender::setOutlineColor( const std::string &color ) {
|
||||
|
||||
std::pair< Vec2D< double >, Vec2D< double > >
|
||||
CircleRender::getDoubleRect() const {
|
||||
return { { original.getX() - og_r, original.getY() - og_r }, { 2 * og_r, 2 * og_r } };
|
||||
return { { original.getX() - og_r, original.getY() - og_r },
|
||||
{ 2 * og_r, 2 * og_r } };
|
||||
}
|
||||
|
||||
int CircleRender::leftmost() {
|
||||
|
@ -11,16 +11,22 @@ class SDLPPSCOPE CircleRender : public RenderObject {
|
||||
public:
|
||||
CircleRender() = delete;
|
||||
virtual ~CircleRender(){};
|
||||
CircleRender( double x, double y, double rad, std::shared_ptr< Renderer > &r );
|
||||
CircleRender( double x, double y, double rad, std::shared_ptr< Renderer > &r,
|
||||
CircleRender( double x, double y, double rad,
|
||||
std::shared_ptr< Renderer > &r );
|
||||
CircleRender( double x, double y, double rad,
|
||||
std::shared_ptr< Renderer > &r,
|
||||
std::shared_ptr< Texture > &t );
|
||||
CircleRender( double x, double y, double rad, std::shared_ptr< Renderer > &r,
|
||||
CircleRender( double x, double y, double rad,
|
||||
std::shared_ptr< Renderer > &r,
|
||||
const std::string &img_or_color, bool is_polygon = false );
|
||||
|
||||
CircleRender( Vec2D<double> center, double rad, std::shared_ptr< Renderer > &r );
|
||||
CircleRender( Vec2D<double> center, double rad, std::shared_ptr< Renderer > &r,
|
||||
CircleRender( Vec2D< double > center, double rad,
|
||||
std::shared_ptr< Renderer > &r );
|
||||
CircleRender( Vec2D< double > center, double rad,
|
||||
std::shared_ptr< Renderer > &r,
|
||||
std::shared_ptr< Texture > &t );
|
||||
CircleRender( Vec2D<double> center, double rad, std::shared_ptr< Renderer > &r,
|
||||
CircleRender( Vec2D< double > center, double rad,
|
||||
std::shared_ptr< Renderer > &r,
|
||||
const std::string &img_or_color, bool is_polygon = false );
|
||||
virtual void setColor( const std::string &color ) override;
|
||||
virtual void setOutlineColor( const std::string &color ) override;
|
||||
|
@ -54,7 +54,8 @@ bool infinityIntersection( const SDLPP::CollisionPolygon &infinite,
|
||||
|
||||
bool intersects( const SDLPP::CollisionPolygon &p1,
|
||||
const SDLPP::CollisionPolygon &p2 ) {
|
||||
if(p1.rightmost() < p2.leftmost() || p2.rightmost() < p1.leftmost() || p1.bottommost() < p2.topmost() || p2.bottommost() < p1.topmost())
|
||||
if ( p1.rightmost() < p2.leftmost() || p2.rightmost() < p1.leftmost() ||
|
||||
p1.bottommost() < p2.topmost() || p2.bottommost() < p1.topmost() )
|
||||
return false;
|
||||
for ( auto &line : p1.getLines() ) {
|
||||
for ( auto &line2 : p2.getLines() ) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "sdlpp_common.hpp"
|
||||
#include "sdlpp_font.hpp"
|
||||
#include <memory>
|
||||
|
||||
namespace SDLPP {
|
||||
class SDLPPSCOPE FontConfiguration {
|
||||
|
@ -10,12 +10,10 @@ template<typename T>
|
||||
double vecDotProduct( const Vec2D< T > &a, const Vec2D< T > &b ) {
|
||||
return a * b;
|
||||
}
|
||||
template<typename T>
|
||||
double vecLengthSquared( const Vec2D<T> &vec ) {
|
||||
template < typename T > double vecLengthSquared( const Vec2D< T > &vec ) {
|
||||
return vecDotProduct( vec, vec );
|
||||
}
|
||||
template<typename T>
|
||||
double vecLength( const Vec2D<T> &vec ) {
|
||||
template < typename T > double vecLength( const Vec2D< T > &vec ) {
|
||||
return std::sqrt( vecLengthSquared( vec ) );
|
||||
}
|
||||
template < typename T >
|
||||
|
@ -6,8 +6,7 @@
|
||||
#include <iostream>
|
||||
|
||||
namespace SDLPP {
|
||||
template<typename T>
|
||||
class SDLPPSCOPE Line {
|
||||
template < typename T > class SDLPPSCOPE Line {
|
||||
public:
|
||||
Line() = delete;
|
||||
~Line() = default;
|
||||
@ -15,10 +14,11 @@ public:
|
||||
: _start( start ), _end( end ) {
|
||||
updateMost();
|
||||
}
|
||||
Line( T x_1, T y_1, T x_2, T y_2 )
|
||||
: Line( { x_1, y_1 }, { x_2, y_2 } ) {}
|
||||
Line( T x_1, T y_1, T x_2, T y_2 ) : Line( { x_1, y_1 }, { x_2, y_2 } ) {}
|
||||
Line( const Vec2D< T > &start, const Vec2D< T > &end, bool infinite )
|
||||
: Line( start, end ), _infinite( infinite ) {}
|
||||
: Line( start, end ) {
|
||||
_infinite = infinite;
|
||||
}
|
||||
Line( T x_1, T y_1, T x_2, T y_2, bool infinite )
|
||||
: Line( { x_1, y_1 }, { x_2, y_2 }, infinite ) {}
|
||||
Line( const Line &input ) : Line( input.getStart(), input.getEnd() ) {}
|
||||
|
@ -151,8 +151,10 @@ void LineRenderer::updateXY() {
|
||||
if ( width > height ) {
|
||||
auto multiplier =
|
||||
static_cast< double >( width ) / static_cast< double >( height );
|
||||
x1_ = original.getStart().getX() + static_cast< double >( multiplier - 1 ) / 2;
|
||||
x2_ = original.getEnd().getX() + static_cast< double >( multiplier - 1 ) / 2;
|
||||
x1_ = original.getStart().getX() +
|
||||
static_cast< double >( multiplier - 1 ) / 2;
|
||||
x2_ = original.getEnd().getX() +
|
||||
static_cast< double >( multiplier - 1 ) / 2;
|
||||
} else {
|
||||
x1_ = original.getStart().getX();
|
||||
x2_ = original.getEnd().getX();
|
||||
|
@ -139,9 +139,11 @@ void RectangleRender::updateSizeAndPosition() {
|
||||
rect.x = std::round( current.getX() * dimension );
|
||||
rect.y = std::round( current.getY() * dimension );
|
||||
rect.w =
|
||||
std::round( ( current.getX() + original_size.getX() ) * dimension ) - rect.x;
|
||||
std::round( ( current.getX() + original_size.getX() ) * dimension ) -
|
||||
rect.x;
|
||||
rect.h =
|
||||
std::round( ( current.getY() + original_size.getY() ) * dimension ) - rect.y;
|
||||
std::round( ( current.getY() + original_size.getY() ) * dimension ) -
|
||||
rect.y;
|
||||
if ( polygon )
|
||||
polygon->updateCollision( collisionPushX(), collisionPushY(),
|
||||
collisionWidth(), collisionHeight() );
|
||||
|
@ -32,31 +32,38 @@ public:
|
||||
const std::shared_ptr< Renderer > &r,
|
||||
const std::string &img, const SDL_Rect &source_rect );
|
||||
|
||||
RectangleRender( const Vec2D<double> &top_left, const Vec2D<double> &size,
|
||||
RectangleRender( const Vec2D< double > &top_left,
|
||||
const Vec2D< double > &size,
|
||||
const std::shared_ptr< Renderer > &r );
|
||||
RectangleRender( const Vec2D<double> &top_left, const Vec2D<double> &size,
|
||||
RectangleRender( const Vec2D< double > &top_left,
|
||||
const Vec2D< double > &size,
|
||||
const std::shared_ptr< Renderer > &r,
|
||||
const std::shared_ptr< Texture > &t, int source_x,
|
||||
int source_y, int source_width, int source_height );
|
||||
RectangleRender( const Vec2D<double> &top_left, const Vec2D<double> &size,
|
||||
RectangleRender( const Vec2D< double > &top_left,
|
||||
const Vec2D< double > &size,
|
||||
const std::shared_ptr< Renderer > &r,
|
||||
const std::shared_ptr< Texture > &t,
|
||||
const SDL_Rect &source_rect = { -1, -1, -1, -1 } );
|
||||
RectangleRender( const Vec2D<double> &top_left, const Vec2D<double> &size,
|
||||
RectangleRender( const Vec2D< double > &top_left,
|
||||
const Vec2D< double > &size,
|
||||
const std::shared_ptr< Renderer > &r,
|
||||
const std::string &img_or_color, bool is_polygon = false );
|
||||
RectangleRender( const Vec2D<double> &top_left, const Vec2D<double> &size,
|
||||
RectangleRender( const Vec2D< double > &top_left,
|
||||
const Vec2D< double > &size,
|
||||
const std::shared_ptr< Renderer > &r,
|
||||
const std::string &img, int source_x, int source_y,
|
||||
int source_width, int source_height );
|
||||
RectangleRender( const Vec2D<double> &top_left, const Vec2D<double> &size,
|
||||
RectangleRender( const Vec2D< double > &top_left,
|
||||
const Vec2D< double > &size,
|
||||
const std::shared_ptr< Renderer > &r,
|
||||
const std::string &img, const SDL_Rect &source_rect );
|
||||
virtual void setColor( const std::string &color ) override;
|
||||
virtual void setOutlineColor( const std::string &color ) override;
|
||||
virtual void specialAction( int /*UNUSED*/ ) override {}
|
||||
virtual void custom_move( int /*UNUSED*/ ) override {}
|
||||
virtual std::pair< Vec2D<double>, Vec2D<double> > getDoubleRect() const override;
|
||||
virtual std::pair< Vec2D< double >, Vec2D< double > >
|
||||
getDoubleRect() const override;
|
||||
virtual int leftmost() override;
|
||||
virtual int topmost() override;
|
||||
virtual int rightmost() override;
|
||||
|
@ -4,8 +4,7 @@
|
||||
#include "sdlpp_common.hpp"
|
||||
|
||||
namespace SDLPP {
|
||||
template<typename T>
|
||||
class SDLPPSCOPE Vec2D {
|
||||
template < typename T > class SDLPPSCOPE Vec2D {
|
||||
public:
|
||||
Vec2D() = default;
|
||||
~Vec2D() = default;
|
||||
@ -39,6 +38,7 @@ public:
|
||||
*this = *this - other;
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
T _x = 0.0;
|
||||
T _y = 0.0;
|
||||
@ -51,6 +51,6 @@ template<typename T>
|
||||
Vec2D< T > operator/( double divisor, const Vec2D< T > &vec ) {
|
||||
return vec / divisor;
|
||||
}
|
||||
}
|
||||
} // namespace SDLPP
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user