PDA

View Full Version : Arkanoid like game 1st one of mine :)



mcfly_tm
July 7th, 2005, 07:42 PM
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 :

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;

}

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 :)

mcfly_tm
July 7th, 2005, 07:53 PM
I was thinking about my post and ive encountred another problem...
If the problem in my first post would be resolved, then it leads to antoher problem that is speed. When angle is "flat" it takes quite a long time for ball to to get from paddle to bricks , so what i need is to add speed. if angle of bounce is flatter the speed increases ( and angle > speed decreases)...

any thoughts on that ?

NiñoScript
July 10th, 2005, 09:55 AM
if you send me a .fla (for MX, not MX2004 plz), i could help you, im no good with abstract things :P