SDLPP: add constant rotation
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user