Colliding with rectangle

I'm designing a simple pong games, how do i make it bounce as I draw in my plan? I managed to use ball collided with to randomly change the heading (red arrow) but could not figure out the way to add another condition (how to know which side of the sprite) for the green arrow.

Here is a sample pong doc to get you started ...

Thank you, that is a cool idea of drawing the goalie instead of moving the paddle. But i could not find answer to my question.

How do you make the ball bounce adapting if it touch Top Paddle, Right Side Paddle, Left Side Paddle or Bottom Paddle?

How are you controlling the paddle?

62 because it is half of paddle.width

The Ball1.Collided event block has an other parameter.
Test it against the sprite components of the paddles, one at a time in an if/then/elseif ladder.

Sorry for my english, i think you are mistaken. Top, Right, Bottom, or Left is 1 component. I could not figure out a way to know if the the ball touching which side of the paddle, that is why i confused on how to create the if/then/else condition.

For a more advanced feature, you may use AccelerometerSensor to control the paddle.

Is there only one paddle, or will there be multiple paddles?

Thank you for the suggestion. Iam still working with the collision

1 Like

Only 1 paddle. Solo player game

Is there any rule that -

  • The ball should go to the left when the left part of the paddle is hit.

Or should go to any random direction.

3 rule:

  1. Touch the top part of paddle, ball bounce to random 20-160
  2. Touch the right side, ball -90 degree
  3. Touch the left side, ball +90 degree

OK wait a minute.
Can you please say how are you moving the ball? Using any Clock component or what?

I used ball interval and speed to move it. Here is my current program

Here are some draggable blocks you can try ...

What's the issue here?

That only does the first rule. 2 and 3 for left and right does not work.

Are you saying that if the ball hits the edges (not corners) of the paddle, the 2nd and 3rd rule must be followed?

Yes, that is what iam trying to do.

1 Like