From b80aca0e2980d97b0a101b79385e1909fac36013 Mon Sep 17 00:00:00 2001 From: Recrown Date: Sat, 3 Jun 2017 23:26:03 -0500 Subject: [PATCH] began work on flake entity --- android/assets/1280x720/bar.png | Bin 109 -> 113 bytes android/assets/1280x720/flake.png | Bin 0 -> 161 bytes android/assets/1280x800/bar.png | Bin 116 -> 117 bytes android/assets/1280x800/flake.png | Bin 0 -> 241 bytes android/assets/1366x768/bar.png | Bin 111 -> 116 bytes android/assets/1366x768/flake.png | Bin 0 -> 229 bytes android/assets/1920x1080/bar.png | Bin 131 -> 132 bytes android/assets/1920x1080/flake.png | Bin 0 -> 275 bytes android/assets/1920x1200/bar.png | Bin 135 -> 135 bytes android/assets/1920x1200/flake.png | Bin 0 -> 319 bytes android/assets/2560x1440/bar.png | Bin 143 -> 143 bytes android/assets/2560x1440/flake.png | Bin 0 -> 266 bytes android/assets/3840x2160/bar.png | Bin 234 -> 232 bytes android/assets/3840x2160/flake.png | Bin 0 -> 547 bytes android/assets/800x480/bar.png | Bin 96 -> 97 bytes android/assets/800x480/flake.png | Bin 0 -> 137 bytes core/src/zero1hd/polyjet/Polyjet.java | 1 + core/src/zero1hd/polyjet/entity/Entities.java | 2 +- .../polyjet/entity/EntityController.java | 24 ++++- .../zero1hd/polyjet/entity/enemies/Flake.java | 94 ++++++++++++++++++ .../zero1hd/polyjet/entity/enemies/Shard.java | 15 ++- .../polyjet/entity/enemies/VoidCircle.java | 13 +-- .../polyjet/ui/windows/SpawnerWindow.java | 16 ++- 23 files changed, 149 insertions(+), 16 deletions(-) create mode 100755 android/assets/1280x720/flake.png create mode 100755 android/assets/1280x800/flake.png create mode 100755 android/assets/1366x768/flake.png create mode 100755 android/assets/1920x1080/flake.png create mode 100755 android/assets/1920x1200/flake.png create mode 100755 android/assets/2560x1440/flake.png create mode 100755 android/assets/3840x2160/flake.png create mode 100755 android/assets/800x480/flake.png create mode 100755 core/src/zero1hd/polyjet/entity/enemies/Flake.java diff --git a/android/assets/1280x720/bar.png b/android/assets/1280x720/bar.png index eff4ab3047d18c588ce25c5dc84f0a3d367423d1..0c5d015670b46bd7081a12676e245814c6d3fff6 100755 GIT binary patch delta 82 zcmc~ToS@=s;pyTSQgJIeA>zk>V}bi}M_E3mvndodCm#HNF3^Xe`B0|G1~=wxDAAUm g&}$~!kz>Wcu;QK5xsS`{<}v_*r>mdKI;Vst0E^xs0{{R3 delta 78 zcmXTSouJ}r;_2cTQgJIeA>zk>O@VxwqbwhT*%UT*C5i~JJt&akU32jOj7XG@SnSKL bG@Fm%^8fO4k&ef78Gyjk)z4*}Q$iB}u%8`j diff --git a/android/assets/1280x720/flake.png b/android/assets/1280x720/flake.png new file mode 100755 index 0000000000000000000000000000000000000000..d60baf80d3f2febf3425c3a5d1617cfbdd654b38 GIT binary patch literal 161 zcmeAS@N?(olHy`uVBq!ia0vp^{2=Ec1vOt+k;CU7Z{wR3Z)#@ zxUFGpSi~%{>PSXQ;)JRRcBgWdoj5PjZg%vePa)T0i`>bRRx@ms&F)Tq`g{k_P6kg` KKbLh*2~7Yh;5|G5 literal 0 HcmV?d00001 diff --git a/android/assets/1280x800/bar.png b/android/assets/1280x800/bar.png index 195bca693c0871a00ebc3536088764deb4ef7a19..a11fa6161a39461833e02947cf24e8ff92d05f8b 100755 GIT binary patch delta 86 zcmXRZouCqEzk>b^&|Yqau&xc^n=w9&Y+Sckv7-9gTe~DWM4f4e25d delta 85 zcmXRdnV=G2?djqeQgJIeA>zw_=EH~ntGgMtN{IA19FuDcbg*P-f1Huf$My_NXh`s$ mxp+Y4Riovtb4#MEg&7_#->Ab|D)xy12s~Z=T-G@yGywn$A0n{; diff --git a/android/assets/1280x800/flake.png b/android/assets/1280x800/flake.png new file mode 100755 index 0000000000000000000000000000000000000000..32dd874aa8482fb8e893dea1f54a022b6bec130b GIT binary patch literal 241 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2e89iA?ZAr-fh6Am!{`~P2`zk>Re^k&qbU!k^Ef1FAJ$OdZ#bN1!r;za03#S#87*%0 dELXLn>}1Cmdk@_y4~<(;=QG z4dwR#-ScWc{Ab{3zM+!&@5AT%AG@mmfA7}+HJ|H{f|*Cp0=EUll8s!>*Y5wX_egp8 zU!+a)f3kzb5w_08Ck|O3Zpv)>c<}#WrqBP?51Je{@ZeEl4{E-AQz3dorkfedt4Ret z49q`;Z{FNt;KA#mYm?x3k%cQWAVKgF&tZkF3bqe4mfc|J+UqdYVTqSXkg8(foGB}( d&Ga~VjzOfO!k{O;eHYN(44$rjF6*2UngH&uUUvWh literal 0 HcmV?d00001 diff --git a/android/assets/1920x1080/bar.png b/android/assets/1920x1080/bar.png index a365736113116892e442e1a33aa2cdbf94526139..38370e23922bcddedcc359434d164b7953cb8032 100755 GIT binary patch delta 103 zcmZo>Y+;;uunK>+SW0q74o_E(f>pGetefD0wJQ(!h~_#N|lc)==ezJDa@9<% z`JQv zuIB>aV@#Rdkc+_k3*qv>jd?Hug04@5aKvG}#e$i2u|Nb=1Z~dP*DK825))?DAAza} z98TEPYs?9jV9ot30RcA=F!}*YaKF(C^Z{oHXuv9g&J_x9Dv;cP{|kP*LJ3YUIdPHy zY7qKY?3Nq+o}8}H*wXAgHb@Crf*kV5wLQ7%KR0)axzEiz)ckERe-+K&bMr}LK0`~U Ze+vdg5v7N2oZf*+tyB{j>XC yasM>w?%meidb<{P^u2(fKL)${V@~$Vw8mULXTLjaPG&6w5O})!xvX#c2h->yx!AI&}| x|La6p)c%(|vbz>=Ls4DFJLT&il+)LKV~|mwng7N-u89E%JYD@<);T3K0RZZ9Dh~hv diff --git a/android/assets/1920x1200/flake.png b/android/assets/1920x1200/flake.png new file mode 100755 index 0000000000000000000000000000000000000000..c2fa5c5963e35f947c9d3e8d21a914e17db26f12 GIT binary patch literal 319 zcmV-F0l@x=P)P000>X1^@s6#OZ}&00037Nklf@iT5ODpjZojzm8A7NwSEDXc$ z&d$H{+zo;pLsI2VO?dE+f#UO3qeG$?UOLcSVR%e5oNpDiR_ei-vtF77r;7%Qt=6@P zIze9zICItuTf|LKwA^b~9jgt1Bj&89K;h38;1X{93h)fXe(JhPZh$z^Xtq)0T=b3D zM-F*!AQxl~)~D)b0XRYqd9P&n6l7oWN`|Z;`%-2y_yjo*&|5ONN~XZ_x+u$a=zDYq zdJ(OHN-hJy5&F=Jej7_nVq%tEW_4m#@n*fttP7jHCuT3B*&A>6TPgbQx&ehYlRZD3 R%s>DD002ovPDHLkV1h95hfx3k literal 0 HcmV?d00001 diff --git a/android/assets/2560x1440/bar.png b/android/assets/2560x1440/bar.png index 92dec63f3a9f5fc22aeb721c5c0c15f0bebafe7b..c1dd2a2e8d3ee20061908f391a65893b1bf06fe2 100755 GIT binary patch delta 104 zcmV-u0GI!d0gnNYE@2J8AP@w>Z=Wu30hU|_T|Kr$;G8F$V5BQxvx~Sgq1+ndbwh#i z59^7Z4YqwP2@7E%EQBR2goUsWmaq^O!a`WW;!s$=LXLceP-+62mb%=Ffw-#x0000< KMNUMnLSTZ8fGS7; delta 104 zcmV-u0GI!d0gnNYE@2VCAPfXSRY*orbb)D9HY9F9WP3BO3N};3lWA7Ib7qcj&8%SK zhqbbYRMEBsmcSBN0t+mGC9nh*SOQC62`sR51(si-UHKK774HSvr@Y=k`Pf7N0000< KMNUMnLSTXi)hJH@ diff --git a/android/assets/2560x1440/flake.png b/android/assets/2560x1440/flake.png new file mode 100755 index 0000000000000000000000000000000000000000..909d5fb0a75963d636ce9325d9f92ec5ce961213 GIT binary patch literal 266 zcmV+l0rmcgP)?pf zi3dPVg(J^kmPx#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D02y>eSaefwW^{L9 za%BK;VQFr3E^cLXAT%y8E-^MlX|MGF00EOpL_t(&L)Fg+{F;4yo4tJ6E3UZ5KE3Xe94iap_b;=@H+vqQ>;YHYd&A{e(E`kRz~xw2 z6x<6g$AXez<_VW$X4zoo1(#z+#bD+Emt&%8Fl&X&aiwN3Yk|u#k{g)S!sRG(2eTTu z9PjD|W~FdB&gu?kC2%=TZ3bq!a5;``4rV#<#W1!Tn5E$VZpL;8vo-i3!7K*9fycrV z$5Frx9=N6x-~i*PIUGD9sWAhqGost7|AiCYIrLc z$uYBHxCa=?v7l_Y7Z}O0uq50QjO18R6z&a1a;$6t?*T?~Y$(9-q;Zyiw-|u);|fM{ lbck?wFp{HFo&FoQ;SbUjf&9yHdrtrW002ovPDHLkV1hqe>L>sJ literal 0 HcmV?d00001 diff --git a/android/assets/800x480/bar.png b/android/assets/800x480/bar.png index 4d25b31465252086c0a77caefe9f0ebd7aafb810..00aae1a94593cb03f671f280284add57489d2581 100755 GIT binary patch delta 66 zcmYdDoS;pyTSQgJIeA>zk>F@g7zkA8?TPq=Yu>5?cqcJe>zJw|6x$!l5DeL_?>t~x%s^EVWoZs27%t& UmhnQ3=NN#%)78&qol`;+0B%(o6951J diff --git a/android/assets/800x480/flake.png b/android/assets/800x480/flake.png new file mode 100755 index 0000000000000000000000000000000000000000..facd5c0edb54cc70093a4ad4e4c1c37bf9e46607 GIT binary patch literal 137 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f41$eqRhE&{2PH=V4GE)Em literal 0 HcmV?d00001 diff --git a/core/src/zero1hd/polyjet/Polyjet.java b/core/src/zero1hd/polyjet/Polyjet.java index dc7e2fa..d1ee508 100755 --- a/core/src/zero1hd/polyjet/Polyjet.java +++ b/core/src/zero1hd/polyjet/Polyjet.java @@ -127,6 +127,7 @@ public class Polyjet extends Game { assetManager.load("pellet.png", Texture.class); assetManager.load("shard.png", Texture.class); assetManager.load("bar.png", Texture.class); + assetManager.load("flake.png", Texture.class); } public void generateFonts() { initComplete = true; diff --git a/core/src/zero1hd/polyjet/entity/Entities.java b/core/src/zero1hd/polyjet/entity/Entities.java index 3185d61..f36ca74 100755 --- a/core/src/zero1hd/polyjet/entity/Entities.java +++ b/core/src/zero1hd/polyjet/entity/Entities.java @@ -1,7 +1,7 @@ package zero1hd.polyjet.entity; public enum Entities { - POLYJET, BAR, VOID_CIRCLE, SHARD, LASER, PELLET; + POLYJET, BAR, VOID_CIRCLE, SHARD, LASER, PELLET, FLAKE; public float x; public float y; diff --git a/core/src/zero1hd/polyjet/entity/EntityController.java b/core/src/zero1hd/polyjet/entity/EntityController.java index c04c758..7814abb 100755 --- a/core/src/zero1hd/polyjet/entity/EntityController.java +++ b/core/src/zero1hd/polyjet/entity/EntityController.java @@ -8,6 +8,7 @@ import com.badlogic.gdx.utils.Pool; import zero1hd.polyjet.entity.ally.Laser; 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; @@ -24,9 +25,11 @@ public class EntityController { private Pool pelletPool; private Pool shardPool; private Pool barPool; + private Pool flakePool; //Ally pool declaration; private Pool laserPool; + public EntityController(AssetManager assetManager, ShapeRenderer shapeRenderer) { activeAllies = new Array(); activeEnemies = new Array(); @@ -60,6 +63,12 @@ public class EntityController { return new Bar(assets.get("bar.png", Texture.class)); } }; + flakePool = new Pool() { + @Override + protected Flake newObject() { + return new Flake(assets.get("flake.png", Texture.class)); + } + }; //Ally pool initialization; laserPool = new Pool() { @@ -93,42 +102,47 @@ public class EntityController { Bar bar = barPool.obtain(); activeEnemies.add(bar); return bar; + case FLAKE: + Flake flake = flakePool.obtain(); + activeEnemies.add(flake); + return flake; default: return null; } } public void free(Entity entity) { + activeEnemies.removeValue(entity, true); switch (entity.getEntityType()) { case VOID_CIRCLE: VoidCircle voidCircle = (VoidCircle) entity; voidCircle.remove(); - activeEnemies.removeValue(entity, true); voidCirclePool.free(voidCircle); break; case LASER: Laser laser = (Laser) entity; laser.remove(); - activeAllies.removeValue(entity, true); laserPool.free(laser); break; case PELLET: Pellet pellet = (Pellet) entity; pellet.remove(); - activeEnemies.removeValue(entity, true); pelletPool.free(pellet); break; case SHARD: Shard shard = (Shard) entity; shard.remove(); - activeEnemies.removeValue(entity, true); shardPool.free(shard); break; case BAR: Bar bar = (Bar) entity; bar.remove(); - activeEnemies.removeValue(entity, true); barPool.free(bar); + break; + case FLAKE: + Flake flake = (Flake) entity; + flake.remove(); + flakePool.free(flake); default: break; } diff --git a/core/src/zero1hd/polyjet/entity/enemies/Flake.java b/core/src/zero1hd/polyjet/entity/enemies/Flake.java new file mode 100755 index 0000000..bdee48d --- /dev/null +++ b/core/src/zero1hd/polyjet/entity/enemies/Flake.java @@ -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); + } + +} diff --git a/core/src/zero1hd/polyjet/entity/enemies/Shard.java b/core/src/zero1hd/polyjet/entity/enemies/Shard.java index f7e7a2a..c0ab8fc 100755 --- a/core/src/zero1hd/polyjet/entity/enemies/Shard.java +++ b/core/src/zero1hd/polyjet/entity/enemies/Shard.java @@ -40,7 +40,7 @@ public class Shard extends Actor implements Entity, Poolable { setSize(2f, 2f); hitbox.setSize(getWidth(), getHeight()); center.set(getWidth()/2f, getHeight()/2f); - setPosition(x-center.x, y-center.y); + setPosition(x, y); sprite.setOrigin(sprite.getWidth()/2f, sprite.getHeight()/2f); } @@ -106,5 +106,18 @@ public class Shard extends Actor implements Entity, Poolable { } 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; + } } diff --git a/core/src/zero1hd/polyjet/entity/enemies/VoidCircle.java b/core/src/zero1hd/polyjet/entity/enemies/VoidCircle.java index d7778b8..e89789b 100755 --- a/core/src/zero1hd/polyjet/entity/enemies/VoidCircle.java +++ b/core/src/zero1hd/polyjet/entity/enemies/VoidCircle.java @@ -35,18 +35,15 @@ public VoidCircle(ShapeRenderer shapeRenderer) { warnTime = warningTime; this.endRadius = endRadius; setSize(2f*endRadius, 2f*endRadius); - setX(x - getWidth()/2f); - setY(y - getWidth()/2f); + center.set(getWidth()/2f, getHeight()/2f); + setPosition(x-center.x, y-center.y); this.growthRate = growthRate; } @Override public void act(float delta) { toFront(); - - center.x = getX()+getWidth()/2f; - center.y = getY()+getHeight()/2f; - hitBox.setCenter(center.x, center.y); + hitBox.setCenter(getX()+center.x, getY()+center.y); if (timer > 0) { timer -= delta; @@ -74,11 +71,11 @@ public VoidCircle(ShapeRenderer shapeRenderer) { if (begin) { shapeRenderer.set(ShapeType.Filled); shapeRenderer.setColor(Color.BLACK); - shapeRenderer.circle(center.x, center.y, currentRadius, 48); + shapeRenderer.circle(getX()+center.x, getY()+center.y, currentRadius, 48); } else { shapeRenderer.set(ShapeType.Line); 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(); batch.begin(); diff --git a/core/src/zero1hd/polyjet/ui/windows/SpawnerWindow.java b/core/src/zero1hd/polyjet/ui/windows/SpawnerWindow.java index e035a31..84e936f 100755 --- a/core/src/zero1hd/polyjet/ui/windows/SpawnerWindow.java +++ b/core/src/zero1hd/polyjet/ui/windows/SpawnerWindow.java @@ -15,6 +15,7 @@ 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.Flake; import zero1hd.polyjet.entity.enemies.Pellet; import zero1hd.polyjet.entity.enemies.Shard; import zero1hd.polyjet.entity.enemies.VoidCircle; @@ -29,6 +30,8 @@ public class SpawnerWindow extends Window { private Slider mod1; private Slider mod2; private Slider mod3; + private Slider mod4; + public SpawnerWindow(String title, Skin skin, EntityController ec, Stage stageForEntities) { super(title, skin); this.ec = ec; @@ -37,13 +40,15 @@ public class SpawnerWindow extends Window { mod1 = new Slider(0.1f, 50f, 0.01f, true, skin); mod2 = new Slider(0f, 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.setItems(Entities.values()); scroller = new ScrollPane(listOfEntities); add(scroller).expandY().fillY().spaceRight(15f); - add(mod1, mod2, mod3); + + add(mod1, mod2, mod3, mod4); setSize(300f, 375f); } @@ -89,6 +94,15 @@ public class SpawnerWindow extends Window { bar.init(coords.x, mod1.getValue()); stage.addActor(bar); 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: break; }