Commits

Chuck Adams  committed 5a941bc

new tests

  • Participants
  • Parent commits 0212d65

Comments (0)

Files changed (5)

File src/main/java/net/fishbulb/sandbox/Main.java

 
 import com.badlogic.gdx.ApplicationListener;
 import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.Graphics;
 import com.badlogic.gdx.Input;
 import com.badlogic.gdx.InputAdapter;
+import com.badlogic.gdx.graphics.Camera;
 import com.badlogic.gdx.graphics.GL10;
+import com.badlogic.gdx.graphics.OrthographicCamera;
+import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
+
+import static com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
 
 public class Main extends InputAdapter implements ApplicationListener {
 
+    Camera camera;
+    private ShapeRenderer shapeRenderer;
+
+    int width;
+    int height;
 
     @Override
     public void create() {
         Gdx.input.setInputProcessor(this);
+        Graphics g = Gdx.app.getGraphics();
+        width = g.getWidth();
+        height = g.getHeight();
+
+        camera = new OrthographicCamera(100, 100);
+        camera.position.set((float)width/2, (float)height/2, 0);
+
+        GL10 gl10 = g.getGL10();
+        gl10.glViewport(0, 0, width, height);
+        shapeRenderer = new ShapeRenderer();
     }
 
     @Override
     public void render() {
-        Gdx.gl.glClearColor(0, 0, 0, 0);
+        Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
         Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
+
+        camera.update();
+        shapeRenderer.setProjectionMatrix(camera.combined);
+
+        shapeRenderer.begin(ShapeType.Line);
+        shapeRenderer.setColor(1, 1, 0, 1);
+
+        int x = 10;
+        int y = 10;
+        int x2 = 20;
+        int y2 = 20;
+        int x3 = 5;
+        int y3 = 50;
+        int x4 = 50;
+        int y4 = 5;
+
+        int z = 0;
+        int depth = 0;
+
+        shapeRenderer.line(x, y, x2, y2);
+        shapeRenderer.line(x3, y3, x4, y4);
+        shapeRenderer.end();
+
+        shapeRenderer.begin(ShapeType.Box);
+        shapeRenderer.setColor(0, 1, 0, 1);
+        shapeRenderer.box(x, y, z, width, height, depth);
+        shapeRenderer.end();
+
+
     }
 
     @Override

File src/main/java/net/fishbulb/sandbox/MainDesktop.java

 
     public static void main(String[] args) {
 		LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
-		config.useGL20 = true;
-        config.width = 800;
-        config.height = 600;
+		config.useGL20 = false;
+        config.width = 500;
+        config.height = 500;
         config.vSyncEnabled = true;
         config.title = "Sandbox";
-        new LwjglApplication(new Main(), config);
+        new LwjglApplication(new StageTest(), config);
 	}
 }

File src/main/java/net/fishbulb/sandbox/StageTest.java

+package net.fishbulb.sandbox;
+
+import com.badlogic.gdx.ApplicationListener;
+import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.InputAdapter;
+import com.badlogic.gdx.graphics.Camera;
+import com.badlogic.gdx.graphics.GL10;
+import com.badlogic.gdx.graphics.OrthographicCamera;
+import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
+import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType;
+
+public class StageTest extends InputAdapter implements ApplicationListener {
+    Camera camera;
+    ShapeRenderer renderer;
+
+    ShapeType currentShape = ShapeType.FilledCircle;
+
+    float pointSize = 1.2f;
+
+
+    @Override
+    public void create() {
+        Gdx.input.setInputProcessor(this);
+        camera = new OrthographicCamera(200, 200);
+        renderer = new ShapeRenderer();
+    }
+
+    @Override
+    public void render() {
+        camera.update();
+        renderer.setProjectionMatrix(camera.combined);
+
+        Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1);
+        Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
+
+        renderer.begin(currentShape);
+        renderer.setColor(1, 0, 0, 1);
+        point(0, 0);
+        point(5, 5);
+        point(50, 50);
+        renderer.end();
+    }
+
+    private void startShape(ShapeType shape) {
+        if (currentShape != shape) {
+            renderer.end();
+            renderer.begin(shape);
+            currentShape = shape;
+        }
+    }
+
+    public void point(float x, float y) {
+        startShape(ShapeType.FilledCircle);
+        renderer.filledCircle(x, y, pointSize);
+    }
+
+    @Override
+    public void dispose() {
+        renderer.dispose();
+    }
+
+    @Override public void resize(int width, int height) {
+        Gdx.gl.glViewport(0, 0, width, height);
+    }
+
+    @Override public void pause() {}
+
+    @Override public void resume() {}
+
+}

File src/main/resources/badlogicsmall.jpg

Added
New image

File src/main/resources/ui.png

Added
New image