I'm creating an Arkanoid clone using Haxe and Openfl. I'm thinking the bouncing algorithms could be improved. But I'm not sure how to handle those. I was hoping you guys could help.
private function bounceBall():Void {
var direction:Int = (ballMovement.x > 0)?( -1):(1);
var randomAngle:Float = (Math.random() * Math.PI / 2) - 45;
ballMovement.x = -1 * Math.cos(randomAngle) * ballSpeed;
ballMovement.y = Math.sin(randomAngle) * ballSpeed;
}
Since I've never coded anything in Haxe I followed a tutorial to build a pong game. This is one of the functions that was used in the pong exercise. I think it's causing the ball to bounce left/right and rarely up or down. Can you guys help me out? How can I recreate the arkanoid bouncing ball logic?
You can find the rest of the source Here
direction.x * -1
\$\endgroup\$