Hi, im doing a Breakout game for a class project. In the game, when the ball touches the left or right side of a brick, the balls just change his vertical speed and not his horizontal speed, so it doesnt bounce correctly. I have tried to fix it but i don't know how to do it, so every help or comment is really appreciated.
This is the code that make the ball bounce when it touches a brick, but i cant make it to work correctly when it touches a side of the brick because i dont know how to detect when the ball is colliding with a side of the brick
public void reboteBarra() {
Actor BloqueA = getOneIntersectingObject(BloqueA.class);
if (BloqueA != null) {
vel_y = -vel_y;
score = score + 20;
getWorld().showText("Puntuación = "+ score.toString(), 900, 20);
Greenfoot.playSound("sonidos.wav");
}
}

