I am a huge novice and this isn't really a programming question, but here I go, say I want to make a game that involves rolling up a ramp like this one:

to move upwards, similar to how it would work in an old Sonic the Hedgehog game or something, how would I go about doing that, where could I find a good recourse to learn this?

  • \$\begingroup\$ You have to define the curve mathematically, to calculate how to translate the distance on a curve of the ramp to change of x,y coordinates. The distance will be calculated from velocity, the velocity from previous velocity and two accelerations, being player's input (keys pressed) and gravity. \$\endgroup\$ – Markus von Broady Nov 5 '12 at 7:36

first off not to descurage you or anything, but collison detection and response is quite math intensive, but luckily there are some good resourses and frameworks that can help out with this. if you are just looking for a quick fix a toolkit or library is your best bet, otherwise if you want to write it from scratch it is quite complex, but there are some good resources out there.

the Colision detection toolkit is a good one: http://code.google.com/p/collisiondetectionkit/

anther good framework is box2D, but it is a bit more involved, because it requires everything to be set up in a very specific way, but the advantage is, there is a lot of good documentation and less math involved. : "http://box2dflash.sourceforge.net/" (I can only post two links because I'm somewhat new to the site, so I had to quote the URL... sorry)

if you would like to learn about the way collision detection works here is a pretty good tutorial on the subject: http://www.metanetsoftware.com/technique/tutorialA.html

the basic idea in making a ramp like this work in a game, is you need to figure out if your two objects are intersecting... if so you need to determine the amount they are intersecting and find a the vector orthogonal(aka perpendicular) to the surface of the ramp, to push your player or object out of, so it does not intersect... this process is checked every frame or so to make sure the object does not go inside the other object.

  • \$\begingroup\$ It does not have to be so complex. Since this is a Flash game and the level of graphics was not mentioned, its physics are not going to be flight simulator-grade, so no advanced collision detection algorithm might be required. Plenty of retro games do very neat animations without using a world-realistic physics engine. \$\endgroup\$ – sleblanc Jan 8 '16 at 7:44
  • \$\begingroup\$ And since we are looking at collision with fixed geometry (the ramp) and we are not doing bouncing collisions, there is no need to calculate vectors at all, just checking if the player is still inside the geometry is enough. \$\endgroup\$ – sleblanc Jan 8 '16 at 8:01

Here is a good resource for sonic-like tile collisions/interactions http://info.sonicretro.org/SPG:Solid_Tiles


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.