summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-11-27 15:35:48 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2014-11-27 15:35:48 +0100
commit655e19401debae60e029a4ceca41caeb52a80ad3 (patch)
tree17513a1c03ac84596e664636030cd236677cf56b
parent5d81af80867965dc5be81098ec0e6e8a740e0ce7 (diff)
downloadRustAndDust-655e19401debae60e029a4ceca41caeb52a80ad3.zip
RustAndDust-655e19401debae60e029a4ceca41caeb52a80ad3.tar.gz
ShotAnimation: use explosion sounds
-rw-r--r--core/src/ch/asynk/tankontank/engine/gfx/animations/ShotAnimation.java41
-rw-r--r--core/src/ch/asynk/tankontank/game/Map.java4
2 files changed, 29 insertions, 16 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/gfx/animations/ShotAnimation.java b/core/src/ch/asynk/tankontank/engine/gfx/animations/ShotAnimation.java
index 9d2257e..4a0130d 100644
--- a/core/src/ch/asynk/tankontank/engine/gfx/animations/ShotAnimation.java
+++ b/core/src/ch/asynk/tankontank/engine/gfx/animations/ShotAnimation.java
@@ -49,11 +49,14 @@ public class ShotAnimation implements Disposable, Animation, Pool.Poolable
private static final float EXPLOSION_FRAME_DURATION = 0.05f;
private static Random random = new Random();
- private static Sound shortShot;
- private static Sound longShot;
+ private static Sound shotSnd;
+ private static Sound shotSndLong;
+ private static Sound explosionSnd;
+ private static Sound explosionSndLong;
private static Sprites shot;
private static Sprites explosion;
- private static double longShotId;
+ private static double shotSndLongId;
+ private static double explosionSndLongId;
private TextureRegion shotRegion;
private float shot_a;
@@ -96,24 +99,30 @@ public class ShotAnimation implements Disposable, Animation, Pool.Poolable
return a;
}
- public static void init(Texture shot_texture, int scols, int srows, Texture explosion_texture, int ecols, int erows, Sound longSnd, Sound shortSnd)
+ public static void init(Texture shot_texture, int scols, int srows, Texture explosion_texture, int ecols, int erows, Sound ls, Sound ss, Sound le, Sound se)
{
- longShot = longSnd;
- shortShot = shortSnd;
+ shotSndLong = ls;
+ shotSnd = ss;
+ explosionSndLong = le;
+ explosionSnd = se;
shot = new Sprites(shot_texture, scols, srows);
explosion = new Sprites(explosion_texture, ecols, erows);
- longShotId = -1;
+ shotSndLongId = -1;
+ explosionSndLongId = -1;
}
public static void resetSound()
{
- longShotId = -1;
+ shotSndLongId = -1;
+ explosionSndLongId = -1;
}
public static void free()
{
- shortShot.dispose();
- longShot.dispose();
+ shotSnd.dispose();
+ shotSndLong.dispose();
+ explosionSnd.dispose();
+ explosionSndLong.dispose();
shot.texture.dispose();
explosion.texture.dispose();
}
@@ -197,10 +206,10 @@ public class ShotAnimation implements Disposable, Animation, Pool.Poolable
if (!fired) {
fired = true;
- if (longShotId == -1)
- longShotId = longShot.play(volume);
+ if (shotSndLongId == -1)
+ shotSndLongId = shotSndLong.play(volume);
else
- shortShot.play(volume);
+ shotSnd.play(volume);
}
if (!hit && (elapsed < hit_time)) {
@@ -213,8 +222,10 @@ public class ShotAnimation implements Disposable, Animation, Pool.Poolable
if (!hit) {
hit = true;
- // TODO hit sound
- shortShot.play(volume);
+ if (explosionSndLongId == -1)
+ explosionSndLongId = explosionSndLong.play(volume);
+ else
+ explosionSnd.play(volume);
}
if (elapsed < end_time) {
diff --git a/core/src/ch/asynk/tankontank/game/Map.java b/core/src/ch/asynk/tankontank/game/Map.java
index 9549938..0c42b8f 100644
--- a/core/src/ch/asynk/tankontank/game/Map.java
+++ b/core/src/ch/asynk/tankontank/game/Map.java
@@ -60,7 +60,9 @@ public abstract class Map extends Board
game.manager.get("data/shots.png", Texture.class), 1, 7,
game.manager.get("data/explosions.png", Texture.class), 16, 8,
game.manager.get("sounds/shot.mp3", Sound.class),
- game.manager.get("sounds/short_shot.mp3", Sound.class)
+ game.manager.get("sounds/short_shot.mp3", Sound.class),
+ game.manager.get("sounds/explosion.mp3", Sound.class),
+ game.manager.get("sounds/explosion_short.mp3", Sound.class)
);
setup();