summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-12-29 10:33:01 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-12-29 10:33:01 +0100
commit89b7db7ccef38c37b96bb1b0693bda80f5ebfff0 (patch)
tree298d9645512a01e14ab8093ae58120d0a4d2a53f /core/src/ch/asynk/rustanddust
parent1f39ed07f64bc37d4869bca07c33b899f307d966 (diff)
downloadRustAndDust-89b7db7ccef38c37b96bb1b0693bda80f5ebfff0.zip
RustAndDust-89b7db7ccef38c37b96bb1b0693bda80f5ebfff0.tar.gz
TankFireAnimation: if no canAim -> go back to aiming 0 after fired
Diffstat (limited to 'core/src/ch/asynk/rustanddust')
-rw-r--r--core/src/ch/asynk/rustanddust/engine/gfx/animations/TankFireAnimation.java15
1 files changed, 14 insertions, 1 deletions
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 973c092..8e000be 100644
--- a/core/src/ch/asynk/rustanddust/engine/gfx/animations/TankFireAnimation.java
+++ b/core/src/ch/asynk/rustanddust/engine/gfx/animations/TankFireAnimation.java
@@ -40,6 +40,7 @@ public class TankFireAnimation implements Disposable, Animation, Pool.Poolable
private Moveable m;
private boolean aimed;
+ private boolean head_back;
private boolean fired;
private boolean hit;
private float elapsed;
@@ -72,7 +73,7 @@ public class TankFireAnimation implements Disposable, Animation, Pool.Poolable
private void set(float volume, Moveable m, float x0, float y0, float x1, float y1, float halfWidth)
{
this.m = m;
- this.aimed = !m.canAim();
+ this.aimed = false;
this.fired = false;
this.hit = false;
this.volume = volume;
@@ -124,6 +125,7 @@ public class TankFireAnimation implements Disposable, Animation, Pool.Poolable
this.explosion_frame = (FireAnimation.random.nextInt(FireAnimation.explosion.rows) * FireAnimation.explosion.cols);
// aiming
+ this.head_back = !this.m.canAim();
this.aim_r += (Orientation.SOUTH.r() - this.m.getRotation());
while (aim_r > 180) aim_r -= 360;
while(aim_r < -180) aim_r += 360;
@@ -166,6 +168,17 @@ public class TankFireAnimation implements Disposable, Animation, Pool.Poolable
FireAnimation.tankFireSndPlay(volume);
}
+ if (head_back) {
+ float r = m.getAiming();
+ float dr = delta * AIM_SPEED;
+ if (Math.abs(r) < dr) {
+ m.aimAt(0f);
+ head_back = false;
+ } else {
+ m.aimAt(r + ((r > 0) ? -dr : dr));
+ }
+ }
+
if (!hit && (elapsed < hit_time)) {
fire_w += (fire_dw * delta);
fire_x += (fire_dx * delta);