added bar entity
BIN
android/assets/1280x720/bar.png
Executable file
After Width: | Height: | Size: 109 B |
BIN
android/assets/1280x800/bar.png
Executable file
After Width: | Height: | Size: 116 B |
BIN
android/assets/1366x768/bar.png
Executable file
After Width: | Height: | Size: 111 B |
BIN
android/assets/1920x1080/bar.png
Executable file
After Width: | Height: | Size: 131 B |
BIN
android/assets/1920x1200/bar.png
Executable file
After Width: | Height: | Size: 135 B |
BIN
android/assets/2560x1440/bar.png
Executable file
After Width: | Height: | Size: 143 B |
BIN
android/assets/3840x2160/bar.png
Executable file
After Width: | Height: | Size: 234 B |
BIN
android/assets/800x480/bar.png
Executable file
After Width: | Height: | Size: 96 B |
@ -126,6 +126,7 @@ public class Polyjet extends Game {
|
|||||||
assetManager.load("laser.png", Texture.class);
|
assetManager.load("laser.png", Texture.class);
|
||||||
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);
|
||||||
}
|
}
|
||||||
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_BEAT, VOID_CIRCLE, SHARD, LASER, PELLET;
|
POLYJET, BAR, VOID_CIRCLE, SHARD, LASER, PELLET;
|
||||||
|
|
||||||
public float x;
|
public float x;
|
||||||
public float y;
|
public float y;
|
||||||
|
@ -7,6 +7,7 @@ import com.badlogic.gdx.utils.Array;
|
|||||||
import com.badlogic.gdx.utils.Pool;
|
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.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;
|
||||||
@ -17,10 +18,12 @@ public class EntityController {
|
|||||||
|
|
||||||
public Array<Entity> activeAllies;
|
public Array<Entity> activeAllies;
|
||||||
public Array<Entity> activeEnemies;
|
public Array<Entity> activeEnemies;
|
||||||
|
|
||||||
//Enemy pool declaration;
|
//Enemy pool declaration;
|
||||||
private Pool<VoidCircle> voidCirclePool;
|
private Pool<VoidCircle> voidCirclePool;
|
||||||
private Pool<Pellet> pelletPool;
|
private Pool<Pellet> pelletPool;
|
||||||
private Pool<Shard> shardPool;
|
private Pool<Shard> shardPool;
|
||||||
|
private Pool<Bar> barPool;
|
||||||
|
|
||||||
//Ally pool declaration;
|
//Ally pool declaration;
|
||||||
private Pool<Laser> laserPool;
|
private Pool<Laser> laserPool;
|
||||||
@ -51,6 +54,12 @@ public class EntityController {
|
|||||||
return new Shard(assets.get("shard.png", Texture.class));
|
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));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//Ally pool initialization;
|
//Ally pool initialization;
|
||||||
laserPool = new Pool<Laser>() {
|
laserPool = new Pool<Laser>() {
|
||||||
@ -80,6 +89,10 @@ public class EntityController {
|
|||||||
Shard shard = shardPool.obtain();
|
Shard shard = shardPool.obtain();
|
||||||
activeEnemies.add(shard);
|
activeEnemies.add(shard);
|
||||||
return shard;
|
return shard;
|
||||||
|
case BAR:
|
||||||
|
Bar bar = barPool.obtain();
|
||||||
|
activeEnemies.add(bar);
|
||||||
|
return bar;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -111,6 +124,11 @@ public class EntityController {
|
|||||||
activeEnemies.removeValue(entity, true);
|
activeEnemies.removeValue(entity, true);
|
||||||
shardPool.free(shard);
|
shardPool.free(shard);
|
||||||
break;
|
break;
|
||||||
|
case BAR:
|
||||||
|
Bar bar = (Bar) entity;
|
||||||
|
bar.remove();
|
||||||
|
activeEnemies.removeValue(entity, true);
|
||||||
|
barPool.free(bar);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
82
core/src/zero1hd/polyjet/entity/enemies/Bar.java
Executable file
@ -0,0 +1,82 @@
|
|||||||
|
package zero1hd.polyjet.entity.enemies;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.Texture;
|
||||||
|
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.Polyjet;
|
||||||
|
import zero1hd.polyjet.entity.Entities;
|
||||||
|
import zero1hd.polyjet.entity.Entity;
|
||||||
|
|
||||||
|
public class Bar extends Actor implements Entity, Poolable {
|
||||||
|
private boolean dead;
|
||||||
|
private Texture texture;
|
||||||
|
private float rate;
|
||||||
|
private Rectangle hitbox;
|
||||||
|
|
||||||
|
public Bar(Texture barTexture) {
|
||||||
|
this.texture = barTexture;
|
||||||
|
hitbox = new Rectangle();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init(float x, float rate) {
|
||||||
|
setSize(5f, 0.5f);
|
||||||
|
setPosition(x, Polyjet.GAME_AREA_HEIGHT);
|
||||||
|
this.rate = rate;
|
||||||
|
hitbox.set(getX(), getY(), getWidth(), getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void act(float delta) {
|
||||||
|
moveBy(0f, -delta*rate);
|
||||||
|
hitbox.setPosition(getX(), getY());
|
||||||
|
super.act(delta);
|
||||||
|
if (getY() < 0-getHeight()) {
|
||||||
|
dead = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Batch batch, float parentAlpha) {
|
||||||
|
batch.draw(texture, getX(), getY(), getWidth(), getHeight());
|
||||||
|
super.draw(batch, parentAlpha);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reset() {
|
||||||
|
hitbox.set(0, 0, 0, 0);
|
||||||
|
setPosition(0, 0);
|
||||||
|
rate = 0;
|
||||||
|
dead = false;
|
||||||
|
setSize(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void collided(Entity entity) {
|
||||||
|
switch (entity.getEntityType()) {
|
||||||
|
case POLYJET:
|
||||||
|
dead = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Rectangle getHitZone() {
|
||||||
|
return hitbox;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Entities getEntityType() {
|
||||||
|
return Entities.BAR;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDead() {
|
||||||
|
return dead;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -35,12 +35,12 @@ public class Shard extends Actor implements Entity, Poolable {
|
|||||||
this.rate = rate;
|
this.rate = rate;
|
||||||
this.hp = hp;
|
this.hp = hp;
|
||||||
maxHp = hp;
|
maxHp = hp;
|
||||||
setPosition(x, y);
|
|
||||||
this.angle.set(MathUtils.sinDeg(angle), MathUtils.cosDeg(angle));
|
this.angle.set(MathUtils.sinDeg(angle), MathUtils.cosDeg(angle));
|
||||||
sprite.setRotation(-angle);
|
sprite.setRotation(-angle);
|
||||||
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);
|
||||||
sprite.setOrigin(sprite.getWidth()/2f, sprite.getHeight()/2f);
|
sprite.setOrigin(sprite.getWidth()/2f, sprite.getHeight()/2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ public class GamePlayArea extends Stage {
|
|||||||
|
|
||||||
if (keycode == KeyMap.shoot) {
|
if (keycode == KeyMap.shoot) {
|
||||||
Laser laser = (Laser) entityController.retrieveEntity(Entities.LASER);
|
Laser laser = (Laser) entityController.retrieveEntity(Entities.LASER);
|
||||||
laser.init(polyjet.getX() + (polyjet.getWidth()-laser.getWidth())/2f, polyjet.getY() + polyjet.getHeight()+0.25f, 30f);
|
laser.init(polyjet.getX() + (polyjet.getWidth()-laser.getWidth())/2f, polyjet.getY() + polyjet.getHeight()+0.25f, 60f);
|
||||||
addActor(laser);
|
addActor(laser);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -14,6 +14,7 @@ import zero1hd.polyjet.entity.Entities;
|
|||||||
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;
|
||||||
|
import zero1hd.polyjet.entity.enemies.Bar;
|
||||||
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;
|
||||||
@ -63,8 +64,6 @@ public class SpawnerWindow extends Window {
|
|||||||
Entity entity;
|
Entity entity;
|
||||||
if ((entity = ec.retrieveEntity(listOfEntities.getSelected())) != null) {
|
if ((entity = ec.retrieveEntity(listOfEntities.getSelected())) != null) {
|
||||||
switch(entity.getEntityType()) {
|
switch(entity.getEntityType()) {
|
||||||
case BAR_BEAT:
|
|
||||||
break;
|
|
||||||
case LASER:
|
case LASER:
|
||||||
Laser laser = (Laser) entity;
|
Laser laser = (Laser) entity;
|
||||||
laser.init(coords.x, coords.y, mod1.getValue());
|
laser.init(coords.x, coords.y, mod1.getValue());
|
||||||
@ -84,6 +83,12 @@ public class SpawnerWindow extends Window {
|
|||||||
Shard shard = (Shard) entity;
|
Shard shard = (Shard) entity;
|
||||||
shard.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue(), (int) mod3.getValue());
|
shard.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue(), (int) mod3.getValue());
|
||||||
stage.addActor(shard);
|
stage.addActor(shard);
|
||||||
|
break;
|
||||||
|
case BAR:
|
||||||
|
Bar bar = (Bar) entity;
|
||||||
|
bar.init(coords.x, mod1.getValue());
|
||||||
|
stage.addActor(bar);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|