본문내용
.repaint();
frame.repaint(now.getX()*20 + 50,
now.getY()*20 + 50,
Maze.width,
Maze.height);
Thread.sleep(300);
System.out.println(now.getY() + ", " + now.getX());
return true;
}
/**
* - This function check how many enable ways exist?
*
* @param map :
* this is problem
* @return Down_Right_Light_up
: if exist way each of direction filled
* with '1'
*/
protected int[] checkPath(int[][] map) {
int nowY = now.getY();
int nowX = now.getX();
int numOfWay = 0;
int Up_Lt_Rt_Dn[] = new int[4];
int indexOfArray = 0;
int beforeX = 0;
int beforeY = 0;
numOfBranch = 0;
if (!footprints.empty())
beforeX = footprints.peek().getX();
if (!footprints.empty())
beforeY = footprints.peek().getY();
// 1.up_check
if ((nowY - 1 >= 0) && (map[nowY - 1][nowX] == 1)) {
if ((nowY - 1 != beforeY) || (nowX != beforeX)) {
Up_Lt_Rt_Dn[indexOfArray] = 1;
numOfWay++;
}
}
indexOfArray++;
// 2.left_check
if ((nowX - 1 >= 0) && (map[nowY][nowX - 1] == 1)) {
if ((nowY != beforeY) || (nowX - 1 != beforeX)) {
Up_Lt_Rt_Dn[indexOfArray] = 1;
numOfWay++;
}
}
indexOfArray++;
// 3.right_check
if ((nowX + 1 < Maze.getXMax()) && (map[nowY][nowX + 1] == 1)) {
if ((nowY != beforeY) || (nowX + 1 != beforeX)) {
Up_Lt_Rt_Dn[indexOfArray] = 1;
numOfWay++;
}
}
indexOfArray++;
// 4.down_check
if ((nowY + 1 < Maze.getYMax()) && (map[nowY + 1][nowX] == 1)) {
if ((nowY + 1 != beforeY) || (nowX != beforeX)) {
Up_Lt_Rt_Dn[indexOfArray] = 1;
numOfWay++;
}
}
numOfBranch = numOfWay;
return Up_Lt_Rt_Dn;
}
}
위의 소스는 미로까지 구성하느 소스입니다.
frame.repaint(now.getX()*20 + 50,
now.getY()*20 + 50,
Maze.width,
Maze.height);
Thread.sleep(300);
System.out.println(now.getY() + ", " + now.getX());
return true;
}
/**
* - This function check how many enable ways exist?
*
* @param map :
* this is problem
* @return Down_Right_Light_up
: if exist way each of direction filled
* with '1'
*/
protected int[] checkPath(int[][] map) {
int nowY = now.getY();
int nowX = now.getX();
int numOfWay = 0;
int Up_Lt_Rt_Dn[] = new int[4];
int indexOfArray = 0;
int beforeX = 0;
int beforeY = 0;
numOfBranch = 0;
if (!footprints.empty())
beforeX = footprints.peek().getX();
if (!footprints.empty())
beforeY = footprints.peek().getY();
// 1.up_check
if ((nowY - 1 >= 0) && (map[nowY - 1][nowX] == 1)) {
if ((nowY - 1 != beforeY) || (nowX != beforeX)) {
Up_Lt_Rt_Dn[indexOfArray] = 1;
numOfWay++;
}
}
indexOfArray++;
// 2.left_check
if ((nowX - 1 >= 0) && (map[nowY][nowX - 1] == 1)) {
if ((nowY != beforeY) || (nowX - 1 != beforeX)) {
Up_Lt_Rt_Dn[indexOfArray] = 1;
numOfWay++;
}
}
indexOfArray++;
// 3.right_check
if ((nowX + 1 < Maze.getXMax()) && (map[nowY][nowX + 1] == 1)) {
if ((nowY != beforeY) || (nowX + 1 != beforeX)) {
Up_Lt_Rt_Dn[indexOfArray] = 1;
numOfWay++;
}
}
indexOfArray++;
// 4.down_check
if ((nowY + 1 < Maze.getYMax()) && (map[nowY + 1][nowX] == 1)) {
if ((nowY + 1 != beforeY) || (nowX != beforeX)) {
Up_Lt_Rt_Dn[indexOfArray] = 1;
numOfWay++;
}
}
numOfBranch = numOfWay;
return Up_Lt_Rt_Dn;
}
}
위의 소스는 미로까지 구성하느 소스입니다.