Thanks to the great tut ive found on this page i made my first flash game :-). I started to “tune” it a little bit and meet problems while changing bouncing “engine”…
This is the part of AS responsible for bouncing of the paddle :
[AS]
else if (this.y > pGame.barLevel - this._height/2) {
var l = bar._x - bar._width/2;
var r = bar._x + bar._width/2;
if (this.x > l && this.x < r) {
trace ("Collision with the bar") ;
this.y = pGame.barLevel - this._height/2;
this.vy *= -1;
}
[/AS]
this.vy *= -1; this particular line “tells” ball to bounce in 90 degrees angle ( basically that means ball can only have two directions right ( 45 degrees) and left (-45 degrees)).
The million dollar question is : how can I change code so that angle of bounce would be determined by the point in which ball hits the paddle ? I have to add that the closer ball is to the end of paddle the “flatter” angle should be… can somebody help me with that ?
thanks in forward