began work on flake entity
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 113 B |
BIN
android/assets/1280x720/flake.png
Executable file
After Width: | Height: | Size: 161 B |
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 117 B |
BIN
android/assets/1280x800/flake.png
Executable file
After Width: | Height: | Size: 241 B |
Before Width: | Height: | Size: 111 B After Width: | Height: | Size: 116 B |
BIN
android/assets/1366x768/flake.png
Executable file
After Width: | Height: | Size: 229 B |
Before Width: | Height: | Size: 131 B After Width: | Height: | Size: 132 B |
BIN
android/assets/1920x1080/flake.png
Executable file
After Width: | Height: | Size: 275 B |
Before Width: | Height: | Size: 135 B After Width: | Height: | Size: 135 B |
BIN
android/assets/1920x1200/flake.png
Executable file
After Width: | Height: | Size: 319 B |
Before Width: | Height: | Size: 143 B After Width: | Height: | Size: 143 B |
BIN
android/assets/2560x1440/flake.png
Executable file
After Width: | Height: | Size: 266 B |
Before Width: | Height: | Size: 234 B After Width: | Height: | Size: 232 B |
BIN
android/assets/3840x2160/flake.png
Executable file
After Width: | Height: | Size: 547 B |
Before Width: | Height: | Size: 96 B After Width: | Height: | Size: 97 B |
BIN
android/assets/800x480/flake.png
Executable file
After Width: | Height: | Size: 137 B |
@ -127,6 +127,7 @@ public class Polyjet extends Game {
|
|||||||
assetManager.load("pellet.png", Texture.class);
|
assetManager.load("pellet.png", Texture.class);
|
||||||
assetManager.load("shard.png", Texture.class);
|
assetManager.load("shard.png", Texture.class);
|
||||||
assetManager.load("bar.png", Texture.class);
|
assetManager.load("bar.png", Texture.class);
|
||||||
|
assetManager.load("flake.png", Texture.class);
|
||||||
}
|
}
|
||||||
public void generateFonts() {
|
public void generateFonts() {
|
||||||
initComplete = true;
|
initComplete = true;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package zero1hd.polyjet.entity;
|
package zero1hd.polyjet.entity;
|
||||||
|
|
||||||
public enum Entities {
|
public enum Entities {
|
||||||
POLYJET, BAR, VOID_CIRCLE, SHARD, LASER, PELLET;
|
POLYJET, BAR, VOID_CIRCLE, SHARD, LASER, PELLET, FLAKE;
|
||||||
|
|
||||||
public float x;
|
public float x;
|
||||||
public float y;
|
public float y;
|
||||||
|
@ -8,6 +8,7 @@ import com.badlogic.gdx.utils.Pool;
|
|||||||
|
|
||||||
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.Pellet;
|
import zero1hd.polyjet.entity.enemies.Pellet;
|
||||||
import zero1hd.polyjet.entity.enemies.Shard;
|
import zero1hd.polyjet.entity.enemies.Shard;
|
||||||
import zero1hd.polyjet.entity.enemies.VoidCircle;
|
import zero1hd.polyjet.entity.enemies.VoidCircle;
|
||||||
@ -24,9 +25,11 @@ public class EntityController {
|
|||||||
private Pool<Pellet> pelletPool;
|
private Pool<Pellet> pelletPool;
|
||||||
private Pool<Shard> shardPool;
|
private Pool<Shard> shardPool;
|
||||||
private Pool<Bar> barPool;
|
private Pool<Bar> barPool;
|
||||||
|
private Pool<Flake> flakePool;
|
||||||
|
|
||||||
//Ally pool declaration;
|
//Ally pool declaration;
|
||||||
private Pool<Laser> laserPool;
|
private Pool<Laser> laserPool;
|
||||||
|
|
||||||
public EntityController(AssetManager assetManager, ShapeRenderer shapeRenderer) {
|
public EntityController(AssetManager assetManager, ShapeRenderer shapeRenderer) {
|
||||||
activeAllies = new Array<Entity>();
|
activeAllies = new Array<Entity>();
|
||||||
activeEnemies = new Array<Entity>();
|
activeEnemies = new Array<Entity>();
|
||||||
@ -60,6 +63,12 @@ public class EntityController {
|
|||||||
return new Bar(assets.get("bar.png", Texture.class));
|
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));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//Ally pool initialization;
|
//Ally pool initialization;
|
||||||
laserPool = new Pool<Laser>() {
|
laserPool = new Pool<Laser>() {
|
||||||
@ -93,42 +102,47 @@ public class EntityController {
|
|||||||
Bar bar = barPool.obtain();
|
Bar bar = barPool.obtain();
|
||||||
activeEnemies.add(bar);
|
activeEnemies.add(bar);
|
||||||
return bar;
|
return bar;
|
||||||
|
case FLAKE:
|
||||||
|
Flake flake = flakePool.obtain();
|
||||||
|
activeEnemies.add(flake);
|
||||||
|
return flake;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void free(Entity entity) {
|
public void free(Entity entity) {
|
||||||
|
activeEnemies.removeValue(entity, true);
|
||||||
switch (entity.getEntityType()) {
|
switch (entity.getEntityType()) {
|
||||||
case VOID_CIRCLE:
|
case VOID_CIRCLE:
|
||||||
VoidCircle voidCircle = (VoidCircle) entity;
|
VoidCircle voidCircle = (VoidCircle) entity;
|
||||||
voidCircle.remove();
|
voidCircle.remove();
|
||||||
activeEnemies.removeValue(entity, true);
|
|
||||||
voidCirclePool.free(voidCircle);
|
voidCirclePool.free(voidCircle);
|
||||||
break;
|
break;
|
||||||
case LASER:
|
case LASER:
|
||||||
Laser laser = (Laser) entity;
|
Laser laser = (Laser) entity;
|
||||||
laser.remove();
|
laser.remove();
|
||||||
activeAllies.removeValue(entity, true);
|
|
||||||
laserPool.free(laser);
|
laserPool.free(laser);
|
||||||
break;
|
break;
|
||||||
case PELLET:
|
case PELLET:
|
||||||
Pellet pellet = (Pellet) entity;
|
Pellet pellet = (Pellet) entity;
|
||||||
pellet.remove();
|
pellet.remove();
|
||||||
activeEnemies.removeValue(entity, true);
|
|
||||||
pelletPool.free(pellet);
|
pelletPool.free(pellet);
|
||||||
break;
|
break;
|
||||||
case SHARD:
|
case SHARD:
|
||||||
Shard shard = (Shard) entity;
|
Shard shard = (Shard) entity;
|
||||||
shard.remove();
|
shard.remove();
|
||||||
activeEnemies.removeValue(entity, true);
|
|
||||||
shardPool.free(shard);
|
shardPool.free(shard);
|
||||||
break;
|
break;
|
||||||
case BAR:
|
case BAR:
|
||||||
Bar bar = (Bar) entity;
|
Bar bar = (Bar) entity;
|
||||||
bar.remove();
|
bar.remove();
|
||||||
activeEnemies.removeValue(entity, true);
|
|
||||||
barPool.free(bar);
|
barPool.free(bar);
|
||||||
|
break;
|
||||||
|
case FLAKE:
|
||||||
|
Flake flake = (Flake) entity;
|
||||||
|
flake.remove();
|
||||||
|
flakePool.free(flake);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
94
core/src/zero1hd/polyjet/entity/enemies/Flake.java
Executable file
@ -0,0 +1,94 @@
|
|||||||
|
package zero1hd.polyjet.entity.enemies;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
|
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;
|
||||||
|
import com.badlogic.gdx.utils.Pool.Poolable;
|
||||||
|
|
||||||
|
import zero1hd.polyjet.entity.Entities;
|
||||||
|
import zero1hd.polyjet.entity.Entity;
|
||||||
|
|
||||||
|
public class Flake extends Actor implements Poolable, Entity {
|
||||||
|
private Texture texture;
|
||||||
|
private float rate;
|
||||||
|
private float timer;
|
||||||
|
private Shard[] shards;
|
||||||
|
private Rectangle hitbox;
|
||||||
|
private Vector2 center;
|
||||||
|
private Vector2 rot;
|
||||||
|
|
||||||
|
public Flake(Texture texture) {
|
||||||
|
this.texture = texture;
|
||||||
|
hitbox = new Rectangle();
|
||||||
|
center = new Vector2();
|
||||||
|
rot = new Vector2();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(float x, float y, float rate, float fuse, float angle, Shard... shards) {
|
||||||
|
this.shards = shards;
|
||||||
|
setPosition(x, y);
|
||||||
|
setSize(1f, 1f);
|
||||||
|
this.rate = rate;
|
||||||
|
this.timer = fuse;
|
||||||
|
hitbox.setSize(getWidth(), getHeight());
|
||||||
|
center.set(getWidth()/2f, getHeight()/2f);
|
||||||
|
rot.set(MathUtils.sinDeg(angle), MathUtils.cosDeg(angle));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void act(float delta) {
|
||||||
|
moveBy(rot.x*delta*rate, rot.y*delta*rate);
|
||||||
|
|
||||||
|
if (timer > 0) {
|
||||||
|
timer -= delta;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
hitbox.setPosition(getX(), getY());
|
||||||
|
super.act(delta);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void collided(Entity entity) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Rectangle getHitZone() {
|
||||||
|
return hitbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Entities getEntityType() {
|
||||||
|
return Entities.FLAKE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDead() {
|
||||||
|
if (timer <= 0) {
|
||||||
|
for (int i = 0; i < shards.length; i++) {
|
||||||
|
shards[i].setRate(40f);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
rate = 0;
|
||||||
|
timer = 0;
|
||||||
|
shards = null;
|
||||||
|
hitbox.set(0, 0, 0, 0);
|
||||||
|
setPosition(0, 0);
|
||||||
|
setSize(0, 0);
|
||||||
|
center.set(0, 0);
|
||||||
|
rot.set(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -40,7 +40,7 @@ public class Shard extends Actor implements Entity, Poolable {
|
|||||||
setSize(2f, 2f);
|
setSize(2f, 2f);
|
||||||
hitbox.setSize(getWidth(), getHeight());
|
hitbox.setSize(getWidth(), getHeight());
|
||||||
center.set(getWidth()/2f, getHeight()/2f);
|
center.set(getWidth()/2f, getHeight()/2f);
|
||||||
setPosition(x-center.x, y-center.y);
|
setPosition(x, y);
|
||||||
sprite.setOrigin(sprite.getWidth()/2f, sprite.getHeight()/2f);
|
sprite.setOrigin(sprite.getWidth()/2f, sprite.getHeight()/2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,5 +106,18 @@ public class Shard extends Actor implements Entity, Poolable {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setRate(float rate) {
|
||||||
|
this.rate = rate;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPosition(float x, float y) {
|
||||||
|
super.setPosition(x-center.x, y-center.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector2 getCenter() {
|
||||||
|
return center;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,18 +35,15 @@ public VoidCircle(ShapeRenderer shapeRenderer) {
|
|||||||
warnTime = warningTime;
|
warnTime = warningTime;
|
||||||
this.endRadius = endRadius;
|
this.endRadius = endRadius;
|
||||||
setSize(2f*endRadius, 2f*endRadius);
|
setSize(2f*endRadius, 2f*endRadius);
|
||||||
setX(x - getWidth()/2f);
|
center.set(getWidth()/2f, getHeight()/2f);
|
||||||
setY(y - getWidth()/2f);
|
setPosition(x-center.x, y-center.y);
|
||||||
this.growthRate = growthRate;
|
this.growthRate = growthRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void act(float delta) {
|
public void act(float delta) {
|
||||||
toFront();
|
toFront();
|
||||||
|
hitBox.setCenter(getX()+center.x, getY()+center.y);
|
||||||
center.x = getX()+getWidth()/2f;
|
|
||||||
center.y = getY()+getHeight()/2f;
|
|
||||||
hitBox.setCenter(center.x, center.y);
|
|
||||||
|
|
||||||
if (timer > 0) {
|
if (timer > 0) {
|
||||||
timer -= delta;
|
timer -= delta;
|
||||||
@ -74,11 +71,11 @@ public VoidCircle(ShapeRenderer shapeRenderer) {
|
|||||||
if (begin) {
|
if (begin) {
|
||||||
shapeRenderer.set(ShapeType.Filled);
|
shapeRenderer.set(ShapeType.Filled);
|
||||||
shapeRenderer.setColor(Color.BLACK);
|
shapeRenderer.setColor(Color.BLACK);
|
||||||
shapeRenderer.circle(center.x, center.y, currentRadius, 48);
|
shapeRenderer.circle(getX()+center.x, getY()+center.y, currentRadius, 48);
|
||||||
} else {
|
} else {
|
||||||
shapeRenderer.set(ShapeType.Line);
|
shapeRenderer.set(ShapeType.Line);
|
||||||
shapeRenderer.setColor(1 - timer/warnTime, 1 - timer/warnTime, 1 - timer/warnTime, 1f);
|
shapeRenderer.setColor(1 - timer/warnTime, 1 - timer/warnTime, 1 - timer/warnTime, 1f);
|
||||||
shapeRenderer.circle(center.x, center.y, endRadius, 48);
|
shapeRenderer.circle(getX()+center.x, getY()+center.y, endRadius, 48);
|
||||||
}
|
}
|
||||||
shapeRenderer.end();
|
shapeRenderer.end();
|
||||||
batch.begin();
|
batch.begin();
|
||||||
|
@ -15,6 +15,7 @@ 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;
|
||||||
import zero1hd.polyjet.entity.enemies.Bar;
|
import zero1hd.polyjet.entity.enemies.Bar;
|
||||||
|
import zero1hd.polyjet.entity.enemies.Flake;
|
||||||
import zero1hd.polyjet.entity.enemies.Pellet;
|
import zero1hd.polyjet.entity.enemies.Pellet;
|
||||||
import zero1hd.polyjet.entity.enemies.Shard;
|
import zero1hd.polyjet.entity.enemies.Shard;
|
||||||
import zero1hd.polyjet.entity.enemies.VoidCircle;
|
import zero1hd.polyjet.entity.enemies.VoidCircle;
|
||||||
@ -29,6 +30,8 @@ public class SpawnerWindow extends Window {
|
|||||||
private Slider mod1;
|
private Slider mod1;
|
||||||
private Slider mod2;
|
private Slider mod2;
|
||||||
private Slider mod3;
|
private Slider mod3;
|
||||||
|
private Slider mod4;
|
||||||
|
|
||||||
public SpawnerWindow(String title, Skin skin, EntityController ec, Stage stageForEntities) {
|
public SpawnerWindow(String title, Skin skin, EntityController ec, Stage stageForEntities) {
|
||||||
super(title, skin);
|
super(title, skin);
|
||||||
this.ec = ec;
|
this.ec = ec;
|
||||||
@ -37,13 +40,15 @@ public class SpawnerWindow extends Window {
|
|||||||
mod1 = new Slider(0.1f, 50f, 0.01f, true, skin);
|
mod1 = new Slider(0.1f, 50f, 0.01f, true, skin);
|
||||||
mod2 = new Slider(0f, 15f, 0.01f, true, skin);
|
mod2 = new Slider(0f, 15f, 0.01f, true, skin);
|
||||||
mod3 = new Slider(0.1f, 15f, 0.01f, true, skin);
|
mod3 = new Slider(0.1f, 15f, 0.01f, true, skin);
|
||||||
|
mod4 = new Slider(1f, 8f, 0.01f, true, skin);
|
||||||
|
|
||||||
listOfEntities = new List<>(skin);
|
listOfEntities = new List<>(skin);
|
||||||
listOfEntities.setItems(Entities.values());
|
listOfEntities.setItems(Entities.values());
|
||||||
|
|
||||||
scroller = new ScrollPane(listOfEntities);
|
scroller = new ScrollPane(listOfEntities);
|
||||||
add(scroller).expandY().fillY().spaceRight(15f);
|
add(scroller).expandY().fillY().spaceRight(15f);
|
||||||
add(mod1, mod2, mod3);
|
|
||||||
|
add(mod1, mod2, mod3, mod4);
|
||||||
|
|
||||||
setSize(300f, 375f);
|
setSize(300f, 375f);
|
||||||
}
|
}
|
||||||
@ -89,6 +94,15 @@ public class SpawnerWindow extends Window {
|
|||||||
bar.init(coords.x, mod1.getValue());
|
bar.init(coords.x, mod1.getValue());
|
||||||
stage.addActor(bar);
|
stage.addActor(bar);
|
||||||
break;
|
break;
|
||||||
|
case FLAKE:
|
||||||
|
Shard[] shards = new Shard[(int) mod4.getValue()];
|
||||||
|
for (int i = 0; i < shards.length; i++) {
|
||||||
|
shards[i].init(coords.x, coords.y, 360f/shards.length*i, 0f, (int) mod3.getValue());
|
||||||
|
stage.addActor(shards[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Flake flake = (Flake) entity;
|
||||||
|
flake.init(coords.x, coords.y, mod1.getValue(), mod3.getValue(), mod2.getValue()/mod2.getMaxValue()*360f, shards);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|