I used Greenfoot's
getOneIntersectingObject(Obstacles.class)
function. It uses the image of both the player and obstacles objects to detect collisions with the object "Obstacles". For example in the player movement code after the player moves right a while block runs to move the player outside the bounds of the image of "Obstacles" object.
pseudo code:
if ("right" key is down)
{
move Player right by X
}
while (getOneIntersectingObject(Obstacles.class) != null)
{
Move Player to the left one
}
2013/5/24
Mario Demo
2013/5/20
Mario Demo
2013/5/20
Mario Demo