# Objects follow ground with gravity

**URL:** <https://discourse.processing.org/t/objects-follow-ground-with-gravity/7012>\
**Category:** Coding Questions\
**Created:** [December 30, 2018, 2:12am UTC](https://discourse.processing.org/t/objects-follow-ground-with-gravity/7012 "2018-12-30T02:12:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tommyokie](https://avatars.discourse-cdn.com/v4/letter/t/a183cd/32.png) [@tommyokie](https://discourse.processing.org/u/tommyokie)\
**Post date:** [December 30, 2018, 2:12am UTC](https://discourse.processing.org/t/objects-follow-ground-with-gravity/7012/1 "2018-12-30T02:12:21Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![figraham](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/figraham/32/4161_2.png) [@figraham](https://discourse.processing.org/u/figraham)\
**Post date:** [December 30, 2018, 2:34am UTC](https://discourse.processing.org/t/objects-follow-ground-with-gravity/7012/2 "2018-12-30T02:34:21Z")

</div>

Check out Dan Shiffman’s nature of code book. In the [5.9 example](https://natureofcode.com/book/chapter-5-physics-libraries/#59-a-curvy-boundary) he outlines how to do a project like this.

---

<div class="post-metadata">

**Author:** ![BennyHacker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/bennyhacker/32/2969_2.png) [@BennyHacker](https://discourse.processing.org/u/BennyHacker)\
**Post date:** [December 30, 2018, 2:34am UTC](https://discourse.processing.org/t/objects-follow-ground-with-gravity/7012/3 "2018-12-30T02:34:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tommyokie](https://avatars.discourse-cdn.com/v4/letter/t/a183cd/32.png) [@tommyokie](https://discourse.processing.org/u/tommyokie)\
**Post date:** [December 30, 2018, 2:44am UTC](https://discourse.processing.org/t/objects-follow-ground-with-gravity/7012/4 "2018-12-30T02:44:40Z")

</div>

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