diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-12-29 10:24:48 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-12-29 10:24:48 +0100 |
commit | c58f5d8be319f7d767679ac737d61f3895c52e58 (patch) | |
tree | 2e8a0fa0a5f168a74f641cef03ed9e1dfcc0ebb6 /core | |
parent | 5f2bda4fa467e415feaa243520b5d59c4f657789 (diff) | |
download | RustAndDust-c58f5d8be319f7d767679ac737d61f3895c52e58.zip RustAndDust-c58f5d8be319f7d767679ac737d61f3895c52e58.tar.gz |
HeadedPawn: setTurretRotation() -> aimAt(), getTurretRotation() -> getAiming()
Diffstat (limited to 'core')
4 files changed, 11 insertions, 12 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/HeadedPawn.java b/core/src/ch/asynk/rustanddust/engine/HeadedPawn.java index 9b4ed83..faecd6d 100644 --- a/core/src/ch/asynk/rustanddust/engine/HeadedPawn.java +++ b/core/src/ch/asynk/rustanddust/engine/HeadedPawn.java @@ -62,7 +62,7 @@ public abstract class HeadedPawn extends Pawn } @Override - public float getTurretRotation() + public float getAiming() { return turretR; } @@ -87,7 +87,7 @@ public abstract class HeadedPawn extends Pawn } @Override - public void setTurretRotation(float r) + public void aimAt(float r) { if (canAim()) { turretR = r; diff --git a/core/src/ch/asynk/rustanddust/engine/gfx/Moveable.java b/core/src/ch/asynk/rustanddust/engine/gfx/Moveable.java index b3f3541..55c0297 100644 --- a/core/src/ch/asynk/rustanddust/engine/gfx/Moveable.java +++ b/core/src/ch/asynk/rustanddust/engine/gfx/Moveable.java @@ -11,9 +11,9 @@ public interface Moveable extends Drawable public float getWidth(); public float getHeight(); public float getRotation(); - public float getTurretRotation(); + public float getAiming(); public void setPosition(float x, float y); public void setPosition(float x, float y, float r); - public void setTurretRotation(float r); + public void aimAt(float r); public Faction getFaction(); } diff --git a/core/src/ch/asynk/rustanddust/engine/gfx/animations/MoveToAnimation.java b/core/src/ch/asynk/rustanddust/engine/gfx/animations/MoveToAnimation.java index 1ae3f00..1f5ede5 100644 --- a/core/src/ch/asynk/rustanddust/engine/gfx/animations/MoveToAnimation.java +++ b/core/src/ch/asynk/rustanddust/engine/gfx/animations/MoveToAnimation.java @@ -89,7 +89,7 @@ public class MoveToAnimation extends TimedAnimation rDelta = (toR + 360 - fromR); } - aimDelta = moveable.getTurretRotation(); + aimDelta = moveable.getAiming(); aimed = (Math.abs(aimDelta) < 1f); } @@ -113,11 +113,11 @@ public class MoveToAnimation extends TimedAnimation } if (percent == 1f) { moveable.setPosition(toX, toY, (int) toR); - if (!aimed) moveable.setTurretRotation(0f); + if (!aimed) moveable.aimAt(0f); } else { moveable.setPosition(fromX + ((toX - fromX) * percent), fromY + ((toY - fromY) * percent), (fromR + (rDelta * percent))); - if (!aimed) moveable.setTurretRotation((aimDelta * (1f - percent))); + if (!aimed) moveable.aimAt((aimDelta * (1f - percent))); } } diff --git a/core/src/ch/asynk/rustanddust/engine/gfx/animations/TankFireAnimation.java b/core/src/ch/asynk/rustanddust/engine/gfx/animations/TankFireAnimation.java index ef23a6b..973c092 100644 --- a/core/src/ch/asynk/rustanddust/engine/gfx/animations/TankFireAnimation.java +++ b/core/src/ch/asynk/rustanddust/engine/gfx/animations/TankFireAnimation.java @@ -124,8 +124,7 @@ public class TankFireAnimation implements Disposable, Animation, Pool.Poolable this.explosion_frame = (FireAnimation.random.nextInt(FireAnimation.explosion.rows) * FireAnimation.explosion.cols); // aiming - this.aim_r += Orientation.SOUTH.r(); - this.aim_r -= this.m.getRotation(); + this.aim_r += (Orientation.SOUTH.r() - this.m.getRotation()); while (aim_r > 180) aim_r -= 360; while(aim_r < -180) aim_r += 360; } @@ -145,14 +144,14 @@ public class TankFireAnimation implements Disposable, Animation, Pool.Poolable public boolean animate(float delta) { if (!aimed) { - float r = m.getTurretRotation(); + float r = m.getAiming(); float d = (aim_r - r); float dr = delta * AIM_SPEED; if (Math.abs(d) < dr) { - m.setTurretRotation(aim_r); + m.aimAt(aim_r); aimed = true; } else { - m.setTurretRotation(r + ((d > 0) ? dr : -dr)); + m.aimAt(r + ((d > 0) ? dr : -dr)); } return false; } |