Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Bouncing off sprites
- awesomedomination8
-
100+ posts
Bouncing off sprites
I am trying to make a sort of Pong game, but I am trying to make it so that the ball bounces off the paddles, and I've already tried this.
Please help!
(I'm not good at scratch blocks on forum…)
Please help!
- BKFighter
-
1000+ posts
Bouncing off sprites
From an earlier post:
Oct. 11, 2013 19:07:24
Locomule
Scratcher
100+ posts
I Need Help Making the Wall Bounce Look Realistic
Just as a fyi, here are the formulas for changing direction instead of flipping X and Ys…
Side wall reflections are just direction * -1
Top and bottom wall reflections are 180 - direction
You still have to deal with corners where you hit two walls at once. My solution is to use either color sensing with different colored walls or 4 sprites. Either way, I use a 2 entry list to keep up with which walls, if any, the ball is touching. Since I'm using a list, it also allows me to verify which wall was hit last when touching two walls at once. Then I just figure the angle for the second wall, move the ball until it is no longer touching the second wall (It will not be touching the first either by then) and then clear my list of which walls the ball is touching.
Now the ball has bounced off both corners correctly and is back in play. I wrote this and tested it, it works. I will upload the project tonight or tomorrow, whenever I get a chance to get my laptop online.
___________________________________________________________________________
Need help? Try the Scratch Wiki!
Report | Quote
#12Oct. 12, 2013 13:06:54
Locomule
Scratcher
100+ posts
I Need Help Making the Wall Bounce Look Realistic
Here it is
___________________________________________________________________________
Need help? Try the Scratch Wiki!
Report | Quote
Link: https://scratch.mit.edu/discuss/topic/17687/?page=1#post-162096
Oct. 11, 2013 19:07:24
Locomule
Scratcher
100+ posts
I Need Help Making the Wall Bounce Look Realistic
Just as a fyi, here are the formulas for changing direction instead of flipping X and Ys…
Side wall reflections are just direction * -1
Top and bottom wall reflections are 180 - direction
You still have to deal with corners where you hit two walls at once. My solution is to use either color sensing with different colored walls or 4 sprites. Either way, I use a 2 entry list to keep up with which walls, if any, the ball is touching. Since I'm using a list, it also allows me to verify which wall was hit last when touching two walls at once. Then I just figure the angle for the second wall, move the ball until it is no longer touching the second wall (It will not be touching the first either by then) and then clear my list of which walls the ball is touching.
Now the ball has bounced off both corners correctly and is back in play. I wrote this and tested it, it works. I will upload the project tonight or tomorrow, whenever I get a chance to get my laptop online.
___________________________________________________________________________
Need help? Try the Scratch Wiki!
Report | Quote
#12Oct. 12, 2013 13:06:54
Locomule
Scratcher
100+ posts
I Need Help Making the Wall Bounce Look Realistic
Here it is
___________________________________________________________________________
Need help? Try the Scratch Wiki!
Report | Quote
Link: https://scratch.mit.edu/discuss/topic/17687/?page=1#post-162096
- awesomedomination8
-
100+ posts
Bouncing off sprites
ummm… What am I supposed to do? I didn't say I needed help making wall bounces look realistic… From an earlier post:
Oct. 11, 2013 19:07:24
Locomule
Scratcher
100+ posts
I Need Help Making the Wall Bounce Look Realistic
Just as a fyi, here are the formulas for changing direction instead of flipping X and Ys…
Side wall reflections are just direction * -1
Top and bottom wall reflections are 180 - direction
You still have to deal with corners where you hit two walls at once. My solution is to use either color sensing with different colored walls or 4 sprites. Either way, I use a 2 entry list to keep up with which walls, if any, the ball is touching. Since I'm using a list, it also allows me to verify which wall was hit last when touching two walls at once. Then I just figure the angle for the second wall, move the ball until it is no longer touching the second wall (It will not be touching the first either by then) and then clear my list of which walls the ball is touching.
Now the ball has bounced off both corners correctly and is back in play. I wrote this and tested it, it works. I will upload the project tonight or tomorrow, whenever I get a chance to get my laptop online.
___________________________________________________________________________
Need help? Try the Scratch Wiki!
Report | Quote
#12Oct. 12, 2013 13:06:54
Locomule
Scratcher
100+ posts
I Need Help Making the Wall Bounce Look Realistic
Here it is
___________________________________________________________________________
Need help? Try the Scratch Wiki!
Report | Quote
Link: https://scratch.mit.edu/discuss/topic/17687/?page=1#post-162096
Last edited by awesomedomination8 (May 17, 2016 19:00:01)
- JMB17
-
6 posts
Bouncing off sprites
Try getting the ball to “run away from the paddle” but just fall down again.
First, create the paddle, then the ball. Select the ball, and go to its script. Create this script:
First, create the paddle, then the ball. Select the ball, and go to its script. Create this script:
- JMB17
-
6 posts
Bouncing off sprites
Ignore the stuff inbetween the two scripts that start with green flag, it was a mistake. Can't seem to get a handle of these darn script blocks. 

- awesomedomination8
-
100+ posts
Bouncing off sprites
Yeah, neither can I… Well, thanks! I'll see if it works. Ignore the stuff inbetween the two scripts that start with green flag, it was a mistake. Can't seem to get a handle of these darn script blocks.

- awesomedomination8
-
100+ posts
Bouncing off sprites
I've figured out the problem. Thanks everyone for helping!
- stickfiregames
-
1000+ posts
Bouncing off sprites
Please don't necropost (posting on old resolved topics) in this forum. It is better to make a new topic explaining what you need help with. SO i find this being difficult
The way to bounce off a vertical paddle is
and to bounce off a horizontal paddle it's
This project has a custom block that can bounce off a line at any angle.
- Discussion Forums
- » Help with Scripts
-
» Bouncing off sprites