Slopes - Updated 10.22.13

remixed by amcerbu
See inside
Notes and Credits (added by amcerbu)

Curated 2/20/12 by @CylonToast

Thank you!

This is a demonstration of (mostly) accurate roller-coaster-like slope physics.

If you love it, there's a button for that ;)

The current version (10.25.13) features sliding, bouncing, ramp-jumping, custom terrain generation, custom ball size and bounciness (restitution), and arrow key control.

Size represents the diameter of the ball. Restitution represents the amount of energy that the ball retains with each bounce.

Turbo mode suggested until it tells you to turn it off.

Stop the program, hold space, and click/hold the flag if you want to enter your own parameters for the slope.

Try these:
a = 1.5
b = 1.5
c = 1.5
d = 1.5
X-Skew = 0.5
Y-Skew = 100

Or you can let yourself be surprised!

Press the spacebar during the simulation to view the current parameters.


Check out applejack's cool remix with a throwable ball!

This project was inspired in part by eRKSToCK and VirtualClown, although I improved on the accuracy of the physics. In this model, the ball will fly when it goes over a "ramp."


How it Works:

Terrain generation graphs a section of the function f(x) = sin(ax * cos(bx)) * cos(cx * sin(dx)), which is scaled and given randomly generated or user-provided parameters.

The physics scripts use the principle of vector projection (look it up on Wikipedia). This allows accurate slope rolling and pendulum-like oscillation. Vector projection is also used in by "Ball Physics" and "Elastic Collision" projects:


Known Bugs:

The ball intersects the slope on steep inclines.

The ball sticks to shallow ramps when it should fly off.

Variables in Flash are stacked on top of one another.

Random parameters in Java do not generate decimal places.



1.17.12: Added bouncing and improved jumping (no longer based on color detection).

1.18.12: Improved bouncing to prevent "jumps." Added an upper boundary for the ball.

1.21.12: Improved jittery-ness, added a new land generation system, added hide/show terrain parameters.

1.27.12: Experimented with fixing the slope intersecting problem. The program uses a brute-force script (suggestion by applejack) that finds the point tangent to the slope at each x-value. Also replaced edge bouncing based on popular demand.

1.28.12- Removed the slope-intersecting "fix." It was too buggy. Switched to surfboard costume.

1.30.12- Reverted to ball costume. Added user-customizable properties "size" and "restitution".

3.14.12- Added drawable slopes. Happy Pi Day!

10.21.13- Finally fixed the intro; now slightly less insufferable.

Shared: 16 Jan 2012 Modified: 25 Oct 2013
Favorite this project 115
Love this project 190
Total views 4121
View the remix tree  12
More projects by amcerbu