circular visualizer progress
This commit is contained in:
parent
e939bffc68
commit
de38d1c863
@ -41,7 +41,7 @@ public class RhythmBullet extends Game {
|
|||||||
public static final int WORLD_WIDTH = 64;
|
public static final int WORLD_WIDTH = 64;
|
||||||
public static final int WORLD_HEIGHT = 48;
|
public static final int WORLD_HEIGHT = 48;
|
||||||
public static final int SPAWN_CIRCLE_RADIUS = 4;
|
public static final int SPAWN_CIRCLE_RADIUS = 4;
|
||||||
public static float pixels_per_unit;
|
public static int pixels_per_unit;
|
||||||
private boolean initComplete = false;
|
private boolean initComplete = false;
|
||||||
private boolean resizing;
|
private boolean resizing;
|
||||||
private int screenWidth, screenHeight;
|
private int screenWidth, screenHeight;
|
||||||
|
@ -1,5 +1,75 @@
|
|||||||
package zero1hd.rhythmbullet.graphics.meshes;
|
package zero1hd.rhythmbullet.graphics.meshes;
|
||||||
|
|
||||||
|
import zero1hd.rhythmbullet.RhythmBullet;
|
||||||
|
|
||||||
public class CircularVisualizerMesh {
|
public class CircularVisualizerMesh {
|
||||||
|
private int x, y;
|
||||||
|
private int componentCount = 2 + 4;
|
||||||
|
private float[] verts;
|
||||||
|
|
||||||
|
public CircularVisualizerMesh() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void applyPositionChanges() {
|
||||||
|
verts = new float[calculateVertices(x, y, RhythmBullet.pixels_per_unit) * componentCount];
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createCircleVertices(int centerX, int centerY, int radius) {
|
||||||
|
int x = radius - 1;
|
||||||
|
int y = 0;
|
||||||
|
int dx = 1;
|
||||||
|
int dy = 1;
|
||||||
|
int err = dx - (radius << 1);
|
||||||
|
|
||||||
|
while (x >= y)
|
||||||
|
{
|
||||||
|
putVertex(centerX + x, centerY + y);
|
||||||
|
putVertex(centerX + y, centerY + x);
|
||||||
|
putVertex(centerX - y, centerY + x);
|
||||||
|
putVertex(centerX - x, centerY + y);
|
||||||
|
putVertex(centerX - x, centerY - y);
|
||||||
|
putVertex(centerX - y, centerY - x);
|
||||||
|
putVertex(centerX + y, centerY - x);
|
||||||
|
putVertex(centerX + x, centerY - y);
|
||||||
|
|
||||||
|
if (err <= 0) {
|
||||||
|
y++;
|
||||||
|
err += dy;
|
||||||
|
dy += 2;
|
||||||
|
} else {
|
||||||
|
x--;
|
||||||
|
dx += 2;
|
||||||
|
err += dx - (radius << 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private int calculateVertices(int centerX, int centerY, int radius) {
|
||||||
|
int x = radius - 1;
|
||||||
|
int y = 0;
|
||||||
|
int dx = 1;
|
||||||
|
int dy = 1;
|
||||||
|
int err = dx - (radius << 1);
|
||||||
|
int vertCount = 0;
|
||||||
|
while (x >= y)
|
||||||
|
{
|
||||||
|
vertCount += 8;
|
||||||
|
|
||||||
|
if (err <= 0) {
|
||||||
|
y++;
|
||||||
|
err += dy;
|
||||||
|
dy += 2;
|
||||||
|
} else {
|
||||||
|
x--;
|
||||||
|
dx += 2;
|
||||||
|
err += dx - (radius << 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return vertCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void putVertex(int x, int y) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user