Simulating gravity in 2D

Aiden Locke's icon

Beginner of two months or so with Max. I've managed to generate a randomly bouncing ball thanks to a few L Objects. Pressing the button near the top right of the patch randomizes the x & y velocities. I'm using global values as I plan on adding additional effects / elements to the simulation.

My struggle is attempting to simulate gravity on my ball. The goal is that when the G key is held, gravity will constantly apply to the y velocity of the ball (+ 0.8), and when it reaches the bottom the Y velocity is reduced slightly and inverted. I've highlighted the section of the patch responsible for this action, it is not behaving remotely as expected and I'm truly stumped. Any help is much appreciated!!

Max Patch
Copy patch and select New From Clipboard in Max.

Jean-Francois Charles's icon

It's maybe not where you want to go right now, but when you want to learn Jitter, have a look at the page "A Listing of all Jitter OpenGL Examples" in the reference, and go to the "Physics" section.
Also, I would suggest you have a look at the zl object: you might find a native way of doing what you do with the L collection.

Aiden Locke's icon

Thanks for the feedback! Unfortunately, I'm not seeing anything pertaining to gravity in the OpenGL examples. Beyond that, I'm trying to do this with mostly pure max, without higher level jitter / openGL objects (part of the specs of this assignment) :(