Discuss Scratch

SarahPryor
New to Scratch
5 posts

Pong: how to bounce pls

Hello,
On behalf of a keen student, I seek your expertise in answering how to make a Pong ball bounce please. Here is the url:
https://scratch.mit.edu/projects/194731515/#editor

I will check back here for any input. Thank you very much.
deck26
Scratcher
1000+ posts

Pong: how to bounce pls

Project isn't shared but this may help you understand the maths - https://scratch.mit.edu/projects/99412537/

You can also potentially adjust for distance from the centre of the paddle or the speed of movement but start with the basic bounce.
SarahPryor
New to Scratch
5 posts

Pong: how to bounce pls

Thank you so much.. I will relay this information. I would have thought that by sharing the url, that the project would have been there for you to see. My apologies.
AveryBrodyA
Scratcher
41 posts

Pong: how to bounce pls

projects won't appear if you change them.
deck26
Scratcher
1000+ posts

Pong: how to bounce pls

AveryBrodyA wrote:

projects won't appear if you change them.
What do you mean? Once it's shared a project is visible even if you change it and until you unshared it.
happyharry789
New to Scratch
2 posts

Pong: how to bounce pls

The project has been shared.

The project url is this: https://scratch.mit.edu/projects/194731515/#player
Thank you to all who are giving suggestions.

happyharry789
New to Scratch
2 posts

Pong: how to bounce pls

How can I make it bounce off the black paddle?
deck26
Scratcher
1000+ posts

Pong: how to bounce pls

When the ball is touching the paddle you tell it to point in the new direction so the next move is away from the paddle. Your paddles are vertical so the bounce angle is just -1 times the current direction (or 0 minus the current direction).
SarahPryor
New to Scratch
5 posts

Pong: how to bounce pls

Okay, thanks for helping get the ball to bounce off the paddle. Now the question is how to program so that the ball Heads toward the opposite side. Would you have another tip, please?
deck26
Scratcher
1000+ posts

Pong: how to bounce pls

SarahPryor wrote:

Okay, thanks for helping get the ball to bounce off the paddle. Now the question is how to program so that the ball Heads toward the opposite side. Would you have another tip, please?
If it bounces off the paddle surely that's what it's doing?
SarahPryor
New to Scratch
5 posts

Pong: how to bounce pls

No, it goes in a random diagonal and does not reach the opposite side. Thanks again.
asivi
Scratcher
1000+ posts

Pong: how to bounce pls

What is the opposite side, then?
asivi
Scratcher
1000+ posts

Pong: how to bounce pls

Perhaps you want to set the rotation style to “do not rotate” and edit the costume so it faces the left side in the paint editor workspace.
deck26
Scratcher
1000+ posts

Pong: how to bounce pls

You don't currently seem to have followed my advice on how to bounce off the paddle. Once the shared project includes that method and you find it doesn't work we can look to see what you've missed.
SarahPryor
New to Scratch
5 posts

Pong: how to bounce pls

Au contraire. Each suggestion has been relayed to the student I am advocating for here. Thank you for still offering advice on this student's project.
coconut_sharks
Scratcher
12 posts

Pong: how to bounce pls

I can help you! please reply. This script doesn't lag but not the best it doesn't bounce back again and again at the previous paddle it smoothly bounces off.

The Player:

when green flag clicked
forever
point towards [ Ball v]
set rotation style [ all around v]
set y to (mouse y)
set rotation style [ don't rotate v]

The Ball:

when green flag clicked
forever
if < touching [ Paddle v] ? > then
turn cw (([direction ] of [Paddle]) - (direction)) degrees
deck26
Scratcher
1000+ posts

Pong: how to bounce pls

coconut_sharks wrote:

I can help you! please reply. This script doesn't lag but not the best it doesn't bounce back again and again at the previous paddle it smoothly bounces off.

The Player:

when green flag clicked
forever
point towards [ Ball v]
set rotation style [ all around v]
set y to (mouse y)
set rotation style [ don't rotate v]

The Ball:

when green flag clicked
forever
if < touching [ Paddle v] ? > then
turn cw (([direction ] of [Paddle]) - (direction)) degrees
Please check the date before posting.

Powered by DjangoBB