Friday, September 16, 2011

How to make the ball roll, slide, fall etc

Consider the following equations of motion/rotation for a rolling sphere:


Formulate a numerical solution for finite differences. Add lots and lots of graphics and you get this:




Thank you for your attention class.


Thursday, June 30, 2011

New version out now

There is a new version available for download:
June version of Rolling Coaster download

Here's a couple of screenshots showing the new design:



Friday, May 27, 2011

The importance of soundeffects in a game

Recently I heard on radio about a student in game-development doing his exam paper on the importance of sound in videogames. Not surpringsingly he had drawn the conclusion that sound effects are very important. For example, when walking in different rooms, the sound of walking should match the sound you would actually hear in that environment.

For Rolling Coaster, I started adding sound rather late. But when I found decent sounds for events in the game, the game was improved a lot. Try looking at the following shot without sound, it won't give you the same feel of presence as it would with the sounds currently used.

video


Now, I'm not saying that I've used perfect soundeffects for everyting here... it's just that the sounds are way better than not having any sound at all! Also, there is a Doppler-effect on the frequency that really makes a huge difference (which is really simple to add, see wikipedia for the theory)

Thursday, May 26, 2011

One line of code

That's what it's all about: one line of code (!).

Rolling Coaster is a game where you control a ball on a racetrack. You can accelerate, break and speed-boost. The physics that govern the movement of the ball is derived from the torque/angular velocity and the forces acting on the ball: gravity and friction. Some of the equations that are needed look like this:


It's then a simple task (*) to derive the equation of motion for a rolling ball that may slide on the surface depending on friction.

After that, a numerical solution is needed, which is simply to replace the differentials with the actual differences during the integrating timestep. Presto! An advanced model of a rolling, sliding ball is created!

In the C# code it looks like this:

   // Calculate friction wanted by ball   float A = dt * (1.0f / I + 1.0f / (r2 * m));
   Vector3 Bvec = -(1.0f / r2 * Vector3.Cross(radius, v0 + dt / m * gravAlong) + w0 + K * dt);
   Vector3 Bvec0 = 1.0f / A * Bvec;

   // Value of friction
   float fricWanted = Bvec0.Length() / rollinProp.radius;

That's not one line... it's, uh, 4 lines. Yes... and just a couple of more lines are needed to make a game out of it, right now 58518 and still counting.

Download Rolling Coaster .- a game of racing here...


You can always download the latest version of Rolling Coaster - a game of racing from IndieDB:

Indie DB