SDLPP: add constant rotation

This commit is contained in:
2023-04-08 20:19:22 +02:00
parent 5a0cb397b1
commit 9617499ab8
6 changed files with 35 additions and 4 deletions
+16
View File
@@ -291,6 +291,16 @@ void RenderObject::rotateClockwise( int angle ) {
void RenderObject::rotateCounterClockwise( int angle ) {
rotateClockwise( 360 - ( angle % 360 ) );
}
void RenderObject::setRotationSpeed(int speed) {
rotation_speed = speed;
}
void RenderObject::startRotation() {
rotating = true;
}
void RenderObject::stopRotation() {
rotating = false;
}
Vec2D< double > RenderObject::computeAlignmentAdditions() {
double x_addition = 0;
double y_addition = 0;
@@ -322,4 +332,10 @@ void RenderObject::updateXY() {
current = { original.getX() + additions.getX(),
original.getY() + additions.getY() };
}
void RenderObject::custom_move(int ticks) {
if(isRotating()) {
auto angle = ticks * rotation_speed / 1000; // tick = millisecond
rotateCounterClockwise(angle);
}
}
} // namespace SDLPP