diff --git a/core/src/zero1hd/rhythmbullet/RhythmBullet.java b/core/src/zero1hd/rhythmbullet/RhythmBullet.java index da88b5c..dbeb540 100755 --- a/core/src/zero1hd/rhythmbullet/RhythmBullet.java +++ b/core/src/zero1hd/rhythmbullet/RhythmBullet.java @@ -41,7 +41,7 @@ public class RhythmBullet extends Game { public static final int WORLD_WIDTH = 64; public static final int WORLD_HEIGHT = 48; 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 resizing; private int screenWidth, screenHeight; diff --git a/core/src/zero1hd/rhythmbullet/graphics/meshes/CircularVisualizerMesh.java b/core/src/zero1hd/rhythmbullet/graphics/meshes/CircularVisualizerMesh.java index 26212dd..ddf9f41 100755 --- a/core/src/zero1hd/rhythmbullet/graphics/meshes/CircularVisualizerMesh.java +++ b/core/src/zero1hd/rhythmbullet/graphics/meshes/CircularVisualizerMesh.java @@ -1,5 +1,75 @@ package zero1hd.rhythmbullet.graphics.meshes; -public class CircularVisualizerMesh { +import zero1hd.rhythmbullet.RhythmBullet; +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) { + + } }