我正在使用arduino
和android studio创建室内位置应用程序。 Arduino
使用Bluetooth
将室内位置坐标发送到Android手机。
使用以下java类
创建地图public class MazeCreator {
public static Maze getMaze(int mazeNo) {
Maze maze = null;
maze = new Maze();
if(GameView.floorval== false) {
boolean[][] vLines = new boolean[][]{
{false, false, false, true, false, true, false, false, false},
{false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false},
{false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false},
{false, false, false, true, false, true, false, false, false},
{false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false},
{false, false, false, true, false, true, false, false, false},
{false, false, false, true, false, true, false, false, false}
};
boolean[][] hLines = new boolean[][]{
{false, false, false, false, false, false, false, false, false, false},
{false, true, true, true, false, false, false, false, false, false},
{true, false, true, true, false, false, true, true, true, true},
{true, true, true, true, false, false, true, true, false, true},
{false, false, false, false, false, false, false, false, false, false},
{false, false, false, false, false, false, true, true, true, true},
{true, true, true, true, false, false, true, true, true, true},
{false, false, false, false, false, false, false, false, false, false},
{false, false, false, false, false, false, false, false, false, false}
};
maze.setVerticalLines(vLines);
maze.setHorizontalLines(hLines);
Log.d("Maze 1=" ,Integer.toString(mazeNo) );
if (mazeNo == 1) {
maze.setStartPosition(0, 0);
maze.setFinalPosition(2, 7);
}
if (mazeNo == 2) {
maze.setStartPosition(0, 0);
maze.setFinalPosition(2, 4);
}
if (mazeNo == 3) {
maze.setStartPosition(0, 0);
maze.setFinalPosition(1, 3);
}
if (mazeNo == 4) {
maze.setStartPosition(0, 0);
maze.setFinalPosition(0, 0);
}
if (mazeNo == 5) {
maze.setStartPosition(0, 0);
maze.setFinalPosition(7, 1);
}
if (mazeNo == 6) {
maze.setStartPosition(0, 0);
maze.setFinalPosition(8, 4);
}
if (mazeNo == 7) {
maze.setStartPosition(0, 0);
maze.setFinalPosition(8, 7);
}
}
else {
boolean[][] vLines = new boolean[][]{
{false, false, false, true, false, true, false, false, false},
{false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, true, false, false, false},
{false, false, false, true, false, true, false, false, false},
{false, false, false, false, false, true, false, false, false},
{false, false, false, true, false, false, false, false, false},
{false, false, false, false, false, false, false, false, false},
{false, true, true, false, false, true, true, false, false},
{false, true, true, false, false, true, true, false, false},
{false, false, true, false, false, true, true, false, false}
};
boolean[][] hLines = new boolean[][]{
{false, false, false, false, false, false, false, false, false, false},
{false, true, true, true, false, false, false, false, false, false},
{true, false, true, true, false, false, true, true, true, true},
{true, true, true, true, false, false, false, false, false, false},
{false, false, false, false, false, false, true, true, false, true},
{true, true, true, true, false, false, false, false, false, false},
{true, true, false, true, false, true, false, true, false, true},
{false, false, false, false, false, false, false, false, false, false},
{false, false, false, false, false, false, false, false, false, false}
};
maze.setVerticalLines(vLines);
maze.setHorizontalLines(hLines);
if (mazeNo == 8) {
maze.setStartPosition(0, 0);
maze.setFinalPosition(0, 0);
}
if (mazeNo == 9) {
maze.setStartPosition(0, 0);
maze.setFinalPosition(1, 4);
}
if (mazeNo == 10) {
maze.setStartPosition(0, 0);
maze.setFinalPosition(8, 8);
}
if (mazeNo == 11) {
maze.setStartPosition(0, 0);
maze.setFinalPosition(4, 8);
}
if (mazeNo == 12) {
maze.setStartPosition(0, 0);
maze.setFinalPosition(0, 8);
}
if (mazeNo == 13) {
maze.setStartPosition(0, 0);
maze.setFinalPosition(8, 3);
}
}
return maze;
}
}
人指示的 current location
和最终位置表示蓝色圆圈。现在我想draw path
到current location
到最终位置。请帮帮我
答案 0 :(得分:0)
怎么样:
画出你的台词。使用onLocationChanged(我的意思是位置监听器)激活它,从最后一个位置绘制到新位置(保护变量中的旧位置)并在获得新位置时覆盖它。