making the ball bounce back

Feb 18, 2010 at 3:09pm

making the ball bounce back

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!

#48579
Feb 18, 2010 at 3:36pm

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. –
#174687
Feb 18, 2010 at 4:00pm

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

#174688
Feb 18, 2010 at 4:09pm

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

#174689
Feb 24, 2010 at 3:05pm

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

#174690
Feb 24, 2010 at 6:08pm

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. –
#174691
Feb 24, 2010 at 6:19pm

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. –
#174692

You must be logged in to reply to this topic.