From daa7bec0da80de4cfe97fd4e32caf61288b3ff92 Mon Sep 17 00:00:00 2001 From: yugecin Date: Fri, 30 Sep 2016 21:40:33 +0200 Subject: [PATCH] Add mover direction --- src/itdelatrisu/opsu/states/Game.java | 4 +- src/yugecin/opsudance/Dancer.java | 9 +-- src/yugecin/opsudance/MoverDirection.java | 68 +++++++++++++++++++++++ 3 files changed, 74 insertions(+), 7 deletions(-) create mode 100644 src/yugecin/opsudance/MoverDirection.java diff --git a/src/itdelatrisu/opsu/states/Game.java b/src/itdelatrisu/opsu/states/Game.java index df94e338..6a20c711 100644 --- a/src/itdelatrisu/opsu/states/Game.java +++ b/src/itdelatrisu/opsu/states/Game.java @@ -71,6 +71,7 @@ import org.newdawn.slick.state.transition.EasedFadeOutTransition; import org.newdawn.slick.state.transition.EmptyTransition; import org.newdawn.slick.state.transition.FadeInTransition; import yugecin.opsudance.Dancer; +import yugecin.opsudance.MoverDirection; import yugecin.opsudance.ObjectColorOverrides; /** @@ -1163,7 +1164,8 @@ public class Game extends BasicGameState { if (beatmap == null || beatmap.objects == null) throw new RuntimeException("Running game with no beatmap loaded."); - Dancer.instance.init(beatmap.getTitle()); + Dancer.instance.reset(); + MoverDirection.reset(beatmap.getTitle()); // free all previously cached hitobject to framebuffer mappings if some still exist FrameBufferCache.getInstance().freeMap(); diff --git a/src/yugecin/opsudance/Dancer.java b/src/yugecin/opsudance/Dancer.java index 3afe44dc..9effc665 100644 --- a/src/yugecin/opsudance/Dancer.java +++ b/src/yugecin/opsudance/Dancer.java @@ -58,10 +58,10 @@ public class Dancer { public static ObjectColorOverrides colorMirrorOverride = ObjectColorOverrides.NONE; public static int rgbhueinc = 70; // this should really get its own place somewhere... public static boolean cursoruselastobjectcolor; + public static MoverDirection moverDirection = MoverDirection.RANDOM; private int dir; private GameObject p; - private Random rand; private MoverFactory moverFactory; private Mover mover; @@ -82,10 +82,9 @@ public class Dancer { spinner = spinners[0]; } - public void init(String mapname) { + public void reset() { isCurrentLazySlider = false; p = null; - rand = new Random(mapname.hashCode()); dir = 1; for (Spinner s : spinners) { s.init(); @@ -131,9 +130,7 @@ public class Dancer { } } } - if (rand.nextInt(2) == 1) { - dir *= -1; - } + dir = moverDirection.getDirection(dir); if (c.isSpinner()) { double[] spinnerStartPoint = spinner.getPoint(); c.start = new Vec2f((float) spinnerStartPoint[0], (float) spinnerStartPoint[1]); diff --git a/src/yugecin/opsudance/MoverDirection.java b/src/yugecin/opsudance/MoverDirection.java new file mode 100644 index 00000000..e699e359 --- /dev/null +++ b/src/yugecin/opsudance/MoverDirection.java @@ -0,0 +1,68 @@ +/* + * opsu!dance - fork of opsu! with cursordance auto + * Copyright (C) 2016 yugecin + * + * opsu!dance is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * opsu!dance is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with opsu!dance. If not, see . + */ +package yugecin.opsudance; + +import java.util.Random; + +public enum MoverDirection { + + LEFT ("Left", 0) { + @Override + public int getDirection(int currentDirection) { + return 1; + } + }, + RIGHT ("Right", 1) { + @Override + public int getDirection(int currentDirection) { + return 0; + } + }, + ALTERNATE ("Alternate", 2) { + @Override + public int getDirection(int currentDirection) { + return currentDirection * -1; + } + }, + RANDOM ("Random", 3) { + @Override + public int getDirection(int currentDirection) { + if (rand.nextInt(2) == 1) { + return currentDirection * -1; + } + return currentDirection; + } + }; + + public String displayName; + private int nr; + + private static Random rand; + + MoverDirection(String displayName, int nr) { + this.displayName = displayName; + this.nr = nr; + } + + public static void reset(String mapName) { + rand = new Random(mapName.hashCode()); + } + + public abstract int getDirection(int currentDirection); + +}