SDLPP: CircleRenderer can be rendered
This commit is contained in:
@@ -1,6 +1,18 @@
|
||||
#include "sdlpp_renderobject.hpp"
|
||||
#include <cmath>
|
||||
|
||||
namespace SDLPP {
|
||||
void RenderObject::setPos( double x, double y ) {
|
||||
og_x = x;
|
||||
og_y = y;
|
||||
updateSizeAndPosition();
|
||||
}
|
||||
void RenderObject::setPos( const std::pair< double, double > &pos ) {
|
||||
setPos( pos.first, pos.second );
|
||||
}
|
||||
std::pair< double, double > RenderObject::getPos() const {
|
||||
return { og_x, og_y };
|
||||
}
|
||||
bool RenderObject::colidesWith( const RenderObject &other ) const {
|
||||
if ( !hasCollisions() || !other.hasCollisions() || getHidden() ||
|
||||
other.getHidden() ) {
|
||||
@@ -85,6 +97,25 @@ bool RenderObject::getKilled() {
|
||||
void RenderObject::setColiderColor( const std::string &color ) {
|
||||
colider_color = getColorsHEX( color );
|
||||
}
|
||||
void RenderObject::move( int ticks ) {
|
||||
if ( permanent )
|
||||
return;
|
||||
auto addx =
|
||||
static_cast< double >( movementSpeed * movementDirection.first ) *
|
||||
( static_cast< double >( ticks ) / 1000 );
|
||||
auto addy =
|
||||
static_cast< double >( movementSpeed * movementDirection.second ) *
|
||||
( static_cast< double >( ticks ) / 1000 );
|
||||
if ( std::isnan( addx ) || std::isnan( addy ) )
|
||||
return;
|
||||
|
||||
og_x += addx;
|
||||
og_y += addy;
|
||||
|
||||
custom_move( ticks );
|
||||
|
||||
updateSizeAndPosition();
|
||||
}
|
||||
void RenderObject::setPermanent( bool perm ) {
|
||||
permanent = perm;
|
||||
setStatic( perm );
|
||||
|
||||
Reference in New Issue
Block a user