From bed23303e4aee4d2a19898330adcd2100098509c Mon Sep 17 00:00:00 2001 From: Recrown Date: Thu, 10 Aug 2017 15:12:56 -0500 Subject: [PATCH] changed spawn algorithm to include flakes --- .../audio/map/RhythmMapAlgorithm.java | 31 +++++++--- .../zero1hd/rhythmbullet/entity/Entity.java | 4 ++ .../rhythmbullet/entity/EntityManager.java | 3 - .../rhythmbullet/entity/enemies/Bar.java | 60 ------------------- .../rhythmbullet/entity/enemies/Flake.java | 9 ++- .../entity/enemies/VoidCircle.java | 4 +- .../rhythmbullet/screens/CreativeScreen.java | 2 +- .../rhythmbullet/ui/stages/CreativeHUD.java | 9 ++- .../ui/windows/MusicController.java | 8 ++- .../ui/windows/SpawnerWindow.java | 5 -- 10 files changed, 51 insertions(+), 84 deletions(-) delete mode 100755 core/src/zero1hd/rhythmbullet/entity/enemies/Bar.java diff --git a/core/src/zero1hd/rhythmbullet/audio/map/RhythmMapAlgorithm.java b/core/src/zero1hd/rhythmbullet/audio/map/RhythmMapAlgorithm.java index 7e7712f..65c4607 100755 --- a/core/src/zero1hd/rhythmbullet/audio/map/RhythmMapAlgorithm.java +++ b/core/src/zero1hd/rhythmbullet/audio/map/RhythmMapAlgorithm.java @@ -88,14 +88,31 @@ public class RhythmMapAlgorithm implements Runnable { } if (umPeaks.get(index) != 0) { - if (umPeaks.get(index) >= avgUM) { - //If upper midrange peaks are greater than average, the: - int spawnLocations = (RhythmBullet.GAME_AREA_WIDTH-8)/8; + if (umPeaks.get(index) >= avgUM*1.75f) { + //If upper midrange peaks are greater than average, the: + esi = map.addEntity(em.flake, null); - esi = map.addEntity(em.bar, null); - esi.parameters.put("x", (float) (MathUtils.round(rand.nextFloat()*spawnLocations)*8)); - esi.parameters.put("rate", (8f/avgSPB)*speedMod); + float xSpawn = (rand.nextFloat()*RhythmBullet.GAME_AREA_WIDTH) < RhythmBullet.GAME_AREA_WIDTH/2f ? 0 : RhythmBullet.GAME_AREA_WIDTH; + float ySpawn = (rand.nextFloat()*RhythmBullet.GAME_AREA_HEIGHT < RhythmBullet.GAME_AREA_HEIGHT/2f ? 0 : RhythmBullet.GAME_AREA_HEIGHT); + float angle = rand.nextFloat()*90; + if (xSpawn == 0) { + if (ySpawn != 0) { + angle += 270; + } + } else { + if (ySpawn == 0) { + angle += 90; + } else { + angle += 180; + } + } + esi.parameters.put("shardCount", (1f+(difficultyMod/100f))*4f); + esi.parameters.put("x", xSpawn); + esi.parameters.put("y", ySpawn); + esi.parameters.put("rate", (5/avgSPB)*speedMod); + esi.parameters.put("fuse", avgSPB*10f); + esi.parameters.put("angle", angle); } else { float xSpawnLocation = (rand.nextFloat()*(RhythmBullet.GAME_AREA_WIDTH-2))+1; @@ -103,7 +120,7 @@ public class RhythmMapAlgorithm implements Runnable { esi.parameters.put("x", xSpawnLocation); esi.parameters.put("y", RhythmBullet.GAME_AREA_HEIGHT-0.25f); esi.parameters.put("angle", 140*rand.nextFloat()+200f); - esi.parameters.put("speed", (RhythmBullet.GAME_AREA_HEIGHT/4f)/avgSPB); + esi.parameters.put("speed", (RhythmBullet.GAME_AREA_HEIGHT/8f)/avgSPB); } } diff --git a/core/src/zero1hd/rhythmbullet/entity/Entity.java b/core/src/zero1hd/rhythmbullet/entity/Entity.java index af205dd..846fc82 100755 --- a/core/src/zero1hd/rhythmbullet/entity/Entity.java +++ b/core/src/zero1hd/rhythmbullet/entity/Entity.java @@ -187,6 +187,10 @@ public class Entity extends Actor implements Poolable { coordinator.setEntity(this); } + public void kill() { + dead = true; + } + public int getPoints() { return points + (coordinator != null ? coordinator.getScoreBonus() : 0); } diff --git a/core/src/zero1hd/rhythmbullet/entity/EntityManager.java b/core/src/zero1hd/rhythmbullet/entity/EntityManager.java index 2efe9ee..288ee47 100755 --- a/core/src/zero1hd/rhythmbullet/entity/EntityManager.java +++ b/core/src/zero1hd/rhythmbullet/entity/EntityManager.java @@ -6,7 +6,6 @@ import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.utils.Array; import zero1hd.rhythmbullet.entity.ally.Laser; -import zero1hd.rhythmbullet.entity.enemies.Bar; import zero1hd.rhythmbullet.entity.enemies.Flake; import zero1hd.rhythmbullet.entity.enemies.Pellet; import zero1hd.rhythmbullet.entity.enemies.Shard; @@ -23,7 +22,6 @@ public class EntityManager { public EntityFrame voidCircle; public EntityFrame pellet; public EntityFrame shard; - public EntityFrame bar; public EntityFrame flake; public EntityFrame laser; @@ -42,7 +40,6 @@ public class EntityManager { voidCircle = new EntityFrame<>(this, VoidCircle.class); pellet = new EntityFrame<>(this, Pellet.class); shard = new EntityFrame<>(this, Shard.class); - bar = new EntityFrame<>(this, Bar.class); flake = new EntityFrame<>(this, Flake.class); laser = new EntityFrame<>(this, Laser.class); diff --git a/core/src/zero1hd/rhythmbullet/entity/enemies/Bar.java b/core/src/zero1hd/rhythmbullet/entity/enemies/Bar.java deleted file mode 100755 index 6e4069d..0000000 --- a/core/src/zero1hd/rhythmbullet/entity/enemies/Bar.java +++ /dev/null @@ -1,60 +0,0 @@ -package zero1hd.rhythmbullet.entity.enemies; - -import java.util.HashMap; - -import com.badlogic.gdx.graphics.Texture; -import com.badlogic.gdx.graphics.g2d.Sprite; -import com.badlogic.gdx.math.Rectangle; - -import zero1hd.rhythmbullet.RhythmBullet; -import zero1hd.rhythmbullet.entity.Entity; -import zero1hd.rhythmbullet.entity.ally.PolyjetEntity; - -public class Bar extends Entity { - - @Override - public void preInit() { - setSize(8f, 0.5f); - sprite = new Sprite(assets.get("bar.png", Texture.class)); - enemy = true; - super.preInit(); - } - - public void init(float x, float rate) { - setPosition(x, RhythmBullet.GAME_AREA_HEIGHT); - speed = rate; - angle = 270; - } - - @Override - public void init(HashMap params) { - setPosition(params.get("x"), RhythmBullet.GAME_AREA_HEIGHT); - speed = params.get("rate"); - angle = 270; - super.init(params); - } - - @Override - public void act(float delta) { - hitbox.setPosition(getX(), getY()); - super.act(delta); - } - - @Override - public void reset() { - super.reset(); - } - - @Override - public void collided(Entity entity) { - if (entity.getClass() == PolyjetEntity.class) { - dead = true; - } - } - - @Override - public Rectangle getHitZone() { - return hitbox; - } - -} diff --git a/core/src/zero1hd/rhythmbullet/entity/enemies/Flake.java b/core/src/zero1hd/rhythmbullet/entity/enemies/Flake.java index d7f4a5d..ca51db7 100755 --- a/core/src/zero1hd/rhythmbullet/entity/enemies/Flake.java +++ b/core/src/zero1hd/rhythmbullet/entity/enemies/Flake.java @@ -49,7 +49,7 @@ public class Flake extends Entity { this.shards = new Shard[params.get("shardCount").intValue()]; for (int i = 0; i < shards.length; i++) { shards[i] = ec.shard.buildEntity(); - shards[i].init(params.get("x"), params.get("y"), 360/shards.length*i, 0, 2); + shards[i].init(params.get("x"), params.get("y"), 360/shards.length*i, 0, 1); ec.getStage().addActor(shards[i]); } this.speed = params.get("rate"); @@ -75,7 +75,7 @@ public class Flake extends Entity { if (timer <= 0) { for (int i = 0; i < shards.length; i++) { - shards[i].setSpeed(45f); + shards[i].setSpeed(30f); } dead = true; } @@ -92,7 +92,10 @@ public class Flake extends Entity { @Override public void collided(Entity entity) { if (entity.getClass() == Laser.class) { - timer --; + dead = true; + for (int i = 0; i < shards.length; i++) { + shards[i].kill(); + } } } diff --git a/core/src/zero1hd/rhythmbullet/entity/enemies/VoidCircle.java b/core/src/zero1hd/rhythmbullet/entity/enemies/VoidCircle.java index afd9655..0a50eea 100755 --- a/core/src/zero1hd/rhythmbullet/entity/enemies/VoidCircle.java +++ b/core/src/zero1hd/rhythmbullet/entity/enemies/VoidCircle.java @@ -109,7 +109,9 @@ public class VoidCircle extends Entity { @Override public void collided(Entity entity) { - sound.play(prefs.getFloat("fx vol")); + if (begin) { + sound.play(prefs.getFloat("fx vol")); + } } @Override diff --git a/core/src/zero1hd/rhythmbullet/screens/CreativeScreen.java b/core/src/zero1hd/rhythmbullet/screens/CreativeScreen.java index 663a2e3..f3300df 100755 --- a/core/src/zero1hd/rhythmbullet/screens/CreativeScreen.java +++ b/core/src/zero1hd/rhythmbullet/screens/CreativeScreen.java @@ -27,7 +27,7 @@ public class CreativeScreen extends ScreenAdapter { public CreativeScreen(RhythmBullet core, MainMenu mainMenu) { gamePlayArea = new GamePlayArea(core.getAssetManager(), core.getPrefs()); ghud = new GameHUD(core.getDefaultSkin(), 100f, gamePlayArea); - chud = new CreativeHUD(core, mainMenu, gamePlayArea); + chud = new CreativeHUD(core, mainMenu, gamePlayArea, ghud); inputs = new InputMultiplexer(chud, ghud, gamePlayArea); this.prefs = core.getPrefs(); diff --git a/core/src/zero1hd/rhythmbullet/ui/stages/CreativeHUD.java b/core/src/zero1hd/rhythmbullet/ui/stages/CreativeHUD.java index fad6f17..a00dfc2 100755 --- a/core/src/zero1hd/rhythmbullet/ui/stages/CreativeHUD.java +++ b/core/src/zero1hd/rhythmbullet/ui/stages/CreativeHUD.java @@ -45,8 +45,11 @@ public class CreativeHUD extends Stage implements MiniListener { Window toolbox; GamePlayArea gpa; - public CreativeHUD(final RhythmBullet core, final MainMenu mainMenu, final GamePlayArea gpa) { + GameHUD ghud; + public CreativeHUD(final RhythmBullet core, final MainMenu mainMenu, final GamePlayArea gpa, GameHUD ghud) { this.gpa = gpa; + this.ghud = ghud; + musicSelector = new MusicSelector("Select Audio File", core.getDefaultSkin(), core.getPrefs().getString("music dir"), "default"); musicSelector.miniSender.addListener(this); musicSelector.refresh(); @@ -263,7 +266,8 @@ public class CreativeHUD extends Stage implements MiniListener { musicPlayBackControls.setAudiofile(analyzer.getAudioData()); volumeWindow.setMusic(analyzer.getAudioData()); beatViewer.setMusic(analyzer.getAudioData(), analyzer); - + ghud.setMusic(null); + bassUMgraphWindow.setData(analyzer.getBassPeaks(), analyzer.getUMPeaks(), analyzer.getAudioData()); bassUMgraphWindow.getGraph().avgG1 = analyzer.getBassAvg(); bassUMgraphWindow.getGraph().normalDataG1 = analyzer.getBassMaxValue(); @@ -274,6 +278,7 @@ public class CreativeHUD extends Stage implements MiniListener { mGraphWindow.getGraph().normalDataG1 = analyzer.getmMaxValue(); mGraphWindow.getGraph().avgG1 = analyzer.getmAvg(); gpa.setAudioMap(mapGen.getMap()); + ghud.setMusic(analyzer.getAudioData().getPlaybackMusic()); break; default: break; diff --git a/core/src/zero1hd/rhythmbullet/ui/windows/MusicController.java b/core/src/zero1hd/rhythmbullet/ui/windows/MusicController.java index cbed464..ade4385 100755 --- a/core/src/zero1hd/rhythmbullet/ui/windows/MusicController.java +++ b/core/src/zero1hd/rhythmbullet/ui/windows/MusicController.java @@ -57,8 +57,12 @@ public class MusicController extends Window { togglePlay.setDrawable(skin.getDrawable("arrow")); } else { - togglePlay.setDrawable(skin.getDrawable("pause")); - audiofile.getPlaybackMusic().play(); + try { + togglePlay.setDrawable(skin.getDrawable("pause")); + audiofile.getPlaybackMusic().play(); + } catch (NullPointerException e) { + e.printStackTrace(); + } } } super.clicked(event, x, y); diff --git a/core/src/zero1hd/rhythmbullet/ui/windows/SpawnerWindow.java b/core/src/zero1hd/rhythmbullet/ui/windows/SpawnerWindow.java index 44dbd1b..ce76dd3 100755 --- a/core/src/zero1hd/rhythmbullet/ui/windows/SpawnerWindow.java +++ b/core/src/zero1hd/rhythmbullet/ui/windows/SpawnerWindow.java @@ -18,7 +18,6 @@ import zero1hd.rhythmbullet.entity.ally.Laser; import zero1hd.rhythmbullet.entity.coordinator.Coordinator; import zero1hd.rhythmbullet.entity.coordinator.CoordinatorFrame; import zero1hd.rhythmbullet.entity.coordinator.CoordinatorManager; -import zero1hd.rhythmbullet.entity.enemies.Bar; import zero1hd.rhythmbullet.entity.enemies.Flake; import zero1hd.rhythmbullet.entity.enemies.Pellet; import zero1hd.rhythmbullet.entity.enemies.Shard; @@ -54,7 +53,6 @@ public class SpawnerWindow extends Window { add(mod1, mod2, mod3, mod4); listOfEntities = new List<>(skin); - entityFrames.add(em.bar); entityFrames.add(em.flake); entityFrames.add(em.laser); entityFrames.add(em.pellet); @@ -109,9 +107,6 @@ public class SpawnerWindow extends Window { } else if (entity.getClass() == Shard.class) { Shard shard = (Shard) entity; shard.init(coords.x, coords.y, mod2.getValue()/mod2.getMaxValue()*360f, mod1.getValue(), (int) mod3.getValue()); - } else if (entity.getClass() == Bar.class) { - Bar bar = (Bar) entity; - bar.init(coords.x, mod1.getValue()); } else if (entity.getClass() == Flake.class) { Flake flake = (Flake) entity; flake.init(coords.x, coords.y, mod1.getValue(), mod3.getValue(), mod2.getValue()/mod2.getMaxValue()*360f, (int) mod4.getValue());