Add mover direction

This commit is contained in:
yugecin 2016-09-30 21:40:33 +02:00
parent 382ea2b4dc
commit daa7bec0da
3 changed files with 74 additions and 7 deletions

View File

@ -71,6 +71,7 @@ import org.newdawn.slick.state.transition.EasedFadeOutTransition;
import org.newdawn.slick.state.transition.EmptyTransition; import org.newdawn.slick.state.transition.EmptyTransition;
import org.newdawn.slick.state.transition.FadeInTransition; import org.newdawn.slick.state.transition.FadeInTransition;
import yugecin.opsudance.Dancer; import yugecin.opsudance.Dancer;
import yugecin.opsudance.MoverDirection;
import yugecin.opsudance.ObjectColorOverrides; import yugecin.opsudance.ObjectColorOverrides;
/** /**
@ -1163,7 +1164,8 @@ public class Game extends BasicGameState {
if (beatmap == null || beatmap.objects == null) if (beatmap == null || beatmap.objects == null)
throw new RuntimeException("Running game with no beatmap loaded."); 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 // free all previously cached hitobject to framebuffer mappings if some still exist
FrameBufferCache.getInstance().freeMap(); FrameBufferCache.getInstance().freeMap();

View File

@ -58,10 +58,10 @@ public class Dancer {
public static ObjectColorOverrides colorMirrorOverride = ObjectColorOverrides.NONE; public static ObjectColorOverrides colorMirrorOverride = ObjectColorOverrides.NONE;
public static int rgbhueinc = 70; // this should really get its own place somewhere... public static int rgbhueinc = 70; // this should really get its own place somewhere...
public static boolean cursoruselastobjectcolor; public static boolean cursoruselastobjectcolor;
public static MoverDirection moverDirection = MoverDirection.RANDOM;
private int dir; private int dir;
private GameObject p; private GameObject p;
private Random rand;
private MoverFactory moverFactory; private MoverFactory moverFactory;
private Mover mover; private Mover mover;
@ -82,10 +82,9 @@ public class Dancer {
spinner = spinners[0]; spinner = spinners[0];
} }
public void init(String mapname) { public void reset() {
isCurrentLazySlider = false; isCurrentLazySlider = false;
p = null; p = null;
rand = new Random(mapname.hashCode());
dir = 1; dir = 1;
for (Spinner s : spinners) { for (Spinner s : spinners) {
s.init(); s.init();
@ -131,9 +130,7 @@ public class Dancer {
} }
} }
} }
if (rand.nextInt(2) == 1) { dir = moverDirection.getDirection(dir);
dir *= -1;
}
if (c.isSpinner()) { if (c.isSpinner()) {
double[] spinnerStartPoint = spinner.getPoint(); double[] spinnerStartPoint = spinner.getPoint();
c.start = new Vec2f((float) spinnerStartPoint[0], (float) spinnerStartPoint[1]); c.start = new Vec2f((float) spinnerStartPoint[0], (float) spinnerStartPoint[1]);

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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);
}