I just started programming 8 weeks ago, and started making a platformer. Everythings working fine except, i can walk through cliffs. Can anybody help to make a code so that i can't walk through cliffs anymore. Make the wall an impassable object.


setLocation(x, y);
if (getWorld().getObjectsAt(x, y, Object.class).isEmpty()) { //instead of object you must add the classname of the object your searching for; setLocation(x, y); }
public void solidObject() { int x = getX(); int y = getY(); if (getWorld().getObjectsAt(x, y, Cliff.class).isEmpty()) { setLocation(x, y); } }
public void solidObject() { int x = getX(); int y = getY(); x += moveX;//moveX is the change in x directon you want your character to move; y += moveY;//moveY is the same in y direction; if (getWorld().getObjectsAt(x, y, Cliff.class).isEmpty()) { setLocation(x, y); } }