We are almost there
1) ScenarioLoader using strings is working very well
2) Player is blocked by the Wall
When Player hits the wall I setLocation (get_x(), get_y()), get_x() and get_y() memories from previous location of the Player.
3) Player is moving the Blocks to right, left, up, and down.
Please take look the whole code I published
The problem now is, when the Player move the block against the wall block and player should stop. I have try many things with a different result. I tried to stop the Player if Block bump the Wall, instead it flips over the player.
Please, somebody could help me a little here. Thanks.
import greenfoot.*;
public class Player extends MovementController
{
private Display display;
public void act(){
moveWith("right", "left", "up", "down");
stopIfCollideWith(Wall.class);
}
}
public void stopIfCollideWith(Class myClass){
Object obj= getWorld().getObjects(Player.class).get(0);
Player gB = (Player)obj;
Actor actor = getOneIntersectingObject(myClass);
if(actor!=null){
setLocation(gB.get_x(), gB.get_y());
}
}
public void checkBumpWith(Class myClass){
Actor actor1 = getOneIntersectingObject(myClass);
if(actor1!=null && !blockBumpedWall()){
this.moveIt(identifyCollisionSide(actor1));
}
}

