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

#1 2010-06-25 21:34:53

explosivedude
Scratcher
Registered: 2010-06-22
Posts: 64

need help getting ball to move in pong

okay im making a pong game and im trying to figure out how to get the ball to move can u please help me.

Offline

 

#2 2010-06-25 21:40:33

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

Re: need help getting ball to move in pong

Code:

When Green Flag Clicked
forever
  move 3 steps
  if <touching [paddle]>
    turn [clockwise] 180 degrees
  end
end

That should take care of your ball and your paddle. Hope that helps  smile

Offline

 

#3 2010-06-27 18:36:46

Locomule
Scratcher
Registered: 2009-08-24
Posts: 500+

Re: need help getting ball to move in pong

ps.. You will find that due to the way Scratch handles x and y values, you need a special formula to figure some of the bounces. Check out my Pong link I posted in your other forum post for the correct bounce angle formulas. One key to this method is that it has to keep track of which direction the ball is traveling in so that it can use the right formula to figure the bounce angle, but that is all in my script which I intentionally wrote about as simple as possible just for people working on Pong  big_smile


aka Pain from DragonSpires, Delrith Online, BotBattle, Urban Dead etc etc lol

Offline

 

Board footer