Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Bounce angle
- DanielBronfen
-
3 posts
Bounce angle
I'm making the arcade game pong and I don't know how to calculate the angle of the bounce. Could someone help? Thanks!
Last edited by DanielBronfen (Feb. 2, 2019 17:51:20)
- drchubbington
-
100+ posts
Bounce angle
Make a variable called XVel and one called YVel. Always change the x position by XVel and the y by YVel. Then, in a “run without screen refresh” myblock, change the x by XVel. If it's hitting something to bounce on, set Xvel to XVel * -1. Put it back to it's original x position and do the same for YVel and the y position.
- gor-dee
-
1000+ posts
Bounce angle
Scratch uses 0 degrees = “north”, 90 = east, -90 = west & 180 (or-180) = south. So say you ball is travelling at 60 degrees toward the right hand paddle you would want it to bounce and change to -60 degrees for a symmetrical bounce which is easy
you will probably want to adjust this a bit so that it isn't always symmetrical, maybe add
you will probably want to adjust this a bit so that it isn't always symmetrical, maybe add
Last edited by gor-dee (Feb. 2, 2019 18:05:39)
- DanielBronfen
-
3 posts
Bounce angle
gor-dee I tried that, it doesn't work, I don't know why. As for drchubbington, could you post in blocks what you mean? I don't understand. thx
- DanielBronfen
-
3 posts
Bounce angle
Never mind I figured it out. thx anyway 
if direction>0
point in direction 180-direction
else
point in direction -180-direction

if direction>0
point in direction 180-direction
else
point in direction -180-direction
- Oobleck6869
-
1 post
Bounce angle
https://scratch.mit.edu/projects/99412537/is there a way to detect whether the ball is bouncing off of a 90- or a 0-degree angle?
- Discussion Forums
- » Help with Scripts
-
» Bounce angle