Forums > Jitter

making the ball bounce back

February 18, 2010 | 3:09 pm

Hi everyone,
I’m working on a patch in jitter using the jit.lcd object creating a ping pong game.
I need helping making the ball bounce back when it hits one of the rectangular paddles on either side.
Any ideas?

I’m desperate for help!


February 18, 2010 | 3:36 pm

if the current position is out of bounds on the x or y axis, reverse the current velocity on that axis.
here is an example using gl.gridshape or one way of hundreds to do this.

doing collision detection on the paddles will just require more bounds checking.
might be a good idea to look at javascript for something like this.

in the future, please post clear and simple example patches of your attempts at solving your problems, and you will more frequently get answers.

– Pasted Max Patch, click to expand. –

February 18, 2010 | 4:00 pm

Thank you so much for your reply "robtherich".
Unfortunately, I’m quite new to both this online community and the program.
Plus, I have NO idea how to post up an example of my project.
You mind telling me how you created this gibberish code I copy onto my Max clipboard?
I’ll be happy to show you what I’m talking about:)

Again, thank you so much for you help. I’m about to take a look now at your example

Cheers,
Ayah


February 18, 2010 | 4:09 pm

Unfortunately, I need to stay away from the openGL objects group.
I must use the jit.lcd.
I’m pretty limited.


February 24, 2010 | 3:05 pm

Hi,

Great patch! I’m trying to slowdown the velocity using the object (line), but the object gets too confused… need some help :)

Thanks

Luis Marques


February 24, 2010 | 6:08 pm

you can just multiply the velocity by an amount less than 1, to slow down over time.
here i do it every time the ball hits the wall:

– Pasted Max Patch, click to expand. –

February 24, 2010 | 6:19 pm

robtherich:
do you think I can apply the same idea of getting the ball to bound all over the place to jit.lcd graphics too?
the last patch you posted is pretty cool-if only i get my ball to move the same way in jit.lcd. here’s my patch:

– Pasted Max Patch, click to expand. –

Viewing 7 posts - 1 through 7 (of 7 total)