Discuss Scratch

xw132
Scratcher
6 posts

Who can help me to fix my project of "Pong"

Hi,

I'm trying to make the project of “Pong” but a problem comes out when I just started to write the script for the paddle. As you can see in under links, when I press “left” or Right" arrows, the paddle go up and down but not just move 10 steps horizontally. I don't understand why. Whoever can help me fix it?

Thanks!

https://scratch.mit.edu/projects/175909602/
mstone326
Scratcher
1000+ posts

Who can help me to fix my project of "Pong"

Your paddle sprite is not centered properly. It is drawn in the bottom left of the paint editor. Use the crosshairs in the top right of the paint editor and drag the center tool to the middle of your paddle. Then you'll be good to go.

Also, it would be more efficient to change x by 10 to move right and change x by -10 to move left. Then you don't have to worry about rotation by pointing in direction. You can eliminate the block all together

EDIT:
Here is quick example of sprite centering and pointing in direction. Both sprites have the exact same script although the bottom sprite is not centered in the editor. So it jumps to the other side. I explain this to my students this way: take a piece of paper, in the middle draw a stick figure.

Now rotate the paper 180 degrees, he is in the same center location but upside down, same as scratch unless you change rotation style to Left-RIght to stop him from flipping.

Now this time, draw a stick figure on the far left of the paper, and flip rotate the paper 180 degrees, he will no be on the far right. That is what is happening with your paddle.

https://scratch.mit.edu/projects/176089803/

Last edited by mstone326 (Sept. 23, 2017 01:07:46)


High School Athletic Director / Middle School Tech Teacher / High School Baseball Coach
Kung Fu by Nintendo 1984 - https://scratch.mit.edu/projects/369994801/
Taco Defense - Speed Typing - https://scratch.mit.edu/projects/316795450/
Halloween Boss Battle - Taking Back our Woods - https://scratch.mit.edu/projects/257155118/
Almost Pong - https://scratch.mit.edu/projects/656276979/
Studio - My Best Projects - https://scratch.mit.edu/studios/4125978/
Forum Help Project Examples - https://scratch.mit.edu/studios/4133335
xw132
Scratcher
6 posts

Who can help me to fix my project of "Pong"

Thank you so much for helping me out and your explanation is perfect to understand!!

Now I updated it with center and it almost works though it still moves up and down a little when I press left or right arrow key. Is it because I did not center it perfectly? Do you know to center it perfectly?

Thank you again!
mstone326
Scratcher
1000+ posts

Who can help me to fix my project of "Pong"

xw132 wrote:

Thank you so much for helping me out and your explanation is perfect to understand!!

Now I updated it with center and it almost works though it still moves up and down a little when I press left or right arrow key. Is it because I did not center it perfectly? Do you know to center it perfectly?

Thank you again!

It is probably not centered perfectly and you are still using the point in direction block. So with it being not centered when it flips (points in direction) then it is off center. Same as the example of drawing the stick figure. Draw it just above where you think center of the paper is. Rotate it 180 and he'll be just below center. That is what is happening here.

4 ways to fix.

1. Add a block set rotation style to don't rotate to each of your left and right arrow clicked scripts.
2. Add a green flag clicked block to the paddle script and put a single set rotation style to don't rotate
3. Click on the info button on your sprite, the little i in a circle. And change rotation to the little dot (don't rotate).
4. Remove move 10 steps and remove point in direction from both scripts. Instead use change X by 10 under right arrow. Change X by -10 under left arrow. No need for any rotation blocks that way.

Last edited by mstone326 (Sept. 23, 2017 11:31:50)


High School Athletic Director / Middle School Tech Teacher / High School Baseball Coach
Kung Fu by Nintendo 1984 - https://scratch.mit.edu/projects/369994801/
Taco Defense - Speed Typing - https://scratch.mit.edu/projects/316795450/
Halloween Boss Battle - Taking Back our Woods - https://scratch.mit.edu/projects/257155118/
Almost Pong - https://scratch.mit.edu/projects/656276979/
Studio - My Best Projects - https://scratch.mit.edu/studios/4125978/
Forum Help Project Examples - https://scratch.mit.edu/studios/4133335
xw132
Scratcher
6 posts

Who can help me to fix my project of "Pong"

mstone326 wrote:

xw132 wrote:

Thank you so much for helping me out and your explanation is perfect to understand!!

Now I updated it with center and it almost works though it still moves up and down a little when I press left or right arrow key. Is it because I did not center it perfectly? Do you know to center it perfectly?

Thank you again!

It is probably not centered perfectly and you are still using the point in direction block. So with it being not centered when it flips (points in direction) then it is off center. Same as the example of drawing the stick figure. Draw it just above where you think center of the paper is. Rotate it 180 and he'll be just below center. That is what is happening here.

4 ways to fix.

1. Add a block set rotation style to don't rotate to each of your left and right arrow clicked scripts.
2. Add a green flag clicked block to the paddle script and put a single set rotation style to don't rotate
3. Click on the info button on your sprite, the little i in a circle. And change rotation to the little dot (don't rotate).
4. Remove move 10 steps and remove point in direction from both scripts. Instead use change X by 10 under right arrow. Change X by -10 under left arrow. No need for any rotation blocks that way.



Thank you so much!! You are so professional that all your 4 ways work so well !!!!!

Powered by DjangoBB