No, the idea is allright, shouldn't there be an extra : between the two commands after the If ? Better is to use an EndIf block.
Okay, so we are talking about the part after the rectsoverlap() that checks for the collision between the paddle and the ball. That is correct.
The goal is to change the angle of the ball, depending on where it hits the paddle.
I think it is important that you understand how the velocities work that Stevie explained first.
There are two variables: bal_xdir and bal_ydir.
The one you need for this problem is bal_xdir. It defines the sideways movement of the ball.
If "bal_xdir" is negative, the ball goes to the left. If it is positive, it goes to the right. The higher its absoluate value is, the more speed the ball has.
-2 = left/fast
-1 = left/slow
+1 = right/slow
+2 = right/fast
If this value is too high (too low), the ball goes too fast. Best is to check the limits for this yourself.
So, when the ball bounces back from the paddle, you need to assign "bal_xdir" with a new value.
Then you need to determine where the ball hits the paddle.
That can be done by substracting the ball's x position from the paddle's x position. If the outcome of this substraction is negative, the ball is on the left of the paddle. If the substraction is positive, the ball is on the right.
To get a proper 'touch' with this value, use:
Right before calling "Flip"
I'm adding 7 to ball_x and 50 to player_x, because you need the centre of both the ball and the paddle. That is one problem with what you were trying.
Next it is a matter of getting this value converted into a usable velocity.
Okay, so we are talking about the part after the rectsoverlap() that checks for the collision between the paddle and the ball. That is correct.
The goal is to change the angle of the ball, depending on where it hits the paddle.
I think it is important that you understand how the velocities work that Stevie explained first.
There are two variables: bal_xdir and bal_ydir.
The one you need for this problem is bal_xdir. It defines the sideways movement of the ball.
If "bal_xdir" is negative, the ball goes to the left. If it is positive, it goes to the right. The higher its absoluate value is, the more speed the ball has.
-2 = left/fast
-1 = left/slow
+1 = right/slow
+2 = right/fast
If this value is too high (too low), the ball goes too fast. Best is to check the limits for this yourself.
So, when the ball bounces back from the paddle, you need to assign "bal_xdir" with a new value.
Then you need to determine where the ball hits the paddle.
That can be done by substracting the ball's x position from the paddle's x position. If the outcome of this substraction is negative, the ball is on the left of the paddle. If the substraction is positive, the ball is on the right.
To get a proper 'touch' with this value, use:
Color 255,255,255 Text 0, 0, (ball_x + 7) - (player_x + 50)
Right before calling "Flip"
I'm adding 7 to ball_x and 50 to player_x, because you need the centre of both the ball and the paddle. That is one problem with what you were trying.
Next it is a matter of getting this value converted into a usable velocity.