added pellet entity as well as minor changes to collision functions
This commit is contained in:
@@ -24,6 +24,7 @@ public class CollisionDetector {
|
||||
|
||||
fe.collided(se);
|
||||
se.collided(fe);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -96,4 +96,18 @@ public class EntityController {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -60,8 +60,10 @@ public class Laser extends Actor implements Entity, Poolable {
|
||||
|
||||
@Override
|
||||
public void collided(Entity entity) {
|
||||
if (entity.getEntityType() == Entities.VOID_CIRCLE) {
|
||||
switch (entity.getEntityType()) {
|
||||
default:
|
||||
dead = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package zero1hd.polyjet.entity.ally;
|
||||
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.ParticleEffect;
|
||||
@@ -40,7 +41,7 @@ public class PolyJetEntity extends Actor implements Entity {
|
||||
public void act(float delta) {
|
||||
hitbox.setPosition(getX(), getY());
|
||||
|
||||
thrust.setPosition(getX()+(getWidth())/2 - 1f/16f, getY()-0.15f);
|
||||
thrust.setPosition(getX()+(getWidth())/2 - 1f/16f, getY()-0.2f);
|
||||
thrust.update(delta);
|
||||
teleportCloak.setPosition(getX() +(getWidth()-1)/2, getY() + (getHeight()-1)/2);
|
||||
|
||||
@@ -66,6 +67,7 @@ public class PolyJetEntity extends Actor implements Entity {
|
||||
@Override
|
||||
public void draw(Batch batch, float parentAlpha) {
|
||||
thrust.draw(batch);
|
||||
batch.setColor(Color.BLACK);
|
||||
batch.draw(polyjet, getX(), getY(), getWidth(), getHeight());
|
||||
super.draw(batch, parentAlpha);
|
||||
}
|
||||
|
19
core/src/zero1hd/polyjet/entity/enemies/Pellet.java
Normal file → Executable file
19
core/src/zero1hd/polyjet/entity/enemies/Pellet.java
Normal file → Executable file
@@ -1,7 +1,9 @@
|
||||
package zero1hd.polyjet.entity.enemies;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
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.scenes.scene2d.Actor;
|
||||
@@ -24,16 +26,19 @@ public class Pellet extends Actor implements Entity, Poolable {
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
public void init(float x, float y, float direction, float rate) {
|
||||
public void init(float x, float y, float angle, float rate, float colorG) {
|
||||
setPosition(x, y);
|
||||
this.direction.setAngle(direction);
|
||||
rate = 0;
|
||||
setSize(0.5f, 0.5f);
|
||||
direction.set(MathUtils.sinDeg(angle), MathUtils.cosDeg(angle));
|
||||
setSize(0.75f, 0.75f);
|
||||
hitBox.setSize(getWidth(), getHeight());
|
||||
this.rate = rate;
|
||||
setColor(1f, colorG, 0f, 1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
moveBy(direction.x*delta*rate, direction.y*delta*rate);
|
||||
hitBox.setPosition(getX(), getY());
|
||||
super.act(delta);
|
||||
|
||||
if (getX() > Polyjet.GAME_AREA_WIDTH || getY() > Polyjet.GAME_AREA_HEIGHT || getX()-getWidth() < 0 || getY()-getHeight() < 0) {
|
||||
@@ -43,13 +48,15 @@ public class Pellet extends Actor implements Entity, 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
|
||||
public void collided(Entity entity) {
|
||||
if (entity.getEntityType() == Entities.VOID_CIRCLE) {
|
||||
if (entity.getEntityType() == Entities.LASER) {
|
||||
dead = true;
|
||||
}
|
||||
}
|
||||
@@ -76,6 +83,8 @@ public class Pellet extends Actor implements Entity, Poolable {
|
||||
setPosition(0, 0);
|
||||
direction.set(0,0);
|
||||
rate = 0;
|
||||
dead = false;
|
||||
setColor(1f, 1f, 1f, 1f);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -44,18 +44,7 @@ public class GamePlayArea extends Stage {
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
collisionDetector.collisionCheck();
|
||||
|
||||
for (int i = 0; i < entityController.activeAllies.size; i ++) {
|
||||
if (entityController.activeAllies.get(i).isDead()) {
|
||||
entityController.free(entityController.activeAllies.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < entityController.activeEnemies.size; i++) {
|
||||
if (entityController.activeEnemies.get(i).isDead()) {
|
||||
entityController.free(entityController.activeEnemies.get(i));
|
||||
}
|
||||
}
|
||||
entityController.deathClean();
|
||||
|
||||
if (polyjet.getX() <= 1) {
|
||||
polyjet.moveLeft = false;
|
||||
|
@@ -33,7 +33,7 @@ public class SpawnerWindow extends Window {
|
||||
stage = stageForEntities;
|
||||
|
||||
mod1 = new Slider(0.1f, 50f, 0.01f, true, skin);
|
||||
mod2 = new Slider(0.1f, 15f, 0.01f, true, skin);
|
||||
mod2 = new Slider(0f, 15f, 0.01f, true, skin);
|
||||
mod3 = new Slider(0.1f, 15f, 0.01f, true, skin);
|
||||
|
||||
listOfEntities = new List<>(skin);
|
||||
@@ -71,12 +71,12 @@ public class SpawnerWindow extends Window {
|
||||
break;
|
||||
case PELLET:
|
||||
Pellet pellet = (Pellet) entity;
|
||||
pellet.init(coords.x, coords.y, mod2.getValue(), mod3.getValue());
|
||||
pellet.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue(), mod3.getValue()/mod3.getMaxValue());
|
||||
stage.addActor(pellet);
|
||||
break;
|
||||
case VOID_CIRCLE:
|
||||
VoidCircle voidCircle = (VoidCircle) entity;
|
||||
voidCircle.init(mod3.getValue(), coords.x, coords.y, mod1.getValue(), mod2.getValue());
|
||||
voidCircle.init(mod2.getValue(), coords.x, coords.y, mod1.getValue(), mod3.getValue());
|
||||
stage.addActor(voidCircle);
|
||||
break;
|
||||
default:
|
||||
|
Reference in New Issue
Block a user