prepared for explosion effects and added disintegrate sound fx

This commit is contained in:
Harrison Deng 2017-07-21 22:33:21 -05:00
parent 647b3b7d14
commit 7e1c955c8b
5 changed files with 26 additions and 2 deletions

Binary file not shown.

Binary file not shown.

View File

@ -132,6 +132,8 @@ public class Polyjet extends Game {
assetManager.load("void_circle.png", Texture.class); assetManager.load("void_circle.png", Texture.class);
assetManager.load("laser.ogg", Sound.class); assetManager.load("laser.ogg", Sound.class);
assetManager.load("explosion.ogg", Sound.class); assetManager.load("explosion.ogg", Sound.class);
assetManager.load("disintegrate.ogg", Sound.class);
assetManager.load("explosion-s.p", ParticleEffect.class);
} }
public void generateFonts() { public void generateFonts() {
initComplete = true; initComplete = true;

View File

@ -7,6 +7,8 @@ import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.assets.AssetManager; import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.graphics.g2d.ParticleEffectPool;
import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Pool; import com.badlogic.gdx.utils.Pool;
@ -26,6 +28,9 @@ public class EntityController {
public Array<Entity> activeAllies; public Array<Entity> activeAllies;
public Array<Entity> activeEnemies; public Array<Entity> activeEnemies;
//Particle pools;
ParticleEffectPool explosionEffectPool;
//Enemy pool declaration; //Enemy pool declaration;
private Pool<VoidCircle> voidCirclePool; private Pool<VoidCircle> voidCirclePool;
private Pool<Pellet> pelletPool; private Pool<Pellet> pelletPool;
@ -42,11 +47,13 @@ public class EntityController {
this.assets = assetManager; this.assets = assetManager;
this.prefs = preferences; this.prefs = preferences;
explosionEffectPool = new ParticleEffectPool(assets.get("explosion-s.p", ParticleEffect.class), 1, 64);
//Enemy pool initialization; //Enemy pool initialization;
voidCirclePool = new Pool<VoidCircle>() { voidCirclePool = new Pool<VoidCircle>() {
@Override @Override
protected VoidCircle newObject() { protected VoidCircle newObject() {
return new VoidCircle(assets.get("void_circle.png", Texture.class)); return new VoidCircle(assets.get("void_circle.png", Texture.class), assets.get("disintegrate.ogg", Sound.class), prefs);
} }
}; };

View File

@ -1,5 +1,7 @@
package zero1hd.polyjet.entity.enemies; package zero1hd.polyjet.entity.enemies;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.Batch;
@ -23,9 +25,15 @@ public class VoidCircle extends Actor implements Entity, Poolable {
private boolean begin; private boolean begin;
private Vector2 center; private Vector2 center;
private float maxTime; private float maxTime;
public VoidCircle(Texture voidTexture) { private Sound sound;
private Preferences prefs;
public VoidCircle(Texture voidTexture, Sound sound, Preferences prefs) {
hitBox = new Rectangle(); hitBox = new Rectangle();
center = new Vector2(); center = new Vector2();
this.sound = sound;
this.prefs = prefs;
voidCircleTexture = new Sprite(voidTexture); voidCircleTexture = new Sprite(voidTexture);
} }
@ -112,6 +120,13 @@ public VoidCircle(Texture voidTexture) {
@Override @Override
public void collided(Entity entity) { public void collided(Entity entity) {
switch (entity.getEntityType()) {
case LASER:
sound.play(prefs.getFloat("fx vol"));
break;
default:
break;
}
} }
@Override @Override