미로찾기 소스
본 자료는 2페이지 의 미리보기를 제공합니다. 이미지를 클릭하여 주세요.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
해당 자료는 2페이지 까지만 미리보기를 제공합니다.
2페이지 이후부터 다운로드 후 확인할 수 있습니다.

본문내용

.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;
}
}
위의 소스는 미로까지 구성하느 소스입니다.

키워드

  • 가격2,000
  • 페이지수7페이지
  • 등록일2012.03.13
  • 저작시기2009.12
  • 파일형식한글(hwp)
  • 자료번호#799142
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니