Hi, I'm making bomberman game, and I'm having problem with collisions. They work fine, but when I try to go from left to right or right to left, then near the edge, I can walk through them, otherwise they work, as can be seen through the gif if it works with BBcode.
So, I'm using getOneObjectAtOffset method for collisions in my Player class, act method. Player is 32x32 and so are other assets. It doesn't even recognize it as wall when I go through it at that part, tested it with println. This is the code for it:
So, I'm using getOneObjectAtOffset method for collisions in my Player class, act method. Player is 32x32 and so are other assets. It doesn't even recognize it as wall when I go through it at that part, tested it with println. This is the code for it:
Actor rightCollide = getOneObjectAtOffset(16, 0, Collisions.class);
if (rightCollide != null) {
if (Greenfoot.isKeyDown(keyRight)){
moveX = 0; // set direction
if (direction != direction.RIGHT){ // if I wasn't already moving this direction...
frame = 1; // start again at frame 1
direction = direction.RIGHT; // set direction to the newly specified direction
}
}
} else {
if (Greenfoot.isKeyDown(keyRight)){
moveX = 1; // set direction
if (direction != direction.RIGHT){ // if I wasn't already moving this direction...
frame = 1; // start again at frame 1
direction = direction.RIGHT; // set direction to the newly specified direction
}
}
}


But when I try to move horizontally from vertically then It won't work, it won't change direction. Why?