reworked the entity framework (still in progress)
This commit is contained in:
		@@ -1,26 +1,25 @@
 | 
				
			|||||||
package zero1hd.polyjet.audio.map;
 | 
					package zero1hd.polyjet.audio.map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import zero1hd.polyjet.entity.Entities;
 | 
					import java.util.HashMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import zero1hd.polyjet.entity.EntityIndex;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class EntitySpawnInfo {
 | 
					public class EntitySpawnInfo {
 | 
				
			||||||
	private Entities entityType;
 | 
						private EntityIndex entityType;
 | 
				
			||||||
	private float[] parameters;
 | 
					//	private float[] parameters;
 | 
				
			||||||
 | 
						public HashMap<String, Float> parameters;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public EntitySpawnInfo(Entities entityType, float... parameters) {
 | 
						public EntitySpawnInfo(EntityIndex entityType) {
 | 
				
			||||||
		this.entityType = entityType;
 | 
							this.entityType = entityType;
 | 
				
			||||||
		this.parameters = parameters;
 | 
							parameters = new HashMap<>();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public Entities getEntityType() {
 | 
						public EntityIndex getEntityType() {
 | 
				
			||||||
		return entityType;
 | 
							return entityType;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public String toString() {
 | 
						public String toString() {
 | 
				
			||||||
		return entityType.name() + ": " + parameters.length;
 | 
							return entityType.name() + ": " + parameters.size();
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	public float[] getParameters() {
 | 
					 | 
				
			||||||
		return parameters;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,14 +4,16 @@ import com.badlogic.gdx.audio.Music;
 | 
				
			|||||||
import com.badlogic.gdx.utils.Array;
 | 
					import com.badlogic.gdx.utils.Array;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import zero1hd.polyjet.audio.AudioData;
 | 
					import zero1hd.polyjet.audio.AudioData;
 | 
				
			||||||
import zero1hd.polyjet.entity.Entities;
 | 
					import zero1hd.polyjet.entity.EntityIndex;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class GamePlayMap {
 | 
					public class GamePlayMap {
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	private AudioData musicData;
 | 
						private AudioData musicData;
 | 
				
			||||||
	private float playTime;
 | 
						private float playTime;
 | 
				
			||||||
	private Array<MapWindowData> spawnList;
 | 
						private Array<MapWindowData> spawnList;
 | 
				
			||||||
	private boolean building;
 | 
						private boolean building;
 | 
				
			||||||
	private int index;
 | 
						private int index;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * GamePlayMap is what the game area will use to generate entities and judge current audio data
 | 
						 * GamePlayMap is what the game area will use to generate entities and judge current audio data
 | 
				
			||||||
	 * @param audioData audio data
 | 
						 * @param audioData audio data
 | 
				
			||||||
@@ -61,19 +63,17 @@ public class GamePlayMap {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * used to add data types for what entity to spawn at that index position
 | 
						 * adds a new entity to the map for the current window.
 | 
				
			||||||
	 * cannot be null.
 | 
						 * @param entityType what type of entity it should be
 | 
				
			||||||
	 * @param entityType what type of entity to spawn
 | 
						 * @return the object.
 | 
				
			||||||
	 * @param parameters the arguments for the entity. It is important to have the same amount of parameters the entity requires to spawn
 | 
					 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	
 | 
						public EntitySpawnInfo nextEntitySpawnInfo(EntityIndex entityType) {
 | 
				
			||||||
	public void addToMap(Entities entityType, float... parameters) {
 | 
							if (spawnList.get(index) == null) {
 | 
				
			||||||
		if (building && entityType != null && parameters != null) {
 | 
								spawnList.set(index, new MapWindowData());
 | 
				
			||||||
			if (spawnList.get(index) == null) {
 | 
					 | 
				
			||||||
				spawnList.set(index, new MapWindowData());
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			spawnList.get(index).addEntity(new EntitySpawnInfo(entityType, parameters));
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							EntitySpawnInfo esi = new EntitySpawnInfo(entityType);
 | 
				
			||||||
 | 
							spawnList.get(index).addEntity(esi);
 | 
				
			||||||
 | 
							return esi;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
@@ -81,8 +81,7 @@ public class GamePlayMap {
 | 
				
			|||||||
	 */
 | 
						 */
 | 
				
			||||||
	public void nextWindow() {
 | 
						public void nextWindow() {
 | 
				
			||||||
		if (building) {
 | 
							if (building) {
 | 
				
			||||||
			spawnList.add(new MapWindowData());
 | 
								index++;
 | 
				
			||||||
			resetIndex();
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,7 +7,7 @@ import com.badlogic.gdx.utils.FloatArray;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import zero1hd.polyjet.Main;
 | 
					import zero1hd.polyjet.Main;
 | 
				
			||||||
import zero1hd.polyjet.audio.AudioAnalyzer;
 | 
					import zero1hd.polyjet.audio.AudioAnalyzer;
 | 
				
			||||||
import zero1hd.polyjet.entity.Entities;
 | 
					import zero1hd.polyjet.entity.EntityIndex;
 | 
				
			||||||
import zero1hd.polyjet.util.MiniEvents;
 | 
					import zero1hd.polyjet.util.MiniEvents;
 | 
				
			||||||
import zero1hd.polyjet.util.MiniSender;
 | 
					import zero1hd.polyjet.util.MiniSender;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -52,6 +52,8 @@ public class RhythmMapAlgorithm implements Runnable {
 | 
				
			|||||||
		avgBass = analyzer.getBassAvg();
 | 
							avgBass = analyzer.getBassAvg();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						EntitySpawnInfo esi;
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void run() {
 | 
						public void run() {
 | 
				
			||||||
		map.beginBuild();
 | 
							map.beginBuild();
 | 
				
			||||||
@@ -64,13 +66,14 @@ public class RhythmMapAlgorithm implements Runnable {
 | 
				
			|||||||
						int indexMoved = map.goBack((int) (windowPerSecond*1.5f));
 | 
											int indexMoved = map.goBack((int) (windowPerSecond*1.5f));
 | 
				
			||||||
						float waitTime = indexMoved/windowPerSecond;
 | 
											float waitTime = indexMoved/windowPerSecond;
 | 
				
			||||||
						float endRadius = (bassPeaks.get(index)/bassMax)*(Main.GAME_AREA_HEIGHT/4f);
 | 
											float endRadius = (bassPeaks.get(index)/bassMax)*(Main.GAME_AREA_HEIGHT/4f);
 | 
				
			||||||
						map.addToMap(Entities.VOID_CIRCLE, 
 | 
											
 | 
				
			||||||
								endRadius,
 | 
											esi = map.nextEntitySpawnInfo(EntityIndex.VOID_CIRCLE);
 | 
				
			||||||
								rand.nextFloat()*Main.GAME_AREA_WIDTH, 
 | 
											esi.parameters.put("warningTime", waitTime);
 | 
				
			||||||
								rand.nextFloat()*Main.GAME_AREA_HEIGHT,
 | 
											esi.parameters.put("endRadius", endRadius);
 | 
				
			||||||
								endRadius/(avgSPB*0.7f),
 | 
											esi.parameters.put("growthRate", endRadius/(avgSPB*0.7f));
 | 
				
			||||||
								waitTime
 | 
											esi.parameters.put("x", rand.nextFloat()*Main.GAME_AREA_WIDTH);
 | 
				
			||||||
								);
 | 
											esi.parameters.put("y", rand.nextFloat()*Main.GAME_AREA_HEIGHT);
 | 
				
			||||||
 | 
											
 | 
				
			||||||
						map.goForward(indexMoved);
 | 
											map.goForward(indexMoved);
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
@@ -79,16 +82,20 @@ public class RhythmMapAlgorithm implements Runnable {
 | 
				
			|||||||
					if (UMPeaks.get(index) >= avgUM) {
 | 
										if (UMPeaks.get(index) >= avgUM) {
 | 
				
			||||||
						//If upper midrange peaks are greater than average, the:
 | 
											//If upper midrange peaks are greater than average, the:
 | 
				
			||||||
						int spawnLocations = (Main.GAME_AREA_WIDTH-8)/8;
 | 
											int spawnLocations = (Main.GAME_AREA_WIDTH-8)/8;
 | 
				
			||||||
						map.addToMap(Entities.BAR, 
 | 
											
 | 
				
			||||||
								MathUtils.round(rand.nextFloat()*spawnLocations)*8, 
 | 
											esi = map.nextEntitySpawnInfo(EntityIndex.BAR);
 | 
				
			||||||
								(8f/avgSPB)*speedMod);
 | 
											esi.parameters.put("x", (float) (MathUtils.round(rand.nextFloat()*spawnLocations)*8));
 | 
				
			||||||
 | 
											esi.parameters.put("rate", (8f/avgSPB)*speedMod);
 | 
				
			||||||
 | 
											
 | 
				
			||||||
					} else {
 | 
										} else {
 | 
				
			||||||
						float xSpawnLocation = (rand.nextFloat()*(Main.GAME_AREA_WIDTH-2))+1;
 | 
											float xSpawnLocation = (rand.nextFloat()*(Main.GAME_AREA_WIDTH-2))+1;
 | 
				
			||||||
						map.addToMap(Entities.PELLET,
 | 
											
 | 
				
			||||||
								xSpawnLocation,
 | 
											esi = map.nextEntitySpawnInfo(EntityIndex.PELLET);
 | 
				
			||||||
								Main.GAME_AREA_HEIGHT-0.25f, 
 | 
											esi.parameters.put("x", xSpawnLocation);
 | 
				
			||||||
								140*rand.nextFloat()+110f,
 | 
											esi.parameters.put("y", Main.GAME_AREA_HEIGHT-0.25f);
 | 
				
			||||||
								(Main.GAME_AREA_HEIGHT/4f)/avgSPB);
 | 
											esi.parameters.put("angle", 140*rand.nextFloat()+110f);
 | 
				
			||||||
 | 
											esi.parameters.put("speed", (Main.GAME_AREA_HEIGHT/4f)/avgSPB);
 | 
				
			||||||
 | 
											
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				
 | 
									
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,29 +0,0 @@
 | 
				
			|||||||
package zero1hd.polyjet.entity;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import zero1hd.polyjet.entity.ally.Laser;
 | 
					 | 
				
			||||||
import zero1hd.polyjet.entity.ally.PolyJetEntity;
 | 
					 | 
				
			||||||
import zero1hd.polyjet.entity.enemies.Bar;
 | 
					 | 
				
			||||||
import zero1hd.polyjet.entity.enemies.Flake;
 | 
					 | 
				
			||||||
import zero1hd.polyjet.entity.enemies.Pellet;
 | 
					 | 
				
			||||||
import zero1hd.polyjet.entity.enemies.Shard;
 | 
					 | 
				
			||||||
import zero1hd.polyjet.entity.enemies.VoidCircle;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public enum Entities {
 | 
					 | 
				
			||||||
	POLYJET(false, PolyJetEntity.class), BAR(true, Bar.class), VOID_CIRCLE(true, VoidCircle.class), SHARD(true, Shard.class), LASER(false, Laser.class), PELLET(true, Pellet.class), FLAKE(true, Flake.class);
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	private final boolean enemy;
 | 
					 | 
				
			||||||
	private final Class<? extends Entity> classType;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	private Entities(boolean enemy, Class<? extends Entity> classType) {
 | 
					 | 
				
			||||||
		this.enemy = enemy;
 | 
					 | 
				
			||||||
		this.classType = classType;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	public boolean isEnemy() {
 | 
					 | 
				
			||||||
		return enemy;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	public Class<? extends Entity> getClassType() {
 | 
					 | 
				
			||||||
		return classType;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,34 +1,126 @@
 | 
				
			|||||||
package zero1hd.polyjet.entity;
 | 
					package zero1hd.polyjet.entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.HashMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.badlogic.gdx.Preferences;
 | 
				
			||||||
 | 
					import com.badlogic.gdx.assets.AssetManager;
 | 
				
			||||||
 | 
					import com.badlogic.gdx.graphics.Color;
 | 
				
			||||||
 | 
					import com.badlogic.gdx.graphics.g2d.Batch;
 | 
				
			||||||
 | 
					import com.badlogic.gdx.graphics.g2d.Sprite;
 | 
				
			||||||
 | 
					import com.badlogic.gdx.math.MathUtils;
 | 
				
			||||||
import com.badlogic.gdx.math.Rectangle;
 | 
					import com.badlogic.gdx.math.Rectangle;
 | 
				
			||||||
 | 
					import com.badlogic.gdx.math.Vector2;
 | 
				
			||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
 | 
					import com.badlogic.gdx.scenes.scene2d.Actor;
 | 
				
			||||||
 | 
					import com.badlogic.gdx.utils.Pool.Poolable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public abstract class Entity extends Actor {
 | 
					public class Entity extends Actor implements Poolable {
 | 
				
			||||||
 | 
						private EntityFrame<?> ef;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
						protected AssetManager assets;
 | 
				
			||||||
 | 
						protected Preferences prefs;
 | 
				
			||||||
 | 
						protected EntityController ec;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						protected boolean enemy;
 | 
				
			||||||
 | 
						protected boolean simple = true;
 | 
				
			||||||
 | 
						protected boolean nonStnrd = false;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						protected Rectangle hitbox;
 | 
				
			||||||
 | 
						protected Sprite sprite;
 | 
				
			||||||
 | 
						protected Vector2 rotRatios;
 | 
				
			||||||
 | 
						protected Vector2 center;
 | 
				
			||||||
 | 
						protected float angle;
 | 
				
			||||||
 | 
						protected float speed;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * called by the entity frame and only once (when this object is created).
 | 
				
			||||||
 | 
						 * Since your not supposed to actually use the constructor;
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						protected void setup(EntityController ec, EntityFrame<?> ef) {
 | 
				
			||||||
 | 
							this.ec = ec;
 | 
				
			||||||
 | 
							this.ef = ef;
 | 
				
			||||||
 | 
							assets = ec.getAssets();
 | 
				
			||||||
 | 
							prefs = ec.getPrefs();
 | 
				
			||||||
 | 
							rotRatios = new Vector2();
 | 
				
			||||||
 | 
							center = new Vector2();
 | 
				
			||||||
 | 
							hitbox = new Rectangle();
 | 
				
			||||||
 | 
							sprite = new Sprite();
 | 
				
			||||||
 | 
							sprite.setOriginCenter();
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							preInit();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public void preInit() {
 | 
				
			||||||
 | 
							if (sprite.getTexture() == null) throw new NullPointerException("what, your not going to have a texture for your entity?");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public void init(HashMap<String, Float> params) {
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * Called whenever a collision is detected
 | 
						 * Called whenever a collision is detected
 | 
				
			||||||
	 * @param entity is the entity that hit this one.
 | 
						 * @param entity is the entity that hit this one.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public abstract void collided(Entity entity);
 | 
						public void collided(Entity entity) {
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * gets the box that represents the hit box to calculate whether there is a collision or not
 | 
						 * gets the box that represents the hit box to calculate whether there is a collision or not
 | 
				
			||||||
	 * @return the object that represents the hit box
 | 
						 * @return the object that represents the hit box
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public abstract Rectangle getHitZone();
 | 
						public Rectangle getHitZone() {
 | 
				
			||||||
 | 
							return hitbox;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * gets the type of entity this entity is
 | 
						 * gets the type of entity this entity is
 | 
				
			||||||
	 * @return the entity type
 | 
						 * @return the entity type
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public abstract Entities getEntityType();
 | 
						public EntityIndex getEntityType() {
 | 
				
			||||||
 | 
							return null;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
	 * If this entity's life span is over, it should be considered dead. Useful for knowing what can be freed in a pool scenario.
 | 
						 * If this entity's life span is over, it should be considered dead. Useful for knowing what can be freed in a pool scenario.
 | 
				
			||||||
	 * @return if this entity is dead or not.
 | 
						 * @return if this entity is dead or not.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public abstract boolean isDead();
 | 
						public boolean isDead() {
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void act(float delta) {
 | 
				
			||||||
 | 
							if (!nonStnrd) {
 | 
				
			||||||
 | 
								rotRatios.set(MathUtils.cosDeg(angle), MathUtils.sinDeg(angle));
 | 
				
			||||||
 | 
								center.set(getX() + getWidth()/2f, getY() + getHeight()/2f);
 | 
				
			||||||
 | 
								moveBy(rotRatios.x*speed*delta, rotRatios.y*speed*delta);
 | 
				
			||||||
 | 
								if (simple) {
 | 
				
			||||||
 | 
									sprite.setPosition(getX(), getY());
 | 
				
			||||||
 | 
									hitbox.setPosition(getX(), getY());
 | 
				
			||||||
 | 
									sprite.setSize(getWidth(), getHeight());
 | 
				
			||||||
 | 
									hitbox.setSize(getWidth(), getHeight());
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
 | 
									sprite.setCenter(center.x, center.y);
 | 
				
			||||||
 | 
									hitbox.setCenter(center);
 | 
				
			||||||
 | 
									sprite.setRotation(angle);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								super.act(delta);
 | 
				
			||||||
 | 
								
 | 
				
			||||||
 | 
								if (isDead()) {
 | 
				
			||||||
 | 
									ef.recycleEntity(this);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void draw(Batch batch, float parentAlpha) {
 | 
				
			||||||
 | 
							if (!nonStnrd) {
 | 
				
			||||||
 | 
								sprite.draw(batch);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							batch.setColor(Color.WHITE);
 | 
				
			||||||
 | 
							super.draw(batch, parentAlpha);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public boolean playCollidePFX() {
 | 
						public boolean playCollidePFX() {
 | 
				
			||||||
		return true;
 | 
							return true;
 | 
				
			||||||
@@ -37,4 +129,33 @@ public abstract class Entity extends Actor {
 | 
				
			|||||||
	public boolean playCollideSFX() {
 | 
						public boolean playCollideSFX() {
 | 
				
			||||||
		return true;
 | 
							return true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void reset() {
 | 
				
			||||||
 | 
							rotRatios.set(0, 0);
 | 
				
			||||||
 | 
							hitbox.set(0, 0, 0, 0);
 | 
				
			||||||
 | 
							sprite.setBounds(0, 0, 0, 0);
 | 
				
			||||||
 | 
							sprite.setRotation(0);
 | 
				
			||||||
 | 
							sprite.setOrigin(0, 0);
 | 
				
			||||||
 | 
							setPosition(0, 0);
 | 
				
			||||||
 | 
							center.set(0, 0);
 | 
				
			||||||
 | 
							angle = 0;
 | 
				
			||||||
 | 
							speed = 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public Vector2 getCenter() {
 | 
				
			||||||
 | 
							return center;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public float getAngle() {
 | 
				
			||||||
 | 
							return angle;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public void setSpeed(float speed) {
 | 
				
			||||||
 | 
							this.speed = speed;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public float getSpeed() {
 | 
				
			||||||
 | 
							return speed;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,17 +1,13 @@
 | 
				
			|||||||
package zero1hd.polyjet.entity;
 | 
					package zero1hd.polyjet.entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.Arrays;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.badlogic.gdx.Gdx;
 | 
					import java.util.HashMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.badlogic.gdx.Preferences;
 | 
					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.graphics.Texture;
 | 
					 | 
				
			||||||
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 zero1hd.polyjet.audio.map.EntitySpawnInfo;
 | 
					 | 
				
			||||||
import zero1hd.polyjet.entity.ally.Laser;
 | 
					import zero1hd.polyjet.entity.ally.Laser;
 | 
				
			||||||
import zero1hd.polyjet.entity.enemies.Bar;
 | 
					import zero1hd.polyjet.entity.enemies.Bar;
 | 
				
			||||||
import zero1hd.polyjet.entity.enemies.Flake;
 | 
					import zero1hd.polyjet.entity.enemies.Flake;
 | 
				
			||||||
@@ -20,25 +16,23 @@ import zero1hd.polyjet.entity.enemies.Shard;
 | 
				
			|||||||
import zero1hd.polyjet.entity.enemies.VoidCircle;
 | 
					import zero1hd.polyjet.entity.enemies.VoidCircle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class EntityController {
 | 
					public class EntityController {
 | 
				
			||||||
	AssetManager assets;
 | 
						private AssetManager assets;
 | 
				
			||||||
	Preferences prefs;
 | 
						private Preferences prefs;
 | 
				
			||||||
 | 
						private Stage stage;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public Array<Entity> activeAllies;
 | 
						public Array<Entity> activeAllies;
 | 
				
			||||||
	public Array<Entity> activeEnemies;
 | 
						public Array<Entity> activeEnemies;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	//Enemy pool declaration;
 | 
						public EntityFrame<VoidCircle> voidCircle;
 | 
				
			||||||
	private Pool<VoidCircle> voidCirclePool;
 | 
						public EntityFrame<Pellet> pellet;
 | 
				
			||||||
	private Pool<Pellet> pelletPool;
 | 
						public EntityFrame<Shard> shard;
 | 
				
			||||||
	private Pool<Shard> shardPool;
 | 
						public EntityFrame<Bar> bar;
 | 
				
			||||||
	private Pool<Bar> barPool;
 | 
						public EntityFrame<Flake> flake;
 | 
				
			||||||
	private Pool<Flake> flakePool;
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	private EntityController ec = this;
 | 
						public EntityFrame<Laser> laser;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	//Ally pool declaration;
 | 
						private HashMap<EntityIndex, EntityFrame<? extends Entity>> index = new HashMap<>();
 | 
				
			||||||
	private Pool<Laser> laserPool;
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	private Stage stage;
 | 
					 | 
				
			||||||
	public EntityController(AssetManager assetManager, Preferences preferences, Stage stage) {
 | 
						public EntityController(AssetManager assetManager, Preferences preferences, Stage stage) {
 | 
				
			||||||
		activeAllies = new Array<Entity>();
 | 
							activeAllies = new Array<Entity>();
 | 
				
			||||||
		activeEnemies = new Array<Entity>();
 | 
							activeEnemies = new Array<Entity>();
 | 
				
			||||||
@@ -46,187 +40,32 @@ public class EntityController {
 | 
				
			|||||||
		this.prefs = preferences;
 | 
							this.prefs = preferences;
 | 
				
			||||||
		this.stage = stage;
 | 
							this.stage = stage;
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		//Enemy pool initialization;
 | 
							setup();
 | 
				
			||||||
		voidCirclePool = new Pool<VoidCircle>() {
 | 
					 | 
				
			||||||
			@Override
 | 
					 | 
				
			||||||
			protected VoidCircle newObject() {
 | 
					 | 
				
			||||||
				return new VoidCircle(assets.get("void_circle.png", Texture.class), assets.get("disintegrate.ogg", Sound.class), prefs);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		};
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		pelletPool = new Pool<Pellet>() {
 | 
					 | 
				
			||||||
			@Override
 | 
					 | 
				
			||||||
			protected Pellet newObject() {
 | 
					 | 
				
			||||||
				return new Pellet(assets.get("pellet.png", Texture.class));
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		};
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		shardPool = new Pool<Shard>() {
 | 
					 | 
				
			||||||
			@Override
 | 
					 | 
				
			||||||
			protected Shard newObject() {
 | 
					 | 
				
			||||||
				return new Shard(assets.get("shard.png", Texture.class));
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		};
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		barPool = new Pool<Bar>() {
 | 
					 | 
				
			||||||
			@Override
 | 
					 | 
				
			||||||
			protected Bar newObject() {
 | 
					 | 
				
			||||||
				return new Bar(assets.get("bar.png", Texture.class));
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		};
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		flakePool = new Pool<Flake>() {
 | 
					 | 
				
			||||||
			@Override
 | 
					 | 
				
			||||||
			protected Flake newObject() {
 | 
					 | 
				
			||||||
				return new Flake(assets.get("flake.png", Texture.class), ec);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		};
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		//Ally pool initialization;
 | 
					 | 
				
			||||||
		laserPool = new Pool<Laser>() {
 | 
					 | 
				
			||||||
			@Override
 | 
					 | 
				
			||||||
			protected Laser newObject() {
 | 
					 | 
				
			||||||
				return new Laser(assets.get("laser.png", Texture.class), assets.get("laser.ogg", Sound.class), prefs);
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		};
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public Entity retrieveEntity(Entities entity) {
 | 
						private void setup() {
 | 
				
			||||||
		switch (entity) {
 | 
							index.put(EntityIndex.VOID_CIRCLE, new EntityFrame<>(this, VoidCircle.class));
 | 
				
			||||||
		case VOID_CIRCLE:
 | 
							index.put(EntityIndex.PELLET, new EntityFrame<>(this, Pellet.class));
 | 
				
			||||||
			VoidCircle voidCircle = voidCirclePool.obtain();
 | 
							index.put(EntityIndex.SHARD, new EntityFrame<>(this, Shard.class));
 | 
				
			||||||
			activeEnemies.add(voidCircle);
 | 
							index.put(EntityIndex.BAR, new EntityFrame<>(this, Bar.class));
 | 
				
			||||||
			return voidCircle;
 | 
							index.put(EntityIndex.FLAKE, new EntityFrame<>(this, Flake.class));
 | 
				
			||||||
		case LASER:
 | 
							
 | 
				
			||||||
			Laser laser = laserPool.obtain();
 | 
							index.put(EntityIndex.LASER, new EntityFrame<>(this, Laser.class));
 | 
				
			||||||
			activeAllies.add(laser);
 | 
					 | 
				
			||||||
			return laser;
 | 
					 | 
				
			||||||
		case PELLET:
 | 
					 | 
				
			||||||
			Pellet pellet = pelletPool.obtain();
 | 
					 | 
				
			||||||
			activeEnemies.add(pellet);
 | 
					 | 
				
			||||||
			return pellet;
 | 
					 | 
				
			||||||
		case SHARD:
 | 
					 | 
				
			||||||
			Shard shard = shardPool.obtain();
 | 
					 | 
				
			||||||
			activeEnemies.add(shard);
 | 
					 | 
				
			||||||
			return shard;
 | 
					 | 
				
			||||||
		case BAR:
 | 
					 | 
				
			||||||
			Bar bar = barPool.obtain();
 | 
					 | 
				
			||||||
			activeEnemies.add(bar);
 | 
					 | 
				
			||||||
			return bar;
 | 
					 | 
				
			||||||
		case FLAKE:
 | 
					 | 
				
			||||||
			Flake flake = flakePool.obtain();
 | 
					 | 
				
			||||||
			activeEnemies.add(flake);
 | 
					 | 
				
			||||||
			return flake;
 | 
					 | 
				
			||||||
		default:
 | 
					 | 
				
			||||||
			return null;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public Entity spawnEntity(Stage stage, EntitySpawnInfo entitySpawnInfo) {
 | 
						public HashMap<EntityIndex, EntityFrame<? extends Entity>> getIndex() {
 | 
				
			||||||
		if (entitySpawnInfo != null) {
 | 
							return index;
 | 
				
			||||||
			float[] param = entitySpawnInfo.getParameters();
 | 
					 | 
				
			||||||
			Gdx.app.debug("Spawning Entity", entitySpawnInfo.toString() + " parameters: " + Arrays.toString(param));
 | 
					 | 
				
			||||||
			switch (entitySpawnInfo.getEntityType()) {
 | 
					 | 
				
			||||||
			case VOID_CIRCLE:
 | 
					 | 
				
			||||||
				VoidCircle voidCircle = voidCirclePool.obtain();
 | 
					 | 
				
			||||||
				voidCircle.init(param[0], param[1], param[2], param[3], param[4]);
 | 
					 | 
				
			||||||
				activeEnemies.add(voidCircle);
 | 
					 | 
				
			||||||
				stage.addActor(voidCircle);
 | 
					 | 
				
			||||||
				return voidCircle;
 | 
					 | 
				
			||||||
			case LASER:
 | 
					 | 
				
			||||||
				Laser laser = laserPool.obtain();
 | 
					 | 
				
			||||||
				laser.init(param[0], param[1], param[2]);
 | 
					 | 
				
			||||||
				activeAllies.add(laser);
 | 
					 | 
				
			||||||
				stage.addActor(laser);
 | 
					 | 
				
			||||||
				return laser;
 | 
					 | 
				
			||||||
			case PELLET:
 | 
					 | 
				
			||||||
				Pellet pellet = pelletPool.obtain();
 | 
					 | 
				
			||||||
				pellet.init(param[0], param[1], param[2], param[3]);
 | 
					 | 
				
			||||||
				activeEnemies.add(pellet);
 | 
					 | 
				
			||||||
				stage.addActor(pellet);
 | 
					 | 
				
			||||||
				return pellet;
 | 
					 | 
				
			||||||
			case SHARD:
 | 
					 | 
				
			||||||
				Shard shard = shardPool.obtain();
 | 
					 | 
				
			||||||
				shard.init(param[0], param[1], param[2], param[3], (int) param[4]);
 | 
					 | 
				
			||||||
				activeEnemies.add(shard);
 | 
					 | 
				
			||||||
				stage.addActor(shard);
 | 
					 | 
				
			||||||
				return shard;
 | 
					 | 
				
			||||||
			case BAR:
 | 
					 | 
				
			||||||
				Bar bar = barPool.obtain();
 | 
					 | 
				
			||||||
				bar.init(param[0], param[1]);
 | 
					 | 
				
			||||||
				activeEnemies.add(bar);
 | 
					 | 
				
			||||||
				stage.addActor(bar);
 | 
					 | 
				
			||||||
				return bar;
 | 
					 | 
				
			||||||
			case FLAKE:
 | 
					 | 
				
			||||||
				Flake flake = flakePool.obtain();
 | 
					 | 
				
			||||||
				flake.init(param[1], param[2], param[3], param[4], param[5], (int) param[0]);
 | 
					 | 
				
			||||||
				activeEnemies.add(flake);
 | 
					 | 
				
			||||||
				stage.addActor(flake);
 | 
					 | 
				
			||||||
				return flake;
 | 
					 | 
				
			||||||
			default:
 | 
					 | 
				
			||||||
				return null;
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			return null;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	public void free(Entity entity) {
 | 
					 | 
				
			||||||
		if (entity.getEntityType().isEnemy()) {
 | 
					 | 
				
			||||||
			activeEnemies.removeValue(entity, true);
 | 
					 | 
				
			||||||
		} else {
 | 
					 | 
				
			||||||
			activeAllies.removeValue(entity, true);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		switch (entity.getEntityType()) {
 | 
					 | 
				
			||||||
		case VOID_CIRCLE:
 | 
					 | 
				
			||||||
			VoidCircle voidCircle = (VoidCircle) entity;
 | 
					 | 
				
			||||||
			voidCircle.remove();
 | 
					 | 
				
			||||||
			voidCirclePool.free(voidCircle);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case LASER:
 | 
					 | 
				
			||||||
			Laser laser = (Laser) entity;
 | 
					 | 
				
			||||||
			laser.remove();
 | 
					 | 
				
			||||||
			laserPool.free(laser);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case PELLET:
 | 
					 | 
				
			||||||
			Pellet pellet = (Pellet) entity;
 | 
					 | 
				
			||||||
			pellet.remove();
 | 
					 | 
				
			||||||
			pelletPool.free(pellet);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case SHARD:
 | 
					 | 
				
			||||||
			Shard shard = (Shard) entity;
 | 
					 | 
				
			||||||
			shard.remove();
 | 
					 | 
				
			||||||
			shardPool.free(shard);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case BAR:
 | 
					 | 
				
			||||||
			Bar bar = (Bar) entity;
 | 
					 | 
				
			||||||
			bar.remove();
 | 
					 | 
				
			||||||
			barPool.free(bar);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		case FLAKE:
 | 
					 | 
				
			||||||
			Flake flake = (Flake) entity;
 | 
					 | 
				
			||||||
			flake.remove();
 | 
					 | 
				
			||||||
			flakePool.free(flake);
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		default:
 | 
					 | 
				
			||||||
			break;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	public void deathClean() {
 | 
					 | 
				
			||||||
		for (int i = 0; i < activeAllies.size; i ++) {
 | 
					 | 
				
			||||||
			if (activeAllies.get(i).isDead()) {
 | 
					 | 
				
			||||||
				free(activeAllies.get(i));
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		for (int i = 0; i < activeEnemies.size; i++) {
 | 
					 | 
				
			||||||
			if (activeEnemies.get(i).isDead()) {
 | 
					 | 
				
			||||||
				free(activeEnemies.get(i));
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public Stage getStage() {
 | 
						public Stage getStage() {
 | 
				
			||||||
		return stage;
 | 
							return stage;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public AssetManager getAssets() {
 | 
				
			||||||
 | 
							return assets;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public Preferences getPrefs() {
 | 
				
			||||||
 | 
							return prefs;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										56
									
								
								core/src/zero1hd/polyjet/entity/EntityFrame.java
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										56
									
								
								core/src/zero1hd/polyjet/entity/EntityFrame.java
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,56 @@
 | 
				
			|||||||
 | 
					package zero1hd.polyjet.entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.badlogic.gdx.utils.Pool;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class EntityFrame<T extends Entity> {
 | 
				
			||||||
 | 
						private Pool<T> pool;
 | 
				
			||||||
 | 
						private EntityController ec;
 | 
				
			||||||
 | 
						Class<T> ct;
 | 
				
			||||||
 | 
						EntityFrame<T> ef;
 | 
				
			||||||
 | 
						public EntityFrame(EntityController entityController, Class<T> classType) {
 | 
				
			||||||
 | 
							ct = classType;
 | 
				
			||||||
 | 
							ef = this;
 | 
				
			||||||
 | 
							ec = entityController;
 | 
				
			||||||
 | 
							pool = new Pool<T>() {
 | 
				
			||||||
 | 
								@Override
 | 
				
			||||||
 | 
								protected T newObject() {
 | 
				
			||||||
 | 
									try {
 | 
				
			||||||
 | 
										T entity = ct.newInstance();
 | 
				
			||||||
 | 
										entity.setup(ec, ef);
 | 
				
			||||||
 | 
										
 | 
				
			||||||
 | 
										return entity;
 | 
				
			||||||
 | 
									} catch (InstantiationException | IllegalAccessException e) {
 | 
				
			||||||
 | 
										e.printStackTrace();
 | 
				
			||||||
 | 
										return null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							};
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public T buildEntity() {
 | 
				
			||||||
 | 
							T entity = pool.obtain();
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							if (entity.enemy) {
 | 
				
			||||||
 | 
								ec.activeEnemies.add(entity);
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								ec.activeAllies.add(entity);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return entity;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Free the entity if no longer used.
 | 
				
			||||||
 | 
						 * @param entity to be freed.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						public void recycleEntity(Entity entity) {
 | 
				
			||||||
 | 
							if (entity.enemy) {
 | 
				
			||||||
 | 
								ec.activeEnemies.removeValue(entity, true);
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								ec.activeAllies.removeValue(entity, true);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							entity.remove();
 | 
				
			||||||
 | 
							pool.free(ct.cast(entity));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										24
									
								
								core/src/zero1hd/polyjet/entity/EntityIndex.java
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										24
									
								
								core/src/zero1hd/polyjet/entity/EntityIndex.java
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,24 @@
 | 
				
			|||||||
 | 
					package zero1hd.polyjet.entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import zero1hd.polyjet.entity.ally.Laser;
 | 
				
			||||||
 | 
					import zero1hd.polyjet.entity.ally.PolyJetEntity;
 | 
				
			||||||
 | 
					import zero1hd.polyjet.entity.enemies.Bar;
 | 
				
			||||||
 | 
					import zero1hd.polyjet.entity.enemies.Flake;
 | 
				
			||||||
 | 
					import zero1hd.polyjet.entity.enemies.Pellet;
 | 
				
			||||||
 | 
					import zero1hd.polyjet.entity.enemies.Shard;
 | 
				
			||||||
 | 
					import zero1hd.polyjet.entity.enemies.VoidCircle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public enum EntityIndex {
 | 
				
			||||||
 | 
					    POLYJET(PolyJetEntity.class), BAR(Bar.class), VOID_CIRCLE(VoidCircle.class), SHARD(Shard.class), LASER(Laser.class), PELLET(Pellet.class), FLAKE(Flake.class);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private final Class<? extends Entity> classType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    private EntityIndex(Class<? extends Entity> classType) {
 | 
				
			||||||
 | 
					            this.classType = classType;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public Class<? extends Entity> getClassType() {
 | 
				
			||||||
 | 
					            return classType;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,48 +1,51 @@
 | 
				
			|||||||
package zero1hd.polyjet.entity.ally;
 | 
					package zero1hd.polyjet.entity.ally;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.badlogic.gdx.Preferences;
 | 
					import java.util.HashMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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.Batch;
 | 
					import com.badlogic.gdx.graphics.g2d.Batch;
 | 
				
			||||||
import com.badlogic.gdx.math.Rectangle;
 | 
					 | 
				
			||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
 | 
					 | 
				
			||||||
import com.badlogic.gdx.utils.Pool.Poolable;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import zero1hd.polyjet.Main;
 | 
					import zero1hd.polyjet.Main;
 | 
				
			||||||
import zero1hd.polyjet.entity.Entities;
 | 
					import zero1hd.polyjet.entity.EntityIndex;
 | 
				
			||||||
import zero1hd.polyjet.entity.Entity;
 | 
					import zero1hd.polyjet.entity.Entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class Laser extends Entity implements Poolable {
 | 
					public class Laser extends Entity {
 | 
				
			||||||
	private Rectangle hitBox;
 | 
					 | 
				
			||||||
	private float rate;
 | 
					 | 
				
			||||||
	boolean dead;
 | 
						boolean dead;
 | 
				
			||||||
	Texture laserTexture;
 | 
					 | 
				
			||||||
	Sound sfx;
 | 
						Sound sfx;
 | 
				
			||||||
	Preferences prefs;
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public Laser(Texture laserTexture, Sound sfx, Preferences prefs) {
 | 
						@Override
 | 
				
			||||||
		this.laserTexture = laserTexture;
 | 
						public void preInit() {
 | 
				
			||||||
		this.sfx = sfx;
 | 
							sprite.setTexture(assets.get("laser.png", Texture.class));
 | 
				
			||||||
		this.prefs = prefs;
 | 
							sfx = assets.get("laser.ogg", Sound.class);
 | 
				
			||||||
		setSize(0.25f, 2f);
 | 
							setSize(0.25f, 2f);
 | 
				
			||||||
 | 
							super.preInit();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public void init(float x, float y, float rate) {
 | 
						public void init(float x, float y, float rate) {
 | 
				
			||||||
		setX(x);
 | 
							setPosition(x-getWidth()/2f, y-getHeight()/2f);
 | 
				
			||||||
		setY(y);
 | 
							speed = rate;
 | 
				
			||||||
		this.rate = rate;
 | 
					 | 
				
			||||||
		hitBox = new Rectangle();
 | 
					 | 
				
			||||||
		hitBox.setSize(getWidth(), getHeight());
 | 
					 | 
				
			||||||
		sfx.play(prefs.getFloat("fx vol")/100f);
 | 
							sfx.play(prefs.getFloat("fx vol")/100f);
 | 
				
			||||||
		toBack();
 | 
							toBack();
 | 
				
			||||||
 | 
							angle = 90f;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Vars: x, y, rate;
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void init(HashMap<String, Float> params) {
 | 
				
			||||||
 | 
							setX(params.get("x") - getWidth()/2f);
 | 
				
			||||||
 | 
							setY(params.get("y") - getHeight()/2f);
 | 
				
			||||||
 | 
							speed = params.get("rate");
 | 
				
			||||||
 | 
							angle = 90f;
 | 
				
			||||||
 | 
							sfx.play(prefs.getFloat("fx vol")/100f);
 | 
				
			||||||
 | 
							super.init(params);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void act(float delta) {
 | 
						public void act(float delta) {
 | 
				
			||||||
		toBack();
 | 
							toBack();
 | 
				
			||||||
		moveBy(0, delta*rate);
 | 
					 | 
				
			||||||
		hitBox.setX(getX());
 | 
					 | 
				
			||||||
		hitBox.setY(getY());
 | 
					 | 
				
			||||||
		super.act(delta);
 | 
							super.act(delta);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		if (getY() > Main.GAME_AREA_HEIGHT) {
 | 
							if (getY() > Main.GAME_AREA_HEIGHT) {
 | 
				
			||||||
@@ -52,16 +55,11 @@ public class Laser extends Entity implements Poolable {
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void draw(Batch batch, float parentAlpha) {
 | 
						public void draw(Batch batch, float parentAlpha) {
 | 
				
			||||||
		batch.draw(laserTexture ,getX(), getY(), getWidth(), getHeight());
 | 
					 | 
				
			||||||
		super.draw(batch, parentAlpha);
 | 
							super.draw(batch, parentAlpha);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void reset() {
 | 
						public void reset() {
 | 
				
			||||||
		setX(0);
 | 
					 | 
				
			||||||
		setY(0);
 | 
					 | 
				
			||||||
		rate = 0;
 | 
					 | 
				
			||||||
		hitBox.set(0, 0, 0, 0);
 | 
					 | 
				
			||||||
		dead = false;
 | 
							dead = false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -75,13 +73,8 @@ public class Laser extends Entity implements Poolable {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public Rectangle getHitZone() {
 | 
						public EntityIndex getEntityType() {
 | 
				
			||||||
		return hitBox;
 | 
							return EntityIndex.LASER;
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	@Override
 | 
					 | 
				
			||||||
	public Entities getEntityType() {
 | 
					 | 
				
			||||||
		return Entities.LASER;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,7 +8,7 @@ import com.badlogic.gdx.math.Rectangle;
 | 
				
			|||||||
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
 | 
					import com.badlogic.gdx.scenes.scene2d.actions.Actions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import zero1hd.polyjet.Main;
 | 
					import zero1hd.polyjet.Main;
 | 
				
			||||||
import zero1hd.polyjet.entity.Entities;
 | 
					import zero1hd.polyjet.entity.EntityIndex;
 | 
				
			||||||
import zero1hd.polyjet.entity.Entity;
 | 
					import zero1hd.polyjet.entity.Entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class PolyJetEntity extends Entity {
 | 
					public class PolyJetEntity extends Entity {
 | 
				
			||||||
@@ -22,6 +22,7 @@ public class PolyJetEntity extends Entity {
 | 
				
			|||||||
	private float speed, accel;
 | 
						private float speed, accel;
 | 
				
			||||||
	private float rate;
 | 
						private float rate;
 | 
				
			||||||
	public PolyJetEntity(AssetManager assets, float speed, float accel, String jet) {
 | 
						public PolyJetEntity(AssetManager assets, float speed, float accel, String jet) {
 | 
				
			||||||
 | 
							nonStnrd = true;
 | 
				
			||||||
		health = 100;
 | 
							health = 100;
 | 
				
			||||||
		this.speed = speed;
 | 
							this.speed = speed;
 | 
				
			||||||
		this.accel = accel;
 | 
							this.accel = accel;
 | 
				
			||||||
@@ -78,14 +79,10 @@ public class PolyJetEntity extends Entity {
 | 
				
			|||||||
		super.draw(batch, parentAlpha);
 | 
							super.draw(batch, parentAlpha);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
					 | 
				
			||||||
	public Rectangle getHitZone() {
 | 
					 | 
				
			||||||
		return hitbox;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public Entities getEntityType() {
 | 
						public EntityIndex getEntityType() {
 | 
				
			||||||
		return Entities.POLYJET;
 | 
							return EntityIndex.POLYJET;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,35 +1,41 @@
 | 
				
			|||||||
package zero1hd.polyjet.entity.enemies;
 | 
					package zero1hd.polyjet.entity.enemies;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.HashMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.badlogic.gdx.graphics.Texture;
 | 
					import com.badlogic.gdx.graphics.Texture;
 | 
				
			||||||
import com.badlogic.gdx.graphics.g2d.Batch;
 | 
					 | 
				
			||||||
import com.badlogic.gdx.math.Rectangle;
 | 
					import com.badlogic.gdx.math.Rectangle;
 | 
				
			||||||
import com.badlogic.gdx.utils.Pool.Poolable;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import zero1hd.polyjet.Main;
 | 
					import zero1hd.polyjet.Main;
 | 
				
			||||||
import zero1hd.polyjet.entity.Entities;
 | 
					import zero1hd.polyjet.entity.EntityIndex;
 | 
				
			||||||
import zero1hd.polyjet.entity.Entity;
 | 
					import zero1hd.polyjet.entity.Entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class Bar extends Entity implements Poolable {
 | 
					public class Bar extends Entity {
 | 
				
			||||||
	private boolean dead;
 | 
						private boolean dead;
 | 
				
			||||||
	private Texture texture;
 | 
					 | 
				
			||||||
	private float rate;
 | 
					 | 
				
			||||||
	private Rectangle hitbox;
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public Bar(Texture barTexture) {
 | 
						@Override
 | 
				
			||||||
		this.texture = barTexture;
 | 
						public void preInit() {
 | 
				
			||||||
		hitbox = new Rectangle();
 | 
							setSize(8f, 0.5f);
 | 
				
			||||||
 | 
							sprite.setTexture(assets.get("bar.png", Texture.class));
 | 
				
			||||||
 | 
							enemy = true;
 | 
				
			||||||
 | 
							super.preInit();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public void init(float x, float rate) {
 | 
						public void init(float x, float rate) {
 | 
				
			||||||
		setSize(8f, 0.5f);
 | 
					 | 
				
			||||||
		setPosition(x, Main.GAME_AREA_HEIGHT);
 | 
							setPosition(x, Main.GAME_AREA_HEIGHT);
 | 
				
			||||||
		this.rate = rate;
 | 
							speed = rate;
 | 
				
			||||||
		hitbox.set(getX(), getY(), getWidth(), getHeight());
 | 
							angle = 270;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void init(HashMap<String, Float> params) {
 | 
				
			||||||
 | 
							setPosition(params.get("x"), Main.GAME_AREA_HEIGHT);
 | 
				
			||||||
 | 
							speed = params.get("rate");
 | 
				
			||||||
 | 
							angle = 270;
 | 
				
			||||||
 | 
							super.init(params);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void act(float delta) {
 | 
						public void act(float delta) {
 | 
				
			||||||
		moveBy(0f, -delta*rate);
 | 
					 | 
				
			||||||
		hitbox.setPosition(getX(), getY());
 | 
							hitbox.setPosition(getX(), getY());
 | 
				
			||||||
		super.act(delta);
 | 
							super.act(delta);
 | 
				
			||||||
		if (getY() < 0-getHeight()) {
 | 
							if (getY() < 0-getHeight()) {
 | 
				
			||||||
@@ -37,19 +43,9 @@ public class Bar extends Entity implements Poolable {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	@Override
 | 
					 | 
				
			||||||
	public void draw(Batch batch, float parentAlpha) {
 | 
					 | 
				
			||||||
		batch.draw(texture, getX(), getY(), getWidth(), getHeight());
 | 
					 | 
				
			||||||
		super.draw(batch, parentAlpha);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void reset() {
 | 
						public void reset() {
 | 
				
			||||||
		hitbox.set(0, 0, 0, 0);
 | 
					 | 
				
			||||||
		setPosition(0, 0);
 | 
					 | 
				
			||||||
		rate = 0;
 | 
					 | 
				
			||||||
		dead = false;
 | 
							dead = false;
 | 
				
			||||||
		setSize(0, 0);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
@@ -69,8 +65,8 @@ public class Bar extends Entity implements Poolable {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public Entities getEntityType() {
 | 
						public EntityIndex getEntityType() {
 | 
				
			||||||
		return Entities.BAR;
 | 
							return EntityIndex.BAR;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,52 +1,65 @@
 | 
				
			|||||||
package zero1hd.polyjet.entity.enemies;
 | 
					package zero1hd.polyjet.entity.enemies;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.badlogic.gdx.graphics.Color;
 | 
					import java.util.HashMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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;
 | 
				
			||||||
import com.badlogic.gdx.math.MathUtils;
 | 
					 | 
				
			||||||
import com.badlogic.gdx.math.Rectangle;
 | 
					import com.badlogic.gdx.math.Rectangle;
 | 
				
			||||||
import com.badlogic.gdx.math.Vector2;
 | 
					 | 
				
			||||||
import com.badlogic.gdx.utils.Pool.Poolable;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import zero1hd.polyjet.Main;
 | 
					import zero1hd.polyjet.Main;
 | 
				
			||||||
import zero1hd.polyjet.entity.Entities;
 | 
					import zero1hd.polyjet.entity.EntityIndex;
 | 
				
			||||||
import zero1hd.polyjet.entity.Entity;
 | 
					import zero1hd.polyjet.entity.Entity;
 | 
				
			||||||
import zero1hd.polyjet.entity.EntityController;
 | 
					import zero1hd.polyjet.entity.EntityController;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class Flake extends Entity implements Poolable {
 | 
					public class Flake extends Entity {
 | 
				
			||||||
	private Texture texture;
 | 
					 | 
				
			||||||
	private float rate;
 | 
					 | 
				
			||||||
	private float timer;
 | 
						private float timer;
 | 
				
			||||||
	private float totalTime;
 | 
						private float totalTime;
 | 
				
			||||||
	private Shard[] shards;
 | 
						private Shard[] shards;
 | 
				
			||||||
	private Rectangle hitbox;
 | 
					 | 
				
			||||||
	private Vector2 center;
 | 
					 | 
				
			||||||
	private Vector2 rot;
 | 
					 | 
				
			||||||
	private EntityController ec;
 | 
						private EntityController ec;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public Flake(Texture texture, EntityController ec) {
 | 
						@Override
 | 
				
			||||||
		this.ec = ec;
 | 
						public void preInit() {
 | 
				
			||||||
		this.texture = texture;
 | 
							sprite.setTexture(assets.get("flake.png", Texture.class));
 | 
				
			||||||
		hitbox = new Rectangle();
 | 
							simple = true;
 | 
				
			||||||
		center = new Vector2();
 | 
							enemy = true;
 | 
				
			||||||
		rot = new Vector2();
 | 
							setSize(3f, 3f);
 | 
				
			||||||
 | 
							super.preInit();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public void init(float x, float y, float rate, float fuse, float angle, int shardCount) {
 | 
						public void init(float x, float y, float rate, float fuse, float angle, int shardCount) {
 | 
				
			||||||
		this.shards = new Shard[shardCount];
 | 
							this.shards = new Shard[shardCount];
 | 
				
			||||||
		for (int i = 0; i < shards.length; i++) {
 | 
							for (int i = 0; i < shards.length; i++) {
 | 
				
			||||||
			shards[i] = (Shard) ec.retrieveEntity(Entities.SHARD);
 | 
								shards[i] = ec.shard.buildEntity();
 | 
				
			||||||
			shards[i].init(x, y, 360/shards.length*i, 0, 2);
 | 
								shards[i].init(x, y, 360/shards.length*i, 0, 2);
 | 
				
			||||||
			ec.getStage().addActor(shards[i]);
 | 
								ec.getStage().addActor(shards[i]);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		setSize(3f, 3f);
 | 
							setSize(3f, 3f);
 | 
				
			||||||
		this.rate = rate;
 | 
							this.speed = rate;
 | 
				
			||||||
		this.timer = fuse;
 | 
							this.timer = fuse;
 | 
				
			||||||
		this.totalTime = fuse;
 | 
							this.totalTime = fuse;
 | 
				
			||||||
 | 
							this.angle = angle;
 | 
				
			||||||
		hitbox.setSize(getWidth(), getHeight());
 | 
							hitbox.setSize(getWidth(), getHeight());
 | 
				
			||||||
		center.set(getWidth()/2f, getHeight()/2f);
 | 
					 | 
				
			||||||
		setPosition(x-center.x, y-center.y);
 | 
							setPosition(x-center.x, y-center.y);
 | 
				
			||||||
		rot.set(MathUtils.cosDeg(angle), MathUtils.sinDeg(angle));
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * params: shardCount, x, y, rate, fuse, angle;
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void init(HashMap<String, Float> params) {
 | 
				
			||||||
 | 
							this.shards = new Shard[params.get("shardCount").intValue()];
 | 
				
			||||||
 | 
							for (int i = 0; i < shards.length; i++) {
 | 
				
			||||||
 | 
								shards[i] = ec.shard.buildEntity();
 | 
				
			||||||
 | 
								shards[i].init(params.get("x"), params.get("y"), 360/shards.length*i, 0, 2);
 | 
				
			||||||
 | 
								ec.getStage().addActor(shards[i]);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							this.speed = params.get("rate");
 | 
				
			||||||
 | 
							this.timer = params.get("fuse");
 | 
				
			||||||
 | 
							this.totalTime = timer;
 | 
				
			||||||
 | 
							this.angle = params.get("angle");
 | 
				
			||||||
 | 
							hitbox.setSize(getWidth(), getHeight());
 | 
				
			||||||
 | 
							setPosition(params.get("x")-getWidth()/2f, params.get("y")-getHeight()/2f);
 | 
				
			||||||
 | 
							super.init(params);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
@@ -54,13 +67,10 @@ public class Flake extends Entity implements Poolable {
 | 
				
			|||||||
		if (timer > 0) {
 | 
							if (timer > 0) {
 | 
				
			||||||
			timer -= delta;
 | 
								timer -= delta;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		moveBy(rot.x*delta*rate, rot.y*delta*rate);
 | 
					 | 
				
			||||||
		for (int i = 0; i < shards.length; i++) {
 | 
							for (int i = 0; i < shards.length; i++) {
 | 
				
			||||||
			shards[i].setPosition(getX()+center.x-shards[i].getCenter().x, getY()+center.y-shards[i].getCenter().y);
 | 
								shards[i].setPosition(center.x-shards[i].getCenter().x, center.y-shards[i].getCenter().y);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		hitbox.setPosition(getX(), getY());
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		if (getX() > Main.GAME_AREA_WIDTH || getY() > Main.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
 | 
							if (getX() > Main.GAME_AREA_WIDTH || getY() > Main.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
 | 
				
			||||||
			timer = 0;
 | 
								timer = 0;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -69,9 +79,7 @@ public class Flake extends Entity implements Poolable {
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void draw(Batch batch, float parentAlpha) {
 | 
						public void draw(Batch batch, float parentAlpha) {
 | 
				
			||||||
		batch.setColor(0.1f,0.1f,0.1f,1f - timer/totalTime);
 | 
							sprite.setColor(0.1f,0.1f,0.1f,1f - timer/totalTime);
 | 
				
			||||||
		batch.draw(texture, getX(), getY(), getWidth(), getHeight());
 | 
					 | 
				
			||||||
		batch.setColor(Color.WHITE);
 | 
					 | 
				
			||||||
		super.draw(batch, parentAlpha);
 | 
							super.draw(batch, parentAlpha);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
@@ -92,15 +100,15 @@ public class Flake extends Entity implements Poolable {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public Entities getEntityType() {
 | 
						public EntityIndex getEntityType() {
 | 
				
			||||||
		return Entities.FLAKE;
 | 
							return EntityIndex.FLAKE;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public boolean isDead() {
 | 
						public boolean isDead() {
 | 
				
			||||||
		if (timer <= 0) {
 | 
							if (timer <= 0) {
 | 
				
			||||||
			for (int i = 0; i < shards.length; i++) {
 | 
								for (int i = 0; i < shards.length; i++) {
 | 
				
			||||||
				shards[i].setRate(45f);
 | 
									shards[i].setSpeed(45f);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			return true;
 | 
								return true;
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
@@ -110,14 +118,9 @@ public class Flake extends Entity implements Poolable {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void reset() {
 | 
						public void reset() {
 | 
				
			||||||
		rate = 0;
 | 
					 | 
				
			||||||
		timer = 0;
 | 
							timer = 0;
 | 
				
			||||||
		shards = null;
 | 
							shards = null;
 | 
				
			||||||
		hitbox.set(0, 0, 0, 0);
 | 
							hitbox.set(0, 0, 0, 0);
 | 
				
			||||||
		setPosition(0, 0);
 | 
					 | 
				
			||||||
		setSize(0, 0);
 | 
					 | 
				
			||||||
		center.set(0, 0);
 | 
					 | 
				
			||||||
		rot.set(0, 0);
 | 
					 | 
				
			||||||
		totalTime = 0;
 | 
							totalTime = 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,42 +1,45 @@
 | 
				
			|||||||
package zero1hd.polyjet.entity.enemies;
 | 
					package zero1hd.polyjet.entity.enemies;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.badlogic.gdx.graphics.Color;
 | 
					import java.util.HashMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.badlogic.gdx.graphics.Texture;
 | 
					import com.badlogic.gdx.graphics.Texture;
 | 
				
			||||||
import com.badlogic.gdx.graphics.g2d.Batch;
 | 
					 | 
				
			||||||
import com.badlogic.gdx.math.MathUtils;
 | 
					 | 
				
			||||||
import com.badlogic.gdx.math.Rectangle;
 | 
					 | 
				
			||||||
import com.badlogic.gdx.math.Vector2;
 | 
					 | 
				
			||||||
import com.badlogic.gdx.utils.Pool.Poolable;
 | 
					import com.badlogic.gdx.utils.Pool.Poolable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import zero1hd.polyjet.Main;
 | 
					import zero1hd.polyjet.Main;
 | 
				
			||||||
import zero1hd.polyjet.entity.Entities;
 | 
					import zero1hd.polyjet.entity.EntityIndex;
 | 
				
			||||||
import zero1hd.polyjet.entity.Entity;
 | 
					import zero1hd.polyjet.entity.Entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class Pellet extends Entity implements Poolable {
 | 
					public class Pellet extends Entity implements Poolable {
 | 
				
			||||||
	private boolean dead;
 | 
						private boolean dead;
 | 
				
			||||||
	private Texture texture;
 | 
					 | 
				
			||||||
	private Rectangle hitBox;
 | 
					 | 
				
			||||||
	private Vector2 direction;
 | 
					 | 
				
			||||||
	private float rate;
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public Pellet(Texture texture) {
 | 
						@Override
 | 
				
			||||||
		hitBox = new Rectangle();
 | 
						public void preInit() {
 | 
				
			||||||
		direction = new Vector2();
 | 
							sprite.setTexture(assets.get("pellet.png", Texture.class));
 | 
				
			||||||
		this.texture = texture;
 | 
							setSize(0.5f, 0.5f);
 | 
				
			||||||
 | 
							super.preInit();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public void init(float x, float y, float angle, float rate) {
 | 
						public void init(float x, float y, float angle, float rate) {
 | 
				
			||||||
		setPosition(x, y);
 | 
							setPosition(x, y);
 | 
				
			||||||
		direction.set(MathUtils.cosDeg(angle), MathUtils.sinDeg(angle));
 | 
							this.speed = rate;
 | 
				
			||||||
		setSize(0.5f, 0.5f);
 | 
							this.angle = angle;
 | 
				
			||||||
		hitBox.setSize(getWidth(), getHeight());
 | 
						}
 | 
				
			||||||
		this.rate = rate;
 | 
						
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * Vars: x, y, speed, angle;
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void init(HashMap<String, Float> params) {
 | 
				
			||||||
 | 
							setPosition(params.get("x"), params.get("y"));
 | 
				
			||||||
 | 
							speed = params.get("speed");
 | 
				
			||||||
 | 
							angle = params.get("angle");
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							super.init(params);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void act(float delta) {
 | 
						public void act(float delta) {
 | 
				
			||||||
		moveBy(direction.x*delta*rate, direction.y*delta*rate);
 | 
					 | 
				
			||||||
		hitBox.setPosition(getX(), getY());
 | 
					 | 
				
			||||||
		super.act(delta);
 | 
							super.act(delta);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		if (getX() > Main.GAME_AREA_WIDTH || getY() > Main.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
 | 
							if (getX() > Main.GAME_AREA_WIDTH || getY() > Main.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
 | 
				
			||||||
@@ -44,14 +47,6 @@ public class Pellet extends Entity implements Poolable {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	@Override
 | 
					 | 
				
			||||||
	public void draw(Batch batch, float parentAlpha) {
 | 
					 | 
				
			||||||
		batch.setColor(getColor().r, getColor().g, getColor().b, getColor().a);
 | 
					 | 
				
			||||||
		batch.draw(texture, getX(), getY(), getWidth(), getHeight());
 | 
					 | 
				
			||||||
		batch.setColor(Color.WHITE);
 | 
					 | 
				
			||||||
		super.draw(batch, parentAlpha);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void collided(Entity entity) {
 | 
						public void collided(Entity entity) {
 | 
				
			||||||
		switch (entity.getEntityType()) {
 | 
							switch (entity.getEntityType()) {
 | 
				
			||||||
@@ -62,13 +57,8 @@ public class Pellet extends Entity implements Poolable {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public Rectangle getHitZone() {
 | 
						public EntityIndex getEntityType() {
 | 
				
			||||||
		return hitBox;
 | 
							return EntityIndex.PELLET;
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	@Override
 | 
					 | 
				
			||||||
	public Entities getEntityType() {
 | 
					 | 
				
			||||||
		return Entities.PELLET;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
@@ -78,13 +68,7 @@ public class Pellet extends Entity implements Poolable {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void reset() {
 | 
						public void reset() {
 | 
				
			||||||
		hitBox.set(0, 0, 0, 0);
 | 
					 | 
				
			||||||
		setSize(0, 0);
 | 
					 | 
				
			||||||
		setPosition(0, 0);
 | 
					 | 
				
			||||||
		direction.set(0,0);
 | 
					 | 
				
			||||||
		rate = 0;
 | 
					 | 
				
			||||||
		dead = false;
 | 
							dead = false;
 | 
				
			||||||
		setColor(1f, 1f, 1f, 1f);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,65 +1,63 @@
 | 
				
			|||||||
package zero1hd.polyjet.entity.enemies;
 | 
					package zero1hd.polyjet.entity.enemies;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.HashMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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;
 | 
				
			||||||
import com.badlogic.gdx.graphics.g2d.Sprite;
 | 
					import com.badlogic.gdx.graphics.g2d.Sprite;
 | 
				
			||||||
import com.badlogic.gdx.math.MathUtils;
 | 
					 | 
				
			||||||
import com.badlogic.gdx.math.Rectangle;
 | 
					import com.badlogic.gdx.math.Rectangle;
 | 
				
			||||||
import com.badlogic.gdx.math.Vector2;
 | 
					 | 
				
			||||||
import com.badlogic.gdx.utils.Pool.Poolable;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import zero1hd.polyjet.Main;
 | 
					import zero1hd.polyjet.Main;
 | 
				
			||||||
import zero1hd.polyjet.entity.Entities;
 | 
					import zero1hd.polyjet.entity.EntityIndex;
 | 
				
			||||||
import zero1hd.polyjet.entity.Entity;
 | 
					import zero1hd.polyjet.entity.Entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class Shard extends Entity implements Poolable {
 | 
					public class Shard extends Entity {
 | 
				
			||||||
	private Sprite sprite;
 | 
					 | 
				
			||||||
	private Rectangle hitbox;
 | 
					 | 
				
			||||||
	private Vector2 angle;
 | 
					 | 
				
			||||||
	private Vector2 center;
 | 
					 | 
				
			||||||
	private int hp;
 | 
						private int hp;
 | 
				
			||||||
	private int maxHp;
 | 
						private int maxHp;
 | 
				
			||||||
	private float rate;
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public Shard(Texture shardTexture) {
 | 
						@Override
 | 
				
			||||||
		hitbox = new Rectangle();
 | 
						public void preInit() {
 | 
				
			||||||
		angle = new Vector2();
 | 
							sprite = new Sprite(assets.get("shard.png", Texture.class));
 | 
				
			||||||
		sprite = new Sprite(shardTexture);
 | 
					 | 
				
			||||||
		sprite.setSize(2f, 3f);
 | 
							sprite.setSize(2f, 3f);
 | 
				
			||||||
		center = new Vector2();
 | 
							simple = false;
 | 
				
			||||||
 | 
							enemy = true;
 | 
				
			||||||
 | 
							super.preInit();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public void init(float x, float y, float angle, float rate, int hp) {
 | 
						public void init(float x, float y, float angle, float rate, int hp) {
 | 
				
			||||||
		this.rate = rate;
 | 
							speed = rate;
 | 
				
			||||||
		this.hp = hp;
 | 
							this.hp = hp;
 | 
				
			||||||
		maxHp = hp;
 | 
							maxHp = hp;
 | 
				
			||||||
		this.angle.set(MathUtils.cosDeg(angle), MathUtils.sinDeg(angle));
 | 
							this.angle = angle;
 | 
				
			||||||
		sprite.setRotation(angle+90);
 | 
							sprite.setRotation(angle+90);
 | 
				
			||||||
		setSize(2f, 2f);
 | 
							setSize(2f, 2f);
 | 
				
			||||||
 | 
							setPosition(x-(getWidth()/2f), y-(getHeight()/2f));
 | 
				
			||||||
		hitbox.setSize(getWidth(), getHeight());
 | 
							hitbox.setSize(getWidth(), getHeight());
 | 
				
			||||||
		center.set(getWidth()/2f, getHeight()/2f);
 | 
							sprite.setOriginCenter();
 | 
				
			||||||
		setPosition(x-center.x, y-center.y);
 | 
						}
 | 
				
			||||||
		sprite.setOrigin(sprite.getWidth()/2f, sprite.getHeight()/2f);
 | 
						
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * x, y, angle, rate, hp;
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void init(HashMap<String, Float> params) {
 | 
				
			||||||
 | 
							setX(params.get("x"));
 | 
				
			||||||
 | 
							setY(params.get("y"));
 | 
				
			||||||
 | 
							angle = params.get("angle");
 | 
				
			||||||
 | 
							speed = params.get("rate");
 | 
				
			||||||
 | 
							hp = params.get("hp").intValue();
 | 
				
			||||||
 | 
							super.init(params);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void reset() {
 | 
						public void reset() {
 | 
				
			||||||
		hp = 0;
 | 
							hp = 0;
 | 
				
			||||||
		maxHp = 0;
 | 
							maxHp = 0;
 | 
				
			||||||
		setPosition(0, 0);
 | 
					 | 
				
			||||||
		angle.set(0, 0);
 | 
					 | 
				
			||||||
		center.set(0, 0);
 | 
					 | 
				
			||||||
		setSize(0, 0);
 | 
					 | 
				
			||||||
		hitbox.set(0, 0, 0, 0);
 | 
					 | 
				
			||||||
		setSize(0, 0);
 | 
					 | 
				
			||||||
		sprite.setRotation(0);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void act(float delta) {
 | 
						public void act(float delta) {
 | 
				
			||||||
		moveBy(angle.x*delta*rate, angle.y*rate*delta);
 | 
					 | 
				
			||||||
		hitbox.setPosition(getX(), getY());
 | 
					 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		if (getX() > Main.GAME_AREA_WIDTH || getY() > Main.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
 | 
							if (getX() > Main.GAME_AREA_WIDTH || getY() > Main.GAME_AREA_HEIGHT || getX() < 0-getWidth() || getY() < 0-getHeight()) {
 | 
				
			||||||
			hp = 0;
 | 
								hp = 0;
 | 
				
			||||||
@@ -69,7 +67,6 @@ public class Shard extends Entity implements Poolable {
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void draw(Batch batch, float parentAlpha) {
 | 
						public void draw(Batch batch, float parentAlpha) {
 | 
				
			||||||
		sprite.setCenter(getX()+center.x, getY()+center.y);
 | 
					 | 
				
			||||||
		sprite.setColor(((float)hp/(float)maxHp), ((float)hp/(float)maxHp), ((float)hp/(float)maxHp), 0.5f);
 | 
							sprite.setColor(((float)hp/(float)maxHp), ((float)hp/(float)maxHp), ((float)hp/(float)maxHp), 0.5f);
 | 
				
			||||||
		sprite.draw(batch);
 | 
							sprite.draw(batch);
 | 
				
			||||||
		batch.setColor(Color.WHITE);
 | 
							batch.setColor(Color.WHITE);
 | 
				
			||||||
@@ -93,8 +90,8 @@ public class Shard extends Entity implements Poolable {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public Entities getEntityType() {
 | 
						public EntityIndex getEntityType() {
 | 
				
			||||||
		return Entities.SHARD;
 | 
							return EntityIndex.SHARD;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
@@ -104,13 +101,4 @@ public class Shard extends Entity implements Poolable {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	public void setRate(float rate) {
 | 
					 | 
				
			||||||
		this.rate = rate;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	public Vector2 getCenter() {
 | 
					 | 
				
			||||||
		return center;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,39 +1,33 @@
 | 
				
			|||||||
package zero1hd.polyjet.entity.enemies;
 | 
					package zero1hd.polyjet.entity.enemies;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.badlogic.gdx.Preferences;
 | 
					import java.util.HashMap;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.badlogic.gdx.audio.Sound;
 | 
					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;
 | 
				
			||||||
import com.badlogic.gdx.graphics.g2d.Sprite;
 | 
					 | 
				
			||||||
import com.badlogic.gdx.math.Rectangle;
 | 
					 | 
				
			||||||
import com.badlogic.gdx.math.Vector2;
 | 
					 | 
				
			||||||
import com.badlogic.gdx.utils.Pool.Poolable;
 | 
					import com.badlogic.gdx.utils.Pool.Poolable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import zero1hd.polyjet.entity.Entities;
 | 
					import zero1hd.polyjet.entity.EntityIndex;
 | 
				
			||||||
import zero1hd.polyjet.entity.Entity;
 | 
					import zero1hd.polyjet.entity.Entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class VoidCircle extends Entity implements Poolable {
 | 
					public class VoidCircle extends Entity implements Poolable {
 | 
				
			||||||
	private float timer;
 | 
						private float timer;
 | 
				
			||||||
	private float endRadius;
 | 
						private float endRadius;
 | 
				
			||||||
	private float currentRadius;
 | 
						private float currentRadius;
 | 
				
			||||||
	private Rectangle hitBox;
 | 
					 | 
				
			||||||
	private Sprite voidCircleTexture;
 | 
					 | 
				
			||||||
	private float growthRate;
 | 
						private float growthRate;
 | 
				
			||||||
	private boolean done;
 | 
						private boolean done;
 | 
				
			||||||
	private boolean begin;
 | 
						private boolean begin;
 | 
				
			||||||
	private Vector2 center;
 | 
					 | 
				
			||||||
	private float maxTime;
 | 
						private float maxTime;
 | 
				
			||||||
	private Sound sound;
 | 
						private Sound sound;
 | 
				
			||||||
	private Preferences prefs;
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public VoidCircle(Texture voidTexture, Sound sound, Preferences prefs) {
 | 
					 | 
				
			||||||
		hitBox = new Rectangle();
 | 
					 | 
				
			||||||
		center = new Vector2();
 | 
					 | 
				
			||||||
		this.sound = sound;
 | 
					 | 
				
			||||||
		this.prefs = prefs;
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
		voidCircleTexture = new Sprite(voidTexture);
 | 
						@Override
 | 
				
			||||||
 | 
						public void preInit() {
 | 
				
			||||||
 | 
							sprite.setTexture(assets.get("void_circle.png", Texture.class));
 | 
				
			||||||
 | 
							simple = false;
 | 
				
			||||||
 | 
							sound = assets.get("disintegrate.ogg", Sound.class);
 | 
				
			||||||
 | 
							super.preInit();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public void init(float endRadius, float x, float y, float growthRate, float warningTime) {
 | 
						public void init(float endRadius, float x, float y, float growthRate, float warningTime) {
 | 
				
			||||||
@@ -41,22 +35,35 @@ public class VoidCircle extends Entity implements Poolable {
 | 
				
			|||||||
		maxTime = warningTime;
 | 
							maxTime = warningTime;
 | 
				
			||||||
		this.endRadius = endRadius;
 | 
							this.endRadius = endRadius;
 | 
				
			||||||
		setSize(2f*endRadius, 2f*endRadius);
 | 
							setSize(2f*endRadius, 2f*endRadius);
 | 
				
			||||||
		center.set(getWidth()/2f, getHeight()/2f);
 | 
							setPosition(x-getWidth()/2f, y-getHeight()/2f);
 | 
				
			||||||
		setPosition(x-center.x, y-center.y);
 | 
					 | 
				
			||||||
		this.growthRate = growthRate;
 | 
							this.growthRate = growthRate;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						/**
 | 
				
			||||||
 | 
						 * warningTime, endRadius, growthRate, x, y;
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void init(HashMap<String, Float> params) {
 | 
				
			||||||
 | 
							timer = params.get("warningTime");
 | 
				
			||||||
 | 
							maxTime = timer;
 | 
				
			||||||
 | 
							endRadius = params.get("endRadius");
 | 
				
			||||||
 | 
							setSize(2f*endRadius, 2f*endRadius);
 | 
				
			||||||
 | 
							setPosition(params.get("x")-getWidth()/2f, params.get("y")-getHeight()/2f);
 | 
				
			||||||
 | 
							growthRate = params.get("growthRate");
 | 
				
			||||||
 | 
							super.init(params);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void act(float delta) {
 | 
						public void act(float delta) {
 | 
				
			||||||
		toFront();
 | 
							toFront();
 | 
				
			||||||
		if (begin) {
 | 
							if (begin) {
 | 
				
			||||||
			voidCircleTexture.setSize(2*currentRadius, 2*currentRadius);
 | 
								sprite.setSize(2*currentRadius, 2*currentRadius);
 | 
				
			||||||
			voidCircleTexture.setColor(0f,0f,0f,1f);
 | 
								sprite.setColor(0f,0f,0f,1f);
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			voidCircleTexture.setSize(2*endRadius, 2*endRadius);
 | 
								sprite.setSize(2*endRadius, 2*endRadius);
 | 
				
			||||||
			voidCircleTexture.setColor(1f,1f,1f,0.1f*(timer/maxTime));
 | 
								sprite.setColor(1f,1f,1f,0.1f*(timer/maxTime));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		hitBox.setCenter(getX()+center.x, getY()+center.y);
 | 
					 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		if (timer > 0) {
 | 
							if (timer > 0) {
 | 
				
			||||||
			timer -= delta;
 | 
								timer -= delta;
 | 
				
			||||||
@@ -73,21 +80,18 @@ public class VoidCircle extends Entity implements Poolable {
 | 
				
			|||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		voidCircleTexture.setCenter(getX()+center.x, getY()+center.y);
 | 
					 | 
				
			||||||
		super.act(delta);
 | 
							super.act(delta);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void draw(Batch batch, float parentAlpha) {
 | 
						public void draw(Batch batch, float parentAlpha) {
 | 
				
			||||||
		voidCircleTexture.draw(batch);
 | 
					 | 
				
			||||||
		batch.setColor(Color.WHITE);
 | 
							batch.setColor(Color.WHITE);
 | 
				
			||||||
		super.draw(batch, parentAlpha);
 | 
							super.draw(batch, parentAlpha);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void reset() {
 | 
						public void reset() {
 | 
				
			||||||
		hitBox.set(0, 0, 0, 0);
 | 
					 | 
				
			||||||
		currentRadius = 0;
 | 
							currentRadius = 0;
 | 
				
			||||||
		growthRate = 0;
 | 
							growthRate = 0;
 | 
				
			||||||
		timer = 0;
 | 
							timer = 0;
 | 
				
			||||||
@@ -95,26 +99,18 @@ public class VoidCircle extends Entity implements Poolable {
 | 
				
			|||||||
		endRadius = 0;
 | 
							endRadius = 0;
 | 
				
			||||||
		done = false;
 | 
							done = false;
 | 
				
			||||||
		begin = false;
 | 
							begin = false;
 | 
				
			||||||
		center.set(0, 0);
 | 
					 | 
				
			||||||
		voidCircleTexture.setPosition(0, 0);
 | 
					 | 
				
			||||||
		setSize(0, 0);
 | 
							setSize(0, 0);
 | 
				
			||||||
		setPosition(0, 0);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public void growCurrentRadius(float radius) {
 | 
						public void growCurrentRadius(float radius) {
 | 
				
			||||||
		currentRadius += radius;
 | 
							currentRadius += radius;
 | 
				
			||||||
		float length = (float) Math.sqrt(2*(currentRadius*currentRadius));
 | 
							float length = (float) Math.sqrt(2*(currentRadius*currentRadius));
 | 
				
			||||||
		hitBox.setSize(length, length);
 | 
							hitbox.setSize(length, length);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public Rectangle getHitZone() {
 | 
						public EntityIndex getEntityType() {
 | 
				
			||||||
		return hitBox;
 | 
							return EntityIndex.VOID_CIRCLE;
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	@Override
 | 
					 | 
				
			||||||
	public Entities getEntityType() {
 | 
					 | 
				
			||||||
		return Entities.VOID_CIRCLE;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,8 +17,9 @@ import zero1hd.polyjet.audio.map.GamePlayMap;
 | 
				
			|||||||
import zero1hd.polyjet.audio.map.MapWindowData;
 | 
					import zero1hd.polyjet.audio.map.MapWindowData;
 | 
				
			||||||
import zero1hd.polyjet.controls.KeyMap;
 | 
					import zero1hd.polyjet.controls.KeyMap;
 | 
				
			||||||
import zero1hd.polyjet.entity.CollisionDetector;
 | 
					import zero1hd.polyjet.entity.CollisionDetector;
 | 
				
			||||||
import zero1hd.polyjet.entity.Entities;
 | 
					import zero1hd.polyjet.entity.Entity;
 | 
				
			||||||
import zero1hd.polyjet.entity.EntityController;
 | 
					import zero1hd.polyjet.entity.EntityController;
 | 
				
			||||||
 | 
					import zero1hd.polyjet.entity.EntityIndex;
 | 
				
			||||||
import zero1hd.polyjet.entity.ally.Laser;
 | 
					import zero1hd.polyjet.entity.ally.Laser;
 | 
				
			||||||
import zero1hd.polyjet.entity.ally.PolyJetEntity;
 | 
					import zero1hd.polyjet.entity.ally.PolyJetEntity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -126,14 +127,15 @@ public class GamePlayArea extends Stage {
 | 
				
			|||||||
				EntitySpawnInfo[] currentSpawnInfo = mwd.getArray();
 | 
									EntitySpawnInfo[] currentSpawnInfo = mwd.getArray();
 | 
				
			||||||
				if (currentSpawnInfo != null) {
 | 
									if (currentSpawnInfo != null) {
 | 
				
			||||||
					for (int i = 0; i < currentSpawnInfo.length; i++) {
 | 
										for (int i = 0; i < currentSpawnInfo.length; i++) {
 | 
				
			||||||
						ec.spawnEntity(this, currentSpawnInfo[i]);
 | 
											Entity entity = ec.getIndex().get(currentSpawnInfo[i].getEntityType()).buildEntity();
 | 
				
			||||||
 | 
											entity.init(currentSpawnInfo[i].parameters);
 | 
				
			||||||
 | 
											addActor(entity);
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		collisionDetector.collisionCheck();
 | 
							collisionDetector.collisionCheck();
 | 
				
			||||||
		ec.deathClean();
 | 
					 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		if (polyjet.getX() <= 1) {
 | 
							if (polyjet.getX() <= 1) {
 | 
				
			||||||
			polyjet.moveLeft = false;
 | 
								polyjet.moveLeft = false;
 | 
				
			||||||
@@ -208,8 +210,8 @@ public class GamePlayArea extends Stage {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		if (keycode == KeyMap.shoot) {
 | 
							if (keycode == KeyMap.shoot) {
 | 
				
			||||||
			Laser laser	= (Laser) ec.retrieveEntity(Entities.LASER);
 | 
								Laser laser	= (Laser) ec.getIndex().get(EntityIndex.LASER).buildEntity();
 | 
				
			||||||
			laser.init(polyjet.getX() + (polyjet.getWidth()-laser.getWidth())/2f, polyjet.getY() + polyjet.getHeight()+0.25f, 60f);
 | 
								laser.init(polyjet.getX() + polyjet.getWidth()/2f, polyjet.getY() + polyjet.getHeight()+1f, 60f);
 | 
				
			||||||
			addActor(laser);
 | 
								addActor(laser);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -10,7 +10,7 @@ import com.badlogic.gdx.scenes.scene2d.ui.Skin;
 | 
				
			|||||||
import com.badlogic.gdx.scenes.scene2d.ui.Slider;
 | 
					import com.badlogic.gdx.scenes.scene2d.ui.Slider;
 | 
				
			||||||
import com.badlogic.gdx.scenes.scene2d.ui.Window;
 | 
					import com.badlogic.gdx.scenes.scene2d.ui.Window;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import zero1hd.polyjet.entity.Entities;
 | 
					import zero1hd.polyjet.entity.EntityIndex;
 | 
				
			||||||
import zero1hd.polyjet.entity.Entity;
 | 
					import zero1hd.polyjet.entity.Entity;
 | 
				
			||||||
import zero1hd.polyjet.entity.EntityController;
 | 
					import zero1hd.polyjet.entity.EntityController;
 | 
				
			||||||
import zero1hd.polyjet.entity.ally.Laser;
 | 
					import zero1hd.polyjet.entity.ally.Laser;
 | 
				
			||||||
@@ -24,7 +24,7 @@ public class SpawnerWindow extends Window {
 | 
				
			|||||||
	private EntityController ec;
 | 
						private EntityController ec;
 | 
				
			||||||
	private Stage stage;
 | 
						private Stage stage;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	private List<Entities> listOfEntities;
 | 
						private List<EntityIndex> listOfEntities;
 | 
				
			||||||
	private ScrollPane scroller;
 | 
						private ScrollPane scroller;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	private Slider mod1;
 | 
						private Slider mod1;
 | 
				
			||||||
@@ -43,7 +43,7 @@ public class SpawnerWindow extends Window {
 | 
				
			|||||||
		mod4 = new Slider(1f, 12f, 0.01f, true, skin);
 | 
							mod4 = new Slider(1f, 12f, 0.01f, true, skin);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		listOfEntities = new List<>(skin);
 | 
							listOfEntities = new List<>(skin);
 | 
				
			||||||
		listOfEntities.setItems(Entities.values());
 | 
							listOfEntities.setItems(EntityIndex.values());
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		scroller = new ScrollPane(listOfEntities);
 | 
							scroller = new ScrollPane(listOfEntities);
 | 
				
			||||||
		add(scroller).expandY().fillY().spaceRight(15f);
 | 
							add(scroller).expandY().fillY().spaceRight(15f);
 | 
				
			||||||
@@ -67,7 +67,7 @@ public class SpawnerWindow extends Window {
 | 
				
			|||||||
			stage.screenToStageCoordinates(coords);
 | 
								stage.screenToStageCoordinates(coords);
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			Entity entity;
 | 
								Entity entity;
 | 
				
			||||||
			if ((entity = ec.retrieveEntity(listOfEntities.getSelected())) != null) {
 | 
								if ((entity = ec.getIndex().get(listOfEntities.getSelected()).buildEntity()) != null) {
 | 
				
			||||||
				switch(entity.getEntityType()) {
 | 
									switch(entity.getEntityType()) {
 | 
				
			||||||
				case LASER:
 | 
									case LASER:
 | 
				
			||||||
					Laser laser = (Laser) entity;
 | 
										Laser laser = (Laser) entity;
 | 
				
			||||||
@@ -96,8 +96,8 @@ public class SpawnerWindow extends Window {
 | 
				
			|||||||
					break;
 | 
										break;
 | 
				
			||||||
				case FLAKE:
 | 
									case FLAKE:
 | 
				
			||||||
					Flake flake = (Flake) entity;
 | 
										Flake flake = (Flake) entity;
 | 
				
			||||||
					stage.addActor(flake);
 | 
					 | 
				
			||||||
					flake.init(coords.x, coords.y, mod1.getValue(), mod3.getValue(), mod2.getValue()/mod2.getMaxValue()*360f, (int) mod4.getValue());
 | 
										flake.init(coords.x, coords.y, mod1.getValue(), mod3.getValue(), mod2.getValue()/mod2.getMaxValue()*360f, (int) mod4.getValue());
 | 
				
			||||||
 | 
										stage.addActor(flake);
 | 
				
			||||||
				default:
 | 
									default:
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,6 @@ import java.io.DataInputStream;
 | 
				
			|||||||
import java.io.IOException;
 | 
					import java.io.IOException;
 | 
				
			||||||
import java.security.InvalidParameterException;
 | 
					import java.security.InvalidParameterException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.badlogic.gdx.Gdx;
 | 
					 | 
				
			||||||
import com.badlogic.gdx.files.FileHandle;
 | 
					import com.badlogic.gdx.files.FileHandle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class WavDecoder {
 | 
					public class WavDecoder {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user