to be added to Hero class:
|
Hero is RIGHT of Obstacle (obst.getRightEdge() < over )Hero is LEFT of Obstacle ( obst.getLeftEdge() > over + width )Hero is BELOW Obstacle ( obst.getBottomEdge() < down )Hero is ABOVE Obstacle ( obst.getTopEdge() > down + height ) |
public Integer getLeftEdge() { return whatever_the_left_edge_of_the_obstacle_is; } // end of getLeftEdge() public Integer getRightEdge() { return whatever_the_right_edge_of_the_obstacle_is; } // end of getRightEdge() public Integer getTopEdge() { // return .... } // end of getTopEdge() public Integer getBottomEdge() { // return .... } // end of getBottomEdge()
for (Integer index = 0; index < obstacleArray.length; index++) { if ( hero.isTouchingObstacle( obstacleArray[index] ) ) { // do something with or to obstacleArray[index] // or // do something with or to hero } // end if } // end for