pass screen size in instead of polling it later

and add some comments
This commit is contained in:
Peter Tissen
2015-06-08 15:38:46 +02:00
parent 41c7825728
commit 2970972456
6 changed files with 132 additions and 136 deletions

View File

@@ -30,20 +30,12 @@ import itdelatrisu.opsu.objects.curves.CatmullCurve;
import itdelatrisu.opsu.objects.curves.CircumscribedCircle;
import itdelatrisu.opsu.objects.curves.Curve;
import itdelatrisu.opsu.objects.curves.LinearBezier;
import itdelatrisu.opsu.render.Rendertarget;
import itdelatrisu.opsu.states.Game;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL14;
import org.lwjgl.opengl.GL30;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.util.Log;
/**
* Data type representing a slider object.
@@ -58,9 +50,6 @@ public class Slider implements GameObject {
/** Rate at which slider ticks are placed. */
private static float sliderTickRate = 1.0f;
/** Scaling factor for display elements */
private static int diameter = 1;
/** The amount of time, in milliseconds, to fade in the slider. */
private static final int FADE_IN_TIME = 375;
@@ -122,7 +111,7 @@ public class Slider implements GameObject {
containerWidth = container.getWidth();
containerHeight = container.getHeight();
diameter = (int) (104 - (circleSize * 8));
int diameter = (int) (104 - (circleSize * 8));
diameter = (int) (diameter * HitObject.getXMultiplier()); // convert from Osupixels (640x480)
// slider ball
@@ -399,7 +388,6 @@ public class Slider implements GameObject {
// calculate and send slider result
hitResult();
return true;
}
@@ -481,8 +469,6 @@ public class Slider implements GameObject {
this.curve = new CatmullCurve(hitObject, color);
else
this.curve = new LinearBezier(hitObject, color, hitObject.getSliderType() == HitObject.SLIDER_LINEAR);
this.curve.setScale(diameter );//* 118 / 128);
}
@Override

View File

@@ -37,6 +37,9 @@ public abstract class Curve {
/** Points generated along the curve should be spaced this far apart. */
protected static float CURVE_POINTS_SEPERATION = 5;
/** The width and height of the display container this curve gets drawn into */
protected static int containerWidth = 0, containerHeight = 0;
/** The associated HitObject. */
protected HitObject hitObject;
@@ -46,9 +49,6 @@ public abstract class Curve {
/** The scaled slider x, y coordinate lists. */
protected float[] sliderX, sliderY;
/** scaling factor for drawing. */
protected static float scale;
/** Per-curve render-state used for the new style curve renders*/
private CurveRenderState renderState;
@@ -66,10 +66,22 @@ public abstract class Curve {
this.y = hitObject.getScaledY();
this.sliderX = hitObject.getScaledSliderX();
this.sliderY = hitObject.getScaledSliderY();
this.scale = 100;
this.renderState = null;
}
/**
* Set the width and height of the container that Curves get drawn into
* Should be called before any curves are drawn.
* @param width
* @param height
*/
public static void init(int width, int height, float circleSize)
{
containerWidth = width;
containerHeight = height;
CurveRenderState.init(width, height, circleSize);
}
/**
* Returns the point on the curve at a value t.
* @param t the t value [0, 1]
@@ -82,26 +94,24 @@ public abstract class Curve {
* @param color the color filter
*/
public void draw(Color color) {
if ( curve == null){
Log.error("draw curve"+this);
return;
if (curve == null) {
return;
}
if (Options.GameOption.NEW_SLIDER.getBooleanValue()) {
if (renderState == null) {
renderState = new CurveRenderState(hitObject);
}
if (Options.GameOption.NEW_SLIDER.getBooleanValue()) {
if(renderState == null)
{
renderState = new CurveRenderState(scale,hitObject);
}
renderState.draw(color,curve);
} else {
Image hitCircle = GameImage.HITCIRCLE.getImage();
Image hitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage();
for (int i = 0; i < curve.length; i++) {
hitCircleOverlay.drawCentered(curve[i].x, curve[i].y, Utils.COLOR_WHITE_FADE);
}
for (int i = 0; i < curve.length; i++){
hitCircle.drawCentered(curve[i].x, curve[i].y, color);
}
renderState.draw(color, curve);
} else {
Image hitCircle = GameImage.HITCIRCLE.getImage();
Image hitCircleOverlay = GameImage.HITCIRCLE_OVERLAY.getImage();
for (int i = 0; i < curve.length; i++) {
hitCircleOverlay.drawCentered(curve[i].x, curve[i].y, Utils.COLOR_WHITE_FADE);
}
for (int i = 0; i < curve.length; i++) {
hitCircle.drawCentered(curve[i].x, curve[i].y, color);
}
}
}
/**
@@ -126,14 +136,6 @@ public abstract class Curve {
*/
public float getY(int i) { return (i == 0) ? y : sliderY[i - 1]; }
/**
* Set the scaling factor.
* @param factor the new scaling factor for the UI representation
*/
public static void setScale(float factor) {
scale = factor;
}
/**
* Linear interpolation of a and b at t.
*/