mirror of
https://github.com/guezoloic/racing-game.git
synced 2026-03-28 18:03:50 +00:00
feat(Map.java): ajout fonction bindPath
This commit is contained in:
42
src/Map.java
42
src/Map.java
@@ -1,19 +1,47 @@
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Map {
|
||||
public class Map
|
||||
{
|
||||
private Circuit[][] map;
|
||||
private Point[] pathMap;
|
||||
private ArrayList<Point> pathMap;
|
||||
|
||||
public Map(Circuit[][] map) {
|
||||
public Map(Circuit[][] map)
|
||||
{
|
||||
this.map = map;
|
||||
this.buildPath();
|
||||
}
|
||||
|
||||
private boolean buildPath() {
|
||||
return false;
|
||||
private Point[] bindPath()
|
||||
{
|
||||
Point start = null;
|
||||
Point end = null;
|
||||
|
||||
for (int i = 0; i < map.length; i++)
|
||||
{
|
||||
for (int j = 0; j < map.length; j++)
|
||||
{
|
||||
switch (map[i][j].getType())
|
||||
{
|
||||
case CircuitCell.START:
|
||||
if (start == null) start = new Point(i, j);
|
||||
else return null;
|
||||
break;
|
||||
case CircuitCell.FINISH:
|
||||
if (end == null) end = new Point(i, j);
|
||||
else return null;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Circuit getElement(int x, int y) {
|
||||
return new Point[] {start, end};
|
||||
}
|
||||
|
||||
|
||||
public Circuit getElement(int x, int y)
|
||||
{
|
||||
return map[y][x];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user