Game Development Reference
In-Depth Information
//trace("AI UP");
predator.rotation = 0;
}else if (verticalDiff < 0) {
//trace("AI DOWN");
predator.rotation = 180;
}else if (horizontalDiff > 0) {
//trace("AI LEFT");
predator.rotation = -90;
}else if (horizontalDiff < 0) {
//trace("AI RIGHT");
predator.rotation = 90;
}
act = true;
}
if (act) {
if (predator.currCol == prey.currCol) {
//trace ("same col");
difference = Math.abs(predator.currRow - prey.currRow);
if (predator.currRow <prey.currRow) {
testDX = 0;
testDY = 1;
testRotation = 180;
}else if (predator.currRow > prey.currRow) {
testDX = 0;
testDY = -1;
testRotation = 0;
}else {
testDX = 0;
testDY = 0;
testRotation = 99;
}
}else if (predator.currRow == prey.currRow) {
difference = Math.abs(predator.currCol- prey.currCol);
// trace ("same row");
if (predator.currCol<prey.currCol) {
testDX = 1;
testDY = 0;
testRotation = 90;
}else if (predator.currCol>prey.currCol) {
testDX = -1;
testDY = 0;
testRotation = -90;
}else {
testDX = 0;
testDY = 0;
testRotation = 99;
}
Search WWH ::




Custom Search