In my game I have many obstacles for the player to go around, but instead it just moves right through the object. How do I make the obstacles solid and not move-through-able?


public void setLocation(int x, int y) { if (getWorld().getObjectsAt(x, y, Obstacle.class).isEmpty()) { super.setLocation(x, y); } }
public void setLocation(int x, int y) { int oldX = getX(); int oldY = getY(); List<Obstacle> obstacles = getWorld().getObjects(Obstacle.class); super.setLocation(x, y); for (Obstacle obstacle : obstacles) { if (intersects(obstacle)) { super.setLocation(oldX, oldY); break; } } }
public void setLocation(int x, int y) { int oldX = getX(); int oldY = getY(); super.setLocation(x, y); if(!getIntersectingObjects(Obstacle.class).isEmpty()) { super.setLocation(oldX, oldY); } }
setLocation(x,y);