Objects follow ground with gravity

hey,
I’m pretty new with processing so this might be pretty simple

How could I have an object, a ball, with location, velocity, and acceleration vectors, be constrained on top of a 2d ground (a slanted line to be simple, although I would like to have an irregular curve for hills) and roll to the lowest point according to a gravity vector.

I have a ball in a sketch with gravity and friction vectors, and I have it bounce on the flat bottom of the screen. I want to know how to program a slated ground (like a hill) that the ball will roll down according to the gravity vector.

thanks

Check out Dan Shiffman’s nature of code book. In the 5.9 example he outlines how to do a project like this.

1 Like

just go to File > Examples > Topics > Motion > Reflection2

cool, thanks, that’s exactly what I was looking for… that example and the book will help

1 Like