Game Development Reference
In-Depth Information
return false ;
}
Pathfinding at the End of Path
What if it's at the end of a path or approaching another sprite?
//Determines if the specified monster is either at the end of
//a path or approaching another sprite.
//Parameters:
//
m - the specified monster
public boolean checkIfTurnAround(Monster m){
int mrow = m.row;
int mcol = m.col;
switch (m.direction){
case DIR_DOWN:
if (gv.checkCollision(mrow+1,mcol)) return true ;
break ;
case DIR_LEFT:
if (gv.checkCollision(mrow,mcol-1)) return true ;
break ;
case DIR_RIGHT:
if (gv.checkCollision(mrow,mcol+1)) return true ;
break ;
case DIR_UP:
if (gv.checkCollision(mrow-1,mcol)) return true ;
break ;
}
return false ;
}
Search WWH ::




Custom Search