diff --git a/core/src/com/me/asteroids/Utils.java b/core/src/com/me/asteroids/Utils.java index a74f9a1..bbc6576 100644 --- a/core/src/com/me/asteroids/Utils.java +++ b/core/src/com/me/asteroids/Utils.java @@ -10,13 +10,15 @@ public final class Utils { private static final Vector2 tmp = new Vector2(); public static float rotate(float rotation, float degrees) { - rotation += degrees; - if (rotation < 0) { - rotation = 360 - rotation; - } else if (rotation > 360) { - rotation -= 360; - } - return rotation; + return wrapAngle(rotation + degrees); + } + + public static float wrapAngle(float degrees) { + if (degrees < 0) + return degrees + 360; + else if (degrees > 360) + return degrees - 360; + return degrees; } public static Vector2 setUnitVectorAngle(Vector2 vector, float degrees) {