Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to code Pong?
- SpiritSpinch
-
Scratcher
9 posts
How to code Pong?
here’s what I have so far: https://scratch.mit.edu/projects/1383891195
- NMario84
-
Scratcher
1000+ posts
How to code Pong?
You don't have any touching (sensing) blocks.
For bouncing off top and bottom edge of screen you need to reverse the Y flow/movement of the ball.
You'll need a way for the player paddle to reverse the X flow/movement of the ball.
For bouncing off top and bottom edge of screen you need to reverse the Y flow/movement of the ball.
You'll need a way for the player paddle to reverse the X flow/movement of the ball.
- SpiritSpinch
-
Scratcher
9 posts
How to code Pong?
You don't have any touching (sensing) blocks.
For bouncing off top and bottom edge of screen you need to reverse the Y flow/movement of the ball.
You'll need a way for the player paddle to reverse the X flow/movement of the ball.
I get that, but I don’t know how to define the movement/momentum of the ball in order to reverse it.
- NMario84
-
Scratcher
1000+ posts
How to code Pong?
move (X) steps // Replace X with any number for the ball speed
if on edge, bounce // Checks if the object hits the edge of the screen to reverse direction.
I just did a search myself, and here's a few youtube tutorials I saw that may help:
https://www.youtube.com/watch?v=QQhGdzySZ-o
https://www.youtube.com/watch?v=sn6Q1GVBdKs
https://www.youtube.com/watch?v=JfFzKQnlZAM
- 10goto10
-
Scratcher
1000+ posts
How to code Pong?
I made a remix of your project that uses individual sprites instead of clones and has some movement code in it. https://scratch.mit.edu/projects/1384364401/
Clones are okay but sometimes they get in the way of experimenting and making things.
Clones are okay but sometimes they get in the way of experimenting and making things.
- Discussion Forums
- » Help with Scripts
-
» How to code Pong?