Elasto mania :)

Started by
6 comments, last by Hedos 17 years, 10 months ago
Many of you must know about this great game. Ahh, many hours well spent at high school on that gem. [smile] (For those who don't, have a look: www.elastomania.com) I'm making a game myself, not very much like elasto mania, but I'm very interested into the kind of physic (mainly the elasticity, friction, polygons based world and multiple parts objects) involved into Elasto Mania. I'm wondering if you guys could point me out into directions to learn more about that kind of physics. Articles, tutorials and web sites are welcome! I've got some background in physics (done mecanics course at college) and have already developped a basic physics engine.. but it only handles individual particles (I want to also handle large objects with multiple collision points) and probably isn't as efficient as it could be. There's only basic "bouncing" response to collision, no realistic elasiticity or friction. Of course, this is all 2d, but if you have 3d material, I'm sure I'll find it useful too. Any input welcome. Thanks a lot! By the way, my game will be open source, hopefully if I end up with something interesting it'll be shared. [smile]
Advertisement
the physics behind elastomania are as simple as can be.

collisions are only between spheres (wheels, head) and static geometry.

furthermore, there collision response is the most simple form: the wheels are simply projected out of intersecting geometry.

then there are are a few basic mass-spring-damper interactions between the wheels and the COM of the bike, and there you go.
Elasto Mania, ah the memories. Totally awesome game with still unsurpassed gameplay in its genre (AFAIK).

Several years ago when I was a little kid I mailed Balazs Rozsa (the creator of the game) personally and asked how he did collision detection, and I also got an answer from him. It was a big moment in my life [smile]. I didn't understand a thing of the answer at the time I got the reply though since I was like 5 years from a linear algebra course.

Anyway, one of the corner stones for this type of game is to be able to calculate the distance of a point (center of wheel) from a polygon edge (line). This distance is

dist = N · (C1 - V1)

where

N = normalized normal of line
· = dot product
C1 = Center of a wheel
V1 = Point on the line (typically one of the vertices)

If that distance is less than the radius of a wheel => collision.

The perpendicular distance to a line is not enough to decide if the wheel is actual on the polygon edge or "outside" of it. You will also need to test for the tangential distance from end points to the wheel. If that tangetal distance is bigger then the edge length, then movement of the wheel should roll "around" the vertex instead.

[Edited by - Enselic on June 12, 2006 2:09:26 AM]
[s]--------------------------------------------------------[/s]chromecode.com - software with source code
Similar, but better IMO, is Trials from DNA. Also one of the best Java games I've seen.
Check it:
Trials
(I'm not sure it's the right link, make sure to get the download version).
Thanks a lot for the help guys. Unfortunatly though, those are pretty much the parts I already figured out. [smile]
Actually, when I'm talking about particles in my physics engine, I really should say spheres. I've got pretty much what you are talking about, Enselic, setup, as well as a "bouncing" response to the collision which changes the velocity given the angle of collision as well as reduces the general velocity considering a loss of energy during the collision.

Quote:Original post by Eelco
then there are are a few basic mass-spring-damper interactions between the wheels and the COM of the bike, and there you go.


This might be among the things I want to learn. I'll check out this mass-spring-damper stuff.

But to be more precise, the stuff I'm most interested about include:

  • How does the wheel spinning on surface make the bike accelerate? Simple intersection detection doesn't seem enough to do it.
  • How does the brake / friction system works?
  • How is the rotation of the bike handled?
Quote:Original post by Hedos
  • How does the brake / friction system works?

Based on the behavior of braking, I looks like the game simply simulates braking by creating a temporary stiff spring between the polygon-wheel intersection point and the wheel itself, when the user presses the brake key. Whenever contact between the polygon and the wheel is lost (or the player releases the brake key), the spring is simply removed (otherwise you could use the braking to hang from the roof). So, braking is equal to creating a stiff spring between the wheel and the contact surface (at least that's what it looks like).
[s]--------------------------------------------------------[/s]chromecode.com - software with source code
As several have pointed out, elastomania physics are very simple, but it doesn't make it less fun. I'm going to agree with Enselic that the braking is probably just a spring (+ maybe a damper) attached between the wheel and the wheel's intersection point.
Regarding how rotating the wheel makes the bike move; as far as I can tell, there's infinite friction between the wheel and the ground (notice how you never slips), so the torque applied to the wheel can very easily be converted to a force acting on the center of mass.

Quote:
How is the rotation of the bike handled?


I assume you have read: http://www.d6.com/users/checker/dynamics.htm
There's a lot of good information there.

By the way, if you want you can check out my crappy elastomania clone, xmoto (http://sourceforge.net/projects/xmoto) (source code available, ofcourse). Beware that I use ODE (http://ode.org) for physics, so it's probably not that interesting for you. I assume the game you're making is for educational purpose, so you want to learn a lot about physics - if not, I can strongly recommend you to use an existing physics library instead (it's so much simpler).

Good luck!
-- Rasmus Neckelmann
Quote:Original post by kadaf
As several have pointed out, elastomania physics are very simple, but it doesn't make it less fun. I'm going to agree with Enselic that the braking is probably just a spring (+ maybe a damper) attached between the wheel and the wheel's intersection point.
Regarding how rotating the wheel makes the bike move; as far as I can tell, there's infinite friction between the wheel and the ground (notice how you never slips), so the torque applied to the wheel can very easily be converted to a force acting on the center of mass.

Quote:
How is the rotation of the bike handled?


I assume you have read: http://www.d6.com/users/checker/dynamics.htm
There's a lot of good information there.

By the way, if you want you can check out my crappy elastomania clone, xmoto (http://sourceforge.net/projects/xmoto) (source code available, ofcourse). Beware that I use ODE (http://ode.org) for physics, so it's probably not that interesting for you. I assume the game you're making is for educational purpose, so you want to learn a lot about physics - if not, I can strongly recommend you to use an existing physics library instead (it's so much simpler).

Good luck!


So you are the author of XMoto! That's great, I had tried it out just yesterday and was looking through the physics source files [smile]
But what are you talking about? It really is a pretty neat game!

I haven't read the page you gave me though, looks like a very good source of information. Thanks for the other tips though, this'll certainly all be helpful.

edit: Oh wait, actually I did *try* to read that 2 or 3 years ago. I had not done any serious math or physics classes though, I think it'll be much easier to grasp now. [smile]

This topic is closed to new replies.

Advertisement