HTML and CSS Reference
In-Depth Information
switch(move){
case "up":
if (checkBounds(-1,0,tempEnemy)){
moveFound = true;
}
break;
case "down":
if (checkBounds(1,0,tempEnemy)){
moveFound = true;
}
break;
case "left":
if (checkBounds(0,-1, tempEnemy)){
moveFound = true;
}
break;
case "right":
if (checkBounds(0,1,tempEnemy)){
moveFound = true;
}
break
}
movePtr++
if (movePtr==directionsToTest.length){
//do not move if no move found
//this should be impossible
chooseRandom = true;
}
}
}else{
chooseRandom = true;
}
//pick random direction to test;
if (chooseRandom) {
while(!moveFound){
switch(Math.floor(Math.random()*4)){
case 0:
if (checkBounds(-1,0,tempEnemy)){
moveFound = true;
}else{
}
break;
Search WWH ::




Custom Search