ScratchData LogoScratchData
Back to DarthPickley's profile

Slopes - now with normal contacts

DADarthPickley•Created February 23, 2012
Slopes - now with normal contacts
32
17
1256 views
View on Scratch

Description

this remix of amcerbu's great 1s1s physics project http://scratch.mit.edu/projects/amcerbu/2300371 is created so that the ball always is tangent to the surface when it is touching it. // PREVIOUS NOTES: This is a demonstration of (mostly) accurate roller-coaster-like slope physics. The current version (1/30/12) features sliding, bouncing, ramp-jumping, custom terrain generation, custom ball size and bounciness (restitution), and arrow key control. 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! http://scratch.mit.edu/projects/applejack/2285251 This project was inspired in part by eRKSToCK http://scratch.mit.edu/projects/eRKSToCK/1967388 and VirtualClown http://scratch.mit.edu/projects/VirtualClown/2266715, 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: http://scratch.mit.edu/projects/amcerbu/2182230 ===== 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. ===== Changelog: 1/17/12: Added bouncing and improved jumping (no longer based on color detection). 1/18/12: Improved boucing 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.

Project Details

Project ID2350820
CreatedFebruary 23, 2012
Last ModifiedFebruary 23, 2012
SharedFebruary 23, 2012
Visibilityvisible
CommentsAllowed

Remix Information

Parent ProjectView Parent
Root ProjectView Root