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!
Offline
I tried [Point in direction (180)- Direction*2)] , but that didn't work very well. Can anyone help?
Offline
ian528 wrote:
I tried [Point in direction (180)- Direction*2)] , but that didn't work very well. Can anyone help?
![]()
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]
Offline
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.
Offline
Offline
try [blocks]
<point in direction( (( <direction> <-> 90 ))
[/blocks]
instead
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
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
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
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
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!
![]()
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
<point in direction( <turn cw( )degrees><move( )steps>
Offline
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.
Offline
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