Colliding with rectangle

image
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

Sorry, it took a while. My first time using direction, i did not know that it could generate random degrees. But it seem to not working when the ball already facing that direction. For example, when the ball already facing east and i hit it with my paddle. Nothing change. I increase my paddle height for testing.


But other than that, all working fine. I change a few blocks because i set Ball.OriginAtCenter to be true.
So, here is how i do it.

I'll try to change few things to get what i want. Thank you for your solution

This discussion might help Projectile Targeting System and Projectile Animations because the X and Y coordinates provided are the lower left corner of the Sprite (not the center) and How do you adjust collision on mit app inventor

Here is as close as I could get, not perfect because the ball sails by the Sprite too many times.

paddle_bounce.aia (8.2 KB) when Ball1 EdgeReached

I had to set Ball1 as centered at X,Y.

Sorry, that thread has a lot of reading, took me a while to understand the problem. ABG solution is quite straight forward, I understand the general idea by comparing their coordinate XY position.

You know you could just make the imageSprite1 to be bigger, then you will have less problem.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.