summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch/asynk')
-rw-r--r--core/src/ch/asynk/tankontank/engine/gfx/animations/InfantryFireAnimation.java10
-rw-r--r--core/src/ch/asynk/tankontank/engine/gfx/animations/TankFireAnimation.java10
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java5
3 files changed, 13 insertions, 12 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/gfx/animations/InfantryFireAnimation.java b/core/src/ch/asynk/tankontank/engine/gfx/animations/InfantryFireAnimation.java
index 3ab8642..3327680 100644
--- a/core/src/ch/asynk/tankontank/engine/gfx/animations/InfantryFireAnimation.java
+++ b/core/src/ch/asynk/tankontank/engine/gfx/animations/InfantryFireAnimation.java
@@ -63,10 +63,10 @@ public class InfantryFireAnimation implements Disposable, Animation, Pool.Poolab
}
};
- public static InfantryFireAnimation get(float volume, float offset, float x0, float y0, float x1, float y1)
+ public static InfantryFireAnimation get(float volume, float x0, float y0, float x1, float y1, float halfWidth)
{
InfantryFireAnimation a = fireAnimationPool.obtain();
- a.set(volume, offset, x0, y0, x1, y1);
+ a.set(volume, x0, y0, x1, y1, halfWidth);
return a;
}
@@ -77,7 +77,7 @@ public class InfantryFireAnimation implements Disposable, Animation, Pool.Poolab
shots[i] = new Shot(new TextureRegion(FireAnimation.infantryFire.frames[0]));
}
- private void set(float volume, float offset, float _x0, float _y0, float _x1, float _y1)
+ private void set(float volume, float x0, float y0, float x1, float y1, float halfWidth)
{
this.volume = volume;
this.elapsed = 0f;
@@ -90,8 +90,8 @@ public class InfantryFireAnimation implements Disposable, Animation, Pool.Poolab
float y1 = (_y1 + ((SHOT_SCATTERING * FireAnimation.random.nextFloat()) - (SHOT_SCATTERING / 2f)));
double r = Math.atan2((y0 - y1), (x0 - x1));
- float xadj = (float) (Math.cos(r) * offset);
- float yadj = (float) (Math.sin(r) * offset);
+ float xadj = (float) (Math.cos(r) * halfWidth);
+ float yadj = (float) (Math.sin(r) * halfWidth);
x0 -= xadj;
y0 -= yadj;
diff --git a/core/src/ch/asynk/tankontank/engine/gfx/animations/TankFireAnimation.java b/core/src/ch/asynk/tankontank/engine/gfx/animations/TankFireAnimation.java
index a96bcc2..8411bac 100644
--- a/core/src/ch/asynk/tankontank/engine/gfx/animations/TankFireAnimation.java
+++ b/core/src/ch/asynk/tankontank/engine/gfx/animations/TankFireAnimation.java
@@ -53,10 +53,10 @@ public class TankFireAnimation implements Disposable, Animation, Pool.Poolable
}
};
- public static TankFireAnimation get(float volume, float offset, float x0, float y0, float x1, float y1)
+ public static TankFireAnimation get(float volume, float x0, float y0, float x1, float y1, float halfWidth)
{
TankFireAnimation a = fireAnimationPool.obtain();
- a.set(volume, offset, x0, y0, x1, y1);
+ a.set(volume, x0, y0, x1, y1, halfWidth);
return a;
}
@@ -65,7 +65,7 @@ public class TankFireAnimation implements Disposable, Animation, Pool.Poolable
this.fireRegion = new TextureRegion(FireAnimation.tankFire.frames[0]);
}
- private void set(float volume, float offset, float x0, float y0, float x1, float y1)
+ private void set(float volume, float x0, float y0, float x1, float y1, float halfWidth)
{
this.fired = false;
this.hit = false;
@@ -77,8 +77,8 @@ public class TankFireAnimation implements Disposable, Animation, Pool.Poolable
y1 += ((SHOT_SCATTERING * FireAnimation.random.nextFloat()) - (SHOT_SCATTERING / 2f));
double r = Math.atan2((y0 - y1), (x0 - x1));
- float xadj = (float) (Math.cos(r) * offset);
- float yadj = (float) (Math.sin(r) * offset);
+ float xadj = (float) (Math.cos(r) * halfWidth);
+ float yadj = (float) (Math.sin(r) * halfWidth);
x0 -= xadj;
y0 -= yadj;
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index f1d8420..5db9915 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -411,10 +411,11 @@ public abstract class Map extends Board
for (Unit u : activatedUnits) {
Hex from = u.getHex();
AnimationSequence seq = AnimationSequence.get(2);
+ float halfWidth = (u.getWidth() / 2f);
if (u.isA(Unit.UnitType.INFANTRY))
- seq.addAnimation(InfantryFireAnimation.get(ctrl.cfg.fxVolume, (u.getWidth() / 2.f), from.getX(), from.getY(), to.getX(), to.getY()));
+ seq.addAnimation(InfantryFireAnimation.get(ctrl.cfg.fxVolume, from.getX(), from.getY(), to.getX(), to.getY(), halfWidth));
else
- seq.addAnimation(TankFireAnimation.get(ctrl.cfg.fxVolume, (u.getWidth() / 2.f), from.getX(), from.getY(), to.getX(), to.getY()));
+ seq.addAnimation(TankFireAnimation.get(ctrl.cfg.fxVolume, from.getX(), from.getY(), to.getX(), to.getY(), halfWidth));
seq.addAnimation(notifyDoneAnimation(target));
addAnimation(seq);
}