diff --git a/core/src/zero1hd/rhythmbullet/audio/visualizer/BasicVisualizer.java b/core/src/zero1hd/rhythmbullet/audio/visualizer/BasicVisualizer.java index e9a73db..1ee0672 100755 --- a/core/src/zero1hd/rhythmbullet/audio/visualizer/BasicVisualizer.java +++ b/core/src/zero1hd/rhythmbullet/audio/visualizer/BasicVisualizer.java @@ -9,6 +9,7 @@ import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.utils.Array; import zero1hd.rhythmbullet.audio.MusicManager; @@ -25,6 +26,7 @@ public class BasicVisualizer extends VisualizerCore { private float rotation; private Vector2 angleRot; private boolean flip; + private Array mirrors; public BasicVisualizer() { super(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()/2, 0, 0); @@ -137,4 +139,12 @@ public class BasicVisualizer extends VisualizerCore { public boolean isFlipped() { return flip; } + + public void addMirrorVisualizer(MirrorVisualizer mirror) { + mirrors.add(mirror); + } + + public void removeMirrorVisualizer(MirrorVisualizer mirror) { + mirrors.removeValue(mirror, true); + } } diff --git a/core/src/zero1hd/rhythmbullet/audio/visualizer/MirrorVisualizer.java b/core/src/zero1hd/rhythmbullet/audio/visualizer/MirrorVisualizer.java new file mode 100644 index 0000000..8294816 --- /dev/null +++ b/core/src/zero1hd/rhythmbullet/audio/visualizer/MirrorVisualizer.java @@ -0,0 +1,58 @@ +package zero1hd.rhythmbullet.audio.visualizer; + +import com.badlogic.gdx.graphics.g2d.Sprite; +import com.badlogic.gdx.math.MathUtils; +import com.badlogic.gdx.math.Vector2; + +public class MirrorVisualizer { + private Sprite[] bars; + private float rotation; + private int xPos, yPos; + private Vector2 angleRot; + private boolean flip; + protected void setup(Sprite[] sprites, float rotation, int x, int y, Vector2 angleRot) { + this.xPos = x; + this.yPos = y; + this.angleRot = angleRot; + + bars = new Sprite[sprites.length]; + for (int i = 0; i < bars.length; i++) { + bars[i] = new Sprite(sprites[i]); + } + } + + protected void updateSpriteSize(Sprite[] sprites) { + for (int i = 0; i < sprites.length; i++) { + bars[i].setSize(bars[i].getWidth(), sprites[i].getHeight()); + } + } + + public void updatePositioning(Sprite[] sprites, int barSpace) { + angleRot.set(MathUtils.cosDeg(rotation), MathUtils.sinDeg(rotation)); + for (int i = 0; i < sprites.length; i++) { + bars[i].set(sprites[i]); + bars[i].setPosition(xPos + barSpace*angleRot.x, yPos + barSpace*angleRot.y); + if (flip) { + bars[i].setRotation(rotation+180); + } else { + bars[i].setRotation(rotation); + } + } + } + + public void flip() { + flip = flip ? false : true; + } + + public boolean isFlipped() { + return flip; + } + + public void setxPos(int xPos) { + this.xPos = xPos; + } + + public void setyPos(int yPos) { + this.yPos = yPos; + } +}