added comments; removed collision detector vfx and sfx

This commit is contained in:
Harrison Deng 2018-01-17 23:07:07 -06:00
parent 439307d619
commit 8f0eedd1c5
4 changed files with 11 additions and 53 deletions

View File

@ -4,14 +4,8 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
import com.badlogic.gdx.graphics.g2d.ParticleEffectPool;
import com.badlogic.gdx.graphics.g2d.ParticleEffectPool.PooledEffect;
import com.badlogic.gdx.utils.Array;
import zero1hd.rhythmbullet.RhythmBullet;
public class CollisionDetector {
Array<Entity> enemies;
Array<Entity> allies;
@ -19,10 +13,6 @@ public class CollisionDetector {
AssetManager assets;
Preferences prefs;
//Particle pools;
ParticleEffectPool explosionEffectPool;
Array<PooledEffect> effects = new Array<>();
private int amassedPoints;
Sound explosionSFX;
public CollisionDetector(Array<Entity> enemies, Array<Entity> allies, AssetManager assetManager, Preferences prefs) {
@ -31,8 +21,6 @@ public class CollisionDetector {
assets = assetManager;
this.prefs = prefs;
explosionEffectPool = new ParticleEffectPool(assets.get("explosion-s.p", ParticleEffect.class), 1, 64);
explosionSFX = assets.get("explosion.ogg", Sound.class);
}
public void collisionCheck() {
@ -46,17 +34,6 @@ public class CollisionDetector {
if (enemy.getHitZone().overlaps(ally.getHitZone())) {
Gdx.app.debug("Collision Detector", "Collision between entities: " + enemy.getClass().getSimpleName() + " and " + ally.getClass().getSimpleName());
//Play FX;
if (ally.playCollideSFX() && enemy.playCollideSFX()) {
explosionSFX.play(prefs.getFloat("fx vol")/100f, 1f, (enemy.getX()/RhythmBullet.GAME_AREA_WIDTH));
}
if (ally.playCollidePFX() && enemy.playCollidePFX()) {
PooledEffect currentPFX;
currentPFX = explosionEffectPool.obtain();
currentPFX.setPosition(ally.getX() + ally.getWidth()/2f, ally.getY() + ally.getHeight()/2f);
effects.add(currentPFX);
}
enemy.collided(ally);
ally.collided(enemy);
@ -71,28 +48,6 @@ public class CollisionDetector {
}
/**
* draws the explosion particles where necessary.
* @param batch the batch used to draw the said particles
* @param cleanBatch whether this method should call begin and end on the batch.
*/
public void renderParticles(Batch batch, float delta, boolean cleanBatch) {
if (cleanBatch) {
batch.begin();
}
for (int i = 0; i < effects.size; i++) {
effects.get(i).draw(batch, delta);
if (effects.get(i).isComplete()) {
effects.get(i).free();
effects.removeIndex(i);
}
}
if (cleanBatch) {
batch.end();
}
}
public int getAmassedPoints() {
int amassedPoints = this.amassedPoints;
this.amassedPoints = 0;

View File

@ -125,14 +125,6 @@ public class Entity extends Actor implements Poolable {
super.draw(batch, parentAlpha);
}
public boolean playCollidePFX() {
return true;
}
public boolean playCollideSFX() {
return true;
}
public void move(float delta, boolean update) {
rotRatios.set(MathUtils.cosDeg(angle), MathUtils.sinDeg(angle));
moveBy(rotRatios.x*speed*delta, rotRatios.y*speed*delta);

View File

@ -5,6 +5,11 @@ import com.badlogic.gdx.utils.Pool.Poolable;
import zero1hd.rhythmbullet.entity.Entity;
import zero1hd.rhythmbullet.entity.EntityManager;
/**
* Coordinator coordinates movement of an entity. Movement can range from basic pre-determined to more advanced (with condition based behavior).
* @author Yunyang
*
*/
public class Coordinator implements Poolable {
private CoordinatorFrame<? extends Coordinator> cf;
protected EntityManager em;

View File

@ -9,6 +9,12 @@ public class CoordinatorFrame<T extends Coordinator> {
private EntityManager em;
CoordinatorFrame<T> cf;
Class<T> coordinatorType;
/**
* Similar to an entityFrame, however this time, for a coordinator.
* @param entityManager
* @param classtype
*/
public CoordinatorFrame(EntityManager entityManager, Class<T> classtype) {
this.em = entityManager;
coordinatorType = classtype;