Merge branch 'spinners' into master

This commit is contained in:
yugecin 2016-10-01 11:35:43 +02:00
commit 08414d9d2a
12 changed files with 561 additions and 13 deletions

View File

@ -43,6 +43,12 @@ public class DummyObject extends GameObject {
updatePosition(); updatePosition();
} }
public DummyObject() {
this.hitObject = new HitObject("0,0,0,1,0,0:0:0:0:");
updatePosition();
updateStartEndPositions(0);
}
@Override @Override
public void draw(Graphics g, int trackPosition, boolean mirror) {} public void draw(Graphics g, int trackPosition, boolean mirror) {}

View File

@ -348,11 +348,15 @@ public class Game extends BasicGameState {
autoMousePressed = false; autoMousePressed = false;
if (GameMod.AUTO.isActive() || GameMod.AUTOPILOT.isActive()) { if (GameMod.AUTO.isActive() || GameMod.AUTOPILOT.isActive()) {
Vec2f autoPoint; Vec2f autoPoint;
if (objectIndex == 0) { if (objectIndex < beatmap.objects.length) {
autoPoint = gameObjects[0].getPointAt(trackPosition); GameObject p;
} else if (objectIndex < beatmap.objects.length) { if (objectIndex > 0) {
p = gameObjects[objectIndex - 1];
} else {
p = null;
}
Dancer d = Dancer.instance; Dancer d = Dancer.instance;
d.update(trackPosition, gameObjects[objectIndex - 1], gameObjects[objectIndex]); d.update(trackPosition, p, gameObjects[objectIndex]);
autoPoint = new Vec2f(d.x, d.y); autoPoint = new Vec2f(d.x, d.y);
if (trackPosition < gameObjects[objectIndex].getTime()) { if (trackPosition < gameObjects[objectIndex].getTime()) {
autoMousePressed = true; autoMousePressed = true;

View File

@ -20,13 +20,13 @@ package yugecin.opsudance;
import itdelatrisu.opsu.Options; import itdelatrisu.opsu.Options;
import itdelatrisu.opsu.Utils; import itdelatrisu.opsu.Utils;
import itdelatrisu.opsu.objects.Circle; import itdelatrisu.opsu.objects.Circle;
import itdelatrisu.opsu.objects.DummyObject;
import itdelatrisu.opsu.objects.GameObject; import itdelatrisu.opsu.objects.GameObject;
import itdelatrisu.opsu.objects.Slider; import itdelatrisu.opsu.objects.Slider;
import itdelatrisu.opsu.objects.curves.Vec2f; import itdelatrisu.opsu.objects.curves.Vec2f;
import yugecin.opsudance.movers.Mover; import yugecin.opsudance.movers.Mover;
import yugecin.opsudance.movers.factories.*; import yugecin.opsudance.movers.factories.*;
import yugecin.opsudance.spinners.RektSpinner; import yugecin.opsudance.spinners.*;
import yugecin.opsudance.spinners.Spinner;
public class Dancer { public class Dancer {
@ -43,7 +43,15 @@ public class Dancer {
}; };
public static Spinner[] spinners = new Spinner[] { public static Spinner[] spinners = new Spinner[] {
new RektSpinner() new RektSpinner(),
new BeamSpinner(),
new CircleSpinner(),
new DonutSpinner(),
new CubeSpinner(),
new HalfCircleSpinner(),
new IlluminatiSpinner(),
new LessThanThreeSpinner(),
new RektCircleSpinner(),
}; };
public static Dancer instance = new Dancer(); public static Dancer instance = new Dancer();
@ -60,6 +68,7 @@ public class Dancer {
public static boolean hideobjects = false; public static boolean hideobjects = false;
private int dir; private int dir;
private GameObject d = new DummyObject();
private GameObject p; private GameObject p;
private MoverFactory moverFactory; private MoverFactory moverFactory;
@ -83,7 +92,7 @@ public class Dancer {
public void reset() { public void reset() {
isCurrentLazySlider = false; isCurrentLazySlider = false;
p = null; p = d;
dir = 1; dir = 1;
for (Spinner s : spinners) { for (Spinner s : spinners) {
s.init(); s.init();
@ -117,6 +126,9 @@ public class Dancer {
public void update(int time, GameObject p, GameObject c) { public void update(int time, GameObject p, GameObject c) {
if (this.p != p) { if (this.p != p) {
this.p = p; this.p = p;
if (this.p == null) {
this.p = p = d;
}
isCurrentLazySlider = false; isCurrentLazySlider = false;
// detect lazy sliders, should work pretty good // detect lazy sliders, should work pretty good
if (c.isSlider() && LAZY_SLIDERS && Utils.distance(c.start.x, c.start.y, c.end.x , c.end.y) <= Circle.diameter * 0.8f) { if (c.isSlider() && LAZY_SLIDERS && Utils.distance(c.start.x, c.start.y, c.end.x , c.end.y) <= Circle.diameter * 0.8f) {

View File

@ -0,0 +1,81 @@
/*
* 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.spinners;
import itdelatrisu.opsu.Options;
public class BeamSpinner extends Spinner {
private double ang = 0;
private double[] point;
private int index;
@Override
public void init()
{
ang = 0;
index = 0;
point = new double[2];
}
@Override
public double[] getPoint()
{
index = ++index % 4;
final int MOD = 60;
point[0] = Options.width / 2d;
point[1] = Options.height / 2d;
if( index == 0 )
{
add( MOD, 90 );
add( MOD, 180 );
}
else if( index == 1 )
{
add( MOD, 90 );
add( Options.height / 2 * 0.8d, 0 );
}
else if( index == 2 )
{
add( MOD, -90 );
add( Options.height / 2 * 0.8d, 0 );
}
else if( index == 3 )
{
add( MOD, -90 );
add( MOD, 180 );
ang += 0.3;
}
return point;
}
private void add( double rad, double ang )
{
point[0] += rad * Math.cos( (this.ang + ang) / 180d * Math.PI);
point[1] -= rad * Math.sin( (this.ang + ang) / 180d * Math.PI);
}
@Override
public String toString() {
return "Beam";
}
}

View File

@ -0,0 +1,52 @@
/*
* 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.spinners;
import itdelatrisu.opsu.Options;
public class CircleSpinner extends Spinner {
private int ang = 0;
private double[] point = new double[2];
@Override
public void init()
{
ang = 0;
}
@Override
public double[] getPoint()
{
ang += 15;
double rad = Options.width / 4.0f;
point[0] = Options.width / 2.0f + rad * Math.sin(ang / 180d * Math.PI);
point[1] = Options.height / 2.0f - rad * Math.cos(ang / 180d * Math.PI);
return point;
}
@Override
public String toString() {
return "Circle";
}
}

View File

@ -0,0 +1,106 @@
/*
* 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.spinners;
import itdelatrisu.opsu.Options;
public class CubeSpinner extends Spinner {
private int[][] points = {
{ -1, -1, 1 },
{ 1, -1, 1 },
{ 1, 1, 1 },
{ -1, 1, 1 },
{ -1, -1, 1 },
{ -1, -1, -1 },
{ -1, 1, -1 },
{ -1, 1, 1 },
{ -1, 1, -1 },
{ 1, 1, -1 },
{ 1, 1, 1 },
{ 1, 1, -1 },
{ 1, -1, -1 },
{ 1, -1, 1 },
{ 1, -1, -1 },
{ -1, -1, -1 },
{ -1, -1, 1 },
};
private int azi = 0;
private int alt = 73;
public double azimuth = 15.0d;
public double altitude = 95.0d;
private double size = 0;
private int index = 0;
private double[] point = new double[2];
@Override
public void init()
{
azi = 0;
alt = 73;
}
@Override
public double[] getPoint()
{
if( ++index >= 16 )
{
index = 0;
azimuth += 2.0d;
altitude += 6.0d;
size += 15d;
//size = 0;
azi += 5;
alt += 9;
azimuth = 30d * Math.cos( azi / 180d * Math.PI );
altitude = 30d * Math.cos( alt / 180d * Math.PI );
}
double theta = Math.PI * azimuth / 180.0d;
double phi = Math.PI * altitude / 180.0d;
double cosT = Math.cos( theta ), sinT = Math.sin(theta );
double cosP = Math.cos( phi ), sinP = Math.sin( phi );
double x = cosT * points[index][0] + sinT * points[index][2];
double y = -sinT * sinP * points[index][0] + cosP * points[index][1] + cosT * sinP * points[index][2];
// fix depth
double z = cosT * cosP * points[index][2] - sinT * cosP * points[index][0] - sinP * points[index][1];
x *= 3.0d / ( z + 3.0d + 5.0d + 0.5 );
y *= 3.0d / ( z + 3.0d + 5.0d + 0.5 );
double scale = Options.width / (3.0f + 0.5f * Math.cos(size / 180f * Math.PI));
//double scale = Options.width / (3.0f + -1f * ((float)(Options.s.ElapsedMilliseconds % Options.beatTimeMs)/(float)Options.beatTimeMs));
point[0] = (int) ( Options.width / 2.0f + scale * x );
point[1] = (int) ( Options.height / 2.0f - scale * y );
return point;
}
@Override
public String toString() {
return "Cube";
}
}

View File

@ -0,0 +1,52 @@
/*
* 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.spinners;
import itdelatrisu.opsu.Options;
public class DonutSpinner extends Spinner {
private int ang = 0;
private double[] point = new double[2];
@Override
public void init()
{
ang = 0;
}
@Override
public double[] getPoint()
{
ang += 15;
double rad = Options.width / 4.0f;
point[0] = Options.width / 2.0f + rad * Math.sin(ang);
point[1] = Options.height / 2.0f - rad * Math.cos(ang);
return point;
}
@Override
public String toString() {
return "Donut";
}
}

View File

@ -0,0 +1,57 @@
/*
* 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.spinners;
import itdelatrisu.opsu.Options;
public class HalfCircleSpinner extends Spinner {
private int ang = 0;
private double[] point = new double[2];
private int skipang = 180;
@Override
public void init()
{
ang = 0;
skipang = 180;
}
@Override
public double[] getPoint()
{
ang += 15;
if( ang > skipang - 160 )
{
ang = skipang;
skipang += 359;
}
point[0] = Options.width / 2.0d + Options.height / 2 * 0.8d * Math.cos(ang/180d*Math.PI);
point[1] = Options.height / 2.0d + Options.height / 2 * 0.8d * Math.sin(ang/180d*Math.PI);
return point;
}
@Override
public String toString() {
return "Half circle";
}
}

View File

@ -0,0 +1,39 @@
/*
* 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.spinners;
import itdelatrisu.opsu.Options;
public class IlluminatiSpinner extends Spinner {
@Override
public void init()
{
init( new double[][] {
new double[] { Options.width / 2d - 120, Options.height / 2d + 80 },
new double[] { Options.width / 2d, Options.height / 2d - 160 },
new double[] { Options.width / 2d + 120, Options.height / 2d + 80 }
} );
}
@Override
public String toString() {
return "Illuminati";
}
}

View File

@ -0,0 +1,56 @@
/*
* 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.spinners;
import itdelatrisu.opsu.Options;
public class LessThanThreeSpinner extends Spinner {
private int angle = 0;
@Override
public void init()
{
}
@Override
public double[] getPoint()
{
angle += 18;
if( angle > 360 ) angle = 0;
double theta = angle / 180d * Math.PI;
double[] pos = new double[] {
Options.width / 2d,
Options.height / 2d
};
double r = 2 - 2 * Math.sin( theta ) + Math.sin( theta ) * Math.sqrt( Math.abs( Math.cos( theta ) ) ) / ( Math.sin( theta ) + 1.4 );
pos[0] += Math.cos( theta ) * r * 100;
pos[1] -= Math.sin( theta ) * r * 100 + 100;
return pos;
}
@Override
public String toString() {
return "LessThanThree";
}
}

View File

@ -0,0 +1,87 @@
/*
* 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.spinners;
import itdelatrisu.opsu.Options;
public class RektCircleSpinner extends Spinner {
private double[] point;
private int index;
private int pos;
private double size;
private int delay = 0;
@Override
public void init()
{
index = 0;
size = Options.height * 0.8d;
point = new double[2];
}
@Override
public double[] getPoint()
{
if( ++delay < DELAY )
{
return point;
}
delay = 0;
final int INC = 50;
if( index == 0 )
{
point[0] = Options.width / 2d + size / 2d - pos;
point[1] = Options.height / 2d - size / 2d;
index++;
}
else if( index == 1 )
{
point[0] = Options.width / 2 - size / 2;
point[1] = Options.height / 2 - size / 2 + pos;
index++;
}
else if( index == 2 )
{
point[0] = Options.width / 2 - size / 2 + pos;
point[1] = Options.height / 2 + size / 2;
index++;
}
else if( index == 3 )
{
point[0] = Options.width / 2 + size / 2;
point[1] = Options.height / 2 + size / 2 - pos;
pos += INC;
if( pos > size )
{
pos = INC;
}
index = 0;
}
return point;
}
@Override
public String toString() {
return "RektCircle";
}
}

View File

@ -22,7 +22,6 @@ public abstract class Spinner {
private double[][] points; private double[][] points;
private int length; private int length;
private int index; private int index;
private int delay;
public static int DELAY = 3; public static int DELAY = 3;
public abstract void init(); public abstract void init();
@ -33,10 +32,7 @@ public abstract class Spinner {
} }
public double[] getPoint() { public double[] getPoint() {
if (++delay > DELAY) {
delay = 0;
index = ++index % length; index = ++index % length;
}
return points[index]; return points[index];
} }