package net.caraus.labyrinth; import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.Color; import static com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.utils.ScreenUtils; import java.io.BufferedReader; import java.io.IOException; /** {@link com.badlogic.gdx.ApplicationListener} implementation shared by all platforms. */ public class Main extends ApplicationAdapter { private ShapeRenderer shape; private Maze maze; private RecursiveSolve solver; @Override public void create() { shape = new ShapeRenderer(); FileHandle file = Gdx.files.internal("sample.txt"); try { this.maze = new Maze(file.reader("utf-8")); } catch (IOException e) { } this.solver = new RecursiveSolve(this.maze, new Point(0, 0), new Point(this.maze.width() - 1, 0)); this.solver.start(); } @Override public void render() { ScreenUtils.clear(0.15f, 0.15f, 0.2f, 1f); this.shape.begin(ShapeType.Line); this.shape.setColor(Color.RED); this.maze.draw(this.shape); this.shape.setColor(Color.GREEN); this.solver.draw(this.shape); /* this.elapsedTime += Gdx.graphics.getDeltaTime(); if (this.elapsedTime > 1.0f) { if (this.solver.solve() != Solution.CONTINUE) { this.elapsedTime = Float.NEGATIVE_INFINITY; } else { this.elapsedTime -= 1.0f; } } */ this.shape.end(); } @Override public void dispose() { this.shape.dispose(); } }