From 53ff7109b2d59c330ac5737fcfe4909923bc70c4 Mon Sep 17 00:00:00 2001 From: Recrown Date: Sat, 3 Jun 2017 00:24:56 -0500 Subject: [PATCH] added bar entity --- android/assets/1280x720/bar.png | Bin 0 -> 109 bytes android/assets/1280x800/bar.png | Bin 0 -> 116 bytes android/assets/1366x768/bar.png | Bin 0 -> 111 bytes android/assets/1920x1080/bar.png | Bin 0 -> 131 bytes android/assets/1920x1200/bar.png | Bin 0 -> 135 bytes android/assets/2560x1440/bar.png | Bin 0 -> 143 bytes android/assets/3840x2160/bar.png | Bin 0 -> 234 bytes android/assets/800x480/bar.png | Bin 0 -> 96 bytes core/src/zero1hd/polyjet/Polyjet.java | 1 + core/src/zero1hd/polyjet/entity/Entities.java | 2 +- .../polyjet/entity/EntityController.java | 18 ++++ .../zero1hd/polyjet/entity/enemies/Bar.java | 82 ++++++++++++++++++ .../zero1hd/polyjet/entity/enemies/Shard.java | 2 +- .../polyjet/ui/stages/GamePlayArea.java | 2 +- .../polyjet/ui/windows/SpawnerWindow.java | 9 +- 15 files changed, 111 insertions(+), 5 deletions(-) create mode 100755 android/assets/1280x720/bar.png create mode 100755 android/assets/1280x800/bar.png create mode 100755 android/assets/1366x768/bar.png create mode 100755 android/assets/1920x1080/bar.png create mode 100755 android/assets/1920x1200/bar.png create mode 100755 android/assets/2560x1440/bar.png create mode 100755 android/assets/3840x2160/bar.png create mode 100755 android/assets/800x480/bar.png create mode 100755 core/src/zero1hd/polyjet/entity/enemies/Bar.java diff --git a/android/assets/1280x720/bar.png b/android/assets/1280x720/bar.png new file mode 100755 index 0000000000000000000000000000000000000000..eff4ab3047d18c588ce25c5dc84f0a3d367423d1 GIT binary patch literal 109 zcmeAS@N?(olHy`uVBq!ia0vp^-ayR3!3HEZHZf@cDHBf@$B>F!$q5lZ{%Z>4%N%9- z7|f=yu`5wTfbBtn6z`gg2Vg{^bi`s`cBR>T4440xpNn)nrVG^1;OXk;vd$@?2>{jC BASwU= literal 0 HcmV?d00001 diff --git a/android/assets/1280x800/bar.png b/android/assets/1280x800/bar.png new file mode 100755 index 0000000000000000000000000000000000000000..195bca693c0871a00ebc3536088764deb4ef7a19 GIT binary patch literal 116 zcmeAS@N?(olHy`uVBq!ia0vp^!9dK(!3HG#mJ3V-Qr4a>jv*Ddk`p4n{AWIV=)by~ zVXK5lpTjY^wm=6b!3HGr&QzEKDKk$O$B>F!$q5lZ{;LY)%N$L4 zIGx8KN&B#d0)NBdJQD_Y<^mYO$jWGOt7qW?NoI!71!3HEl4+WhEQeK`ejv*Dd-d^9x+hD-s61cqW z@9%(3Ph1x!Fmo;bzVtKG`l72oYktlve!fP#-Sl=@wczBySJ%s$IRXV(0|gYh7VUHR g^5*}8o7=BN-))d^)-m?Z0Gi6+>FVdQ&MBb@069Z3hX4Qo literal 0 HcmV?d00001 diff --git a/android/assets/1920x1200/bar.png b/android/assets/1920x1200/bar.png new file mode 100755 index 0000000000000000000000000000000000000000..487342c95ed199cbe41b2eeccfcf757659c77007 GIT binary patch literal 135 zcmeAS@N?(olHy`uVBq!ia0vp^wIDVJ8<1>Sl=uWl`FXlHhE&{odt)PSg98tXqqvik zbP0FO{PuYbQWvVjtjrB&u0D5U)?3^1zFnJcKbn0`{@01HsQoW_WOps#hN8NTcgoj4 dD5tOe#vr3UGyjcwToce_22WQ%mvv4FO#pcHGEV>i literal 0 HcmV?d00001 diff --git a/android/assets/2560x1440/bar.png b/android/assets/2560x1440/bar.png new file mode 100755 index 0000000000000000000000000000000000000000..92dec63f3a9f5fc22aeb721c5c0c15f0bebafe7b GIT binary patch literal 143 zcmeAS@N?(olHy`uVBq!ia0vp^(}0+tgAGWsWte3GsW49$$B>F!Z*OiCJfOhC;uz}T z7Fg1l8DgfA=a5ouyq?P}_{ikUuzkg8efekCBs^~4x~VTD=soff|^_NVA9(f6!3m+!gf@biWX&;|xiS3j3^P6 activeAllies; public Array activeEnemies; + //Enemy pool declaration; private Pool voidCirclePool; private Pool pelletPool; private Pool shardPool; + private Pool barPool; //Ally pool declaration; private Pool laserPool; @@ -51,6 +54,12 @@ public class EntityController { return new Shard(assets.get("shard.png", Texture.class)); } }; + barPool = new Pool() { + @Override + protected Bar newObject() { + return new Bar(assets.get("bar.png", Texture.class)); + } + }; //Ally pool initialization; laserPool = new Pool() { @@ -80,6 +89,10 @@ public class EntityController { Shard shard = shardPool.obtain(); activeEnemies.add(shard); return shard; + case BAR: + Bar bar = barPool.obtain(); + activeEnemies.add(bar); + return bar; default: return null; } @@ -111,6 +124,11 @@ public class EntityController { activeEnemies.removeValue(entity, true); shardPool.free(shard); break; + case BAR: + Bar bar = (Bar) entity; + bar.remove(); + activeEnemies.removeValue(entity, true); + barPool.free(bar); default: break; } diff --git a/core/src/zero1hd/polyjet/entity/enemies/Bar.java b/core/src/zero1hd/polyjet/entity/enemies/Bar.java new file mode 100755 index 0000000..39ebfae --- /dev/null +++ b/core/src/zero1hd/polyjet/entity/enemies/Bar.java @@ -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; + } + +} diff --git a/core/src/zero1hd/polyjet/entity/enemies/Shard.java b/core/src/zero1hd/polyjet/entity/enemies/Shard.java index 2afacff..f7e7a2a 100755 --- a/core/src/zero1hd/polyjet/entity/enemies/Shard.java +++ b/core/src/zero1hd/polyjet/entity/enemies/Shard.java @@ -35,12 +35,12 @@ public class Shard extends Actor implements Entity, Poolable { this.rate = rate; this.hp = hp; maxHp = hp; - setPosition(x, y); this.angle.set(MathUtils.sinDeg(angle), MathUtils.cosDeg(angle)); sprite.setRotation(-angle); setSize(2f, 2f); hitbox.setSize(getWidth(), getHeight()); center.set(getWidth()/2f, getHeight()/2f); + setPosition(x-center.x, y-center.y); sprite.setOrigin(sprite.getWidth()/2f, sprite.getHeight()/2f); } diff --git a/core/src/zero1hd/polyjet/ui/stages/GamePlayArea.java b/core/src/zero1hd/polyjet/ui/stages/GamePlayArea.java index 2dc659f..4a5eb0e 100755 --- a/core/src/zero1hd/polyjet/ui/stages/GamePlayArea.java +++ b/core/src/zero1hd/polyjet/ui/stages/GamePlayArea.java @@ -120,7 +120,7 @@ public class GamePlayArea extends Stage { if (keycode == KeyMap.shoot) { 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); } return false; diff --git a/core/src/zero1hd/polyjet/ui/windows/SpawnerWindow.java b/core/src/zero1hd/polyjet/ui/windows/SpawnerWindow.java index 2889ccd..e035a31 100755 --- a/core/src/zero1hd/polyjet/ui/windows/SpawnerWindow.java +++ b/core/src/zero1hd/polyjet/ui/windows/SpawnerWindow.java @@ -14,6 +14,7 @@ import zero1hd.polyjet.entity.Entities; import zero1hd.polyjet.entity.Entity; import zero1hd.polyjet.entity.EntityController; import zero1hd.polyjet.entity.ally.Laser; +import zero1hd.polyjet.entity.enemies.Bar; import zero1hd.polyjet.entity.enemies.Pellet; import zero1hd.polyjet.entity.enemies.Shard; import zero1hd.polyjet.entity.enemies.VoidCircle; @@ -63,8 +64,6 @@ public class SpawnerWindow extends Window { Entity entity; if ((entity = ec.retrieveEntity(listOfEntities.getSelected())) != null) { switch(entity.getEntityType()) { - case BAR_BEAT: - break; case LASER: Laser laser = (Laser) entity; laser.init(coords.x, coords.y, mod1.getValue()); @@ -84,6 +83,12 @@ public class SpawnerWindow extends Window { Shard shard = (Shard) entity; shard.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue(), (int) mod3.getValue()); stage.addActor(shard); + break; + case BAR: + Bar bar = (Bar) entity; + bar.init(coords.x, mod1.getValue()); + stage.addActor(bar); + break; default: break; }