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

#1 2011-03-04 16:43:10

ian528
Scratcher
Registered: 2010-05-25
Posts: 500+

Pong!

I need help on making a bounce engine for my pong game. I already used [Point in (direction)+180], but that wasn't realistic. Please help!  sad

Offline

 

#2 2011-03-04 17:05:08

kayybee
Scratcher
Registered: 2009-12-07
Posts: 1000+

Re: Pong!

You could use the technique of math.

Bouncing is hard. Maybe if you try using math, it'd work. I'll try it.

I thought of it before, but it seemed hard. I'll try again.

Offline

 

#3 2011-03-04 20:31:03

ian528
Scratcher
Registered: 2010-05-25
Posts: 500+

Re: Pong!

I tried [Point in direction (180)- Direction*2)] , but that didn't work very well. Can anyone help?  sad

Offline

 

#4 2011-03-05 00:11:28

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Pong!

What kind of bounce do you want?
Just directly back? Or sideways-like?


Hai.

Offline

 

#5 2011-03-05 02:09:20

floppy_gunk
Scratcher
Registered: 2008-11-14
Posts: 500+

Re: Pong!

ian528 wrote:

I tried [Point in direction (180)- Direction*2)] , but that didn't work very well. Can anyone help?  sad

for bouncing on the paddle or ceiling, use [point in direction (180 - direction)], and for bouncing on the walls, use [point in direction (0 - direction)]

For a bounce on a 'curved' paddle, use this:

[set dir to direction]
[point towards paddle]
[turn clockwise (direction - dir) degrees]


http://img163.imageshack.us/img163/1917/2856lg.jpg Get it now!  smile

Offline

 

#6 2011-03-05 09:37:35

ian528
Scratcher
Registered: 2010-05-25
Posts: 500+

Re: Pong!

floppy_gunk wrote:

For a bounce on a 'curved' paddle, use this:

[set dir to direction]
[point towards paddle]
[turn clockwise (direction - dir) degrees]

Well, the ceiling bounce works perfectly now, but the paddle bounce still gets way too glitchy.  tongue

Offline

 

#7 2011-03-05 10:48:11

ian528
Scratcher
Registered: 2010-05-25
Posts: 500+

Re: Pong!

Still need help.

Offline

 

#8 2011-03-05 11:08:26

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Pong!

try [blocks]
<point in direction( (( <direction> <-> 90 ))
[/blocks]
instead  smile



actually, never mind. Try looking at existing pong projects, like m44's one for example!

Last edited by LS97 (2011-03-05 11:14:16)

Offline

 

#9 2011-03-09 21:02:34

Ryan42
Scratcher
Registered: 2009-01-22
Posts: 3

Re: Pong!

Hey, I've run into this problem a while ago, and a solution. I, however, do know the 'math' way, but that's annoying, and confusing if you don't know trig. What I basically did for bouncing was invert the direction and add 180.
<point in direction( (( <direction> <*> -1 ))
<turn cw( 180 )degrees>
at least this was my code for my pong game.

Offline

 

#10 2011-03-11 14:33:59

Zn592
New Scratcher
Registered: 2011-03-06
Posts: 1

Re: Pong!

http://scratch.mit.ehttp://scratch.mit.edu/forums/viewtopic.php?pid=694442#req_messagedu/forums/viewtopic.php?pid=694442#req_messagehttp://scratch.mit.edu/forums/viewtopic.php?pid=694442#req_messagehttp://scratch.mit.edu/forums/viewtopic.php?pid=694442#req_message

Offline

 

#11 2011-03-11 21:03:02

XxXbobXxX
Scratcher
Registered: 2011-02-10
Posts: 50

Re: Pong!

i made i pong project. download it and use it just give me credit.


XxXbobXxX
                                    Barry bright

Offline

 

#12 2011-03-25 04:00:52

livedgim
Scratcher
Registered: 2011-01-28
Posts: 2

Re: Pong!

You can use -1 * direction for realistic reflection. Now, you can change to modifier to smaller or bigger value ...  You can also made a pad of different parts (multiple Sprites), each part having different multiplier or angle addition.

Here is a link to an example:

http://scratch.mit.edu/projects/livedgim/1679156

Offline

 

#13 2011-03-25 04:41:15

livedgim
Scratcher
Registered: 2011-01-28
Posts: 2

Re: Pong!

link change>>
http://scratch.mit.edu/projects/livedgim/1679188

Offline

 

#14 2011-03-25 12:28:23

skeletonxf
Scratcher
Registered: 2010-11-02
Posts: 10

Re: Pong!

ian528 wrote:

I need help on making a bounce engine for my pong game. I already used [Point in (direction)+180], but that wasn't realistic. Please help!  sad

bouncing is easy IF you do it right. If the paddle is at the bottom of the screen then when the ball hits the paddle, make it point at 0 or up and then TURN the balls x position - the paddles x position. this is very realistic.
Having [Point in (direction)+180 then turn x position - x position of paddle] is actualy the most realistic bouncing you can make with scratch, but it is glitchy

Offline

 

#15 2011-05-20 03:21:56

Darking1999
New Scratcher
Registered: 2011-05-20
Posts: 1

Re: Pong!

<point in direction( <turn cw(  )degrees><move(  )steps>

Offline

 

#16 2011-06-17 16:06:52

Baseball132
Scratcher
Registered: 2011-06-10
Posts: 1

Re: Pong!

You can try:
[Point in direction (0 - Ball Direction)] or [Point in direction (180 - Ball Direction)] with the Ball Direction being a variable that equals the direction of the ball. If the paddle is on the side of the screen use the first one and if its on the top/bottom use the second one. Hope this helps.  smile

Offline

 

#17 2011-08-09 13:09:43

knightgamer27
New Scratcher
Registered: 2011-08-06
Posts: 2

Re: Pong!

I tried making a pong game without referencing the script of other pong games. It seemed to work, so I uploaded it. Then I learned that it doesn't work correctly. Could someone take a look at it and identify the problem?

Offline

 

#18 2011-09-01 21:26:17

Wes64
Scratcher
Registered: 2011-08-19
Posts: 1000+

Re: Pong!

If anybody needs help I just made Pong, its on my userpage.


Experienced 2.0 Tester: Ask me questions!
Using Firefox 13.0, Flash plugin version 11.4.402.287, and Windows XP Professional.

Offline

 

Board footer