This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-05-21 19:08:34

jackfitz
Scratcher
Registered: 2010-05-20
Posts: 5

How do you keep the ball moving in Pong? I need to know the formula.

I downloaded Scratch yesterday, but I'm pretty thorough in Scratch. I have been altering Pong for quite a while now. I need to know the formula to keep the ball moving in Pong. See, I have it so that when you click the green flag, the ball will move 15 steps in the y-axis, and then you have to click it again to have it move another 15 steps in the y-axis. I need to know how to change this. Here's my project in case you don't understand. http://scratch.mit.edu/projects/jackfitz/1066546 Picture or project would be nice.

Offline

 

#2 2010-05-21 19:14:20

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: How do you keep the ball moving in Pong? I need to know the formula.

Hi,
This should probably go in "All About Scratch."

As for your question: I'm guessing you want to make it so that you don't have to click the green flag every time? You can easily use a forever loop. You can easily put the code you already have in a "forever" loop, which makes the thing repeat itself until the project is stopped - but you might want to alter the 15 steps to, say, 2 or 3 steps - the project moves quickly!

Offline

 

#3 2010-05-21 20:08:36

jackfitz
Scratcher
Registered: 2010-05-20
Posts: 5

Re: How do you keep the ball moving in Pong? I need to know the formula.

Could you try downloading my project? I think then you'll understand.

Offline

 

#4 2010-05-21 20:18:39

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: How do you keep the ball moving in Pong? I need to know the formula.

Oh, your problem is that you're using a "wait" block. Take that out, and it'll work just fine - what the wait block does is already addressed by the "if" block right after it.

And like I said before, you may wish to change how much it changes the "Y" coordinate by a little bit less than 15.

Also, take out the "point in direction (180)" and move it to before the "Forever" block, but after "When Green Flag Clicked."

Last edited by coolstuff (2010-05-21 20:21:42)

Offline

 

#5 2010-05-21 20:54:22

jackfitz
Scratcher
Registered: 2010-05-20
Posts: 5

Re: How do you keep the ball moving in Pong? I need to know the formula.

Could you try adding scratch blocks to that to demonstrate?

Offline

 

#6 2010-05-21 21:02:24

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: How do you keep the ball moving in Pong? I need to know the formula.

You want the first script on the ball sprite to look like this:
http://i46.tinypic.com/2r5erfo.gif
I hope that helps!

Last edited by coolstuff (2010-05-21 21:05:14)

Offline

 

#7 2010-05-21 22:47:02

jackfitz
Scratcher
Registered: 2010-05-20
Posts: 5

Re: How do you keep the ball moving in Pong? I need to know the formula.

Ok. Thanks for the help.

Offline

 

#8 2010-05-21 22:48:40

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: How do you keep the ball moving in Pong? I need to know the formula.

jackfitz wrote:

Ok. Thanks for the help.

No problem!

Offline

 

Board footer