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
+7 -6
View File
@@ -28,15 +28,17 @@ void RenderObject::render() {
}
}
void RenderObject::setPos( double x, double y ) {
og_x = x;
og_y = y;
original = { x, 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 };
void RenderObject::setPos( const Vec2D<double> &vec ) {
setPos( vec.getX(), vec.getY() );
}
Vec2D< double > RenderObject::getPos() const {
return original;
}
bool RenderObject::colidesWith( const RenderObject &other ) const {
if ( !hasCollisions() || !other.hasCollisions() || getHidden() ||
@@ -161,8 +163,7 @@ void RenderObject::move( int ticks ) {
if ( std::isnan( addx ) || std::isnan( addy ) )
return;
og_x += addx;
og_y += addy;
original += { addx, addy };
custom_move( ticks );