A happy post-mortem

Posted by
August 30th, 2009 9:00 pm

So I was just beginning to have fun. Here’s a vector type of miner race. But before anything I’ll represent you my accomplishments in game development.

-In highschool (about 7 years from now) I programmed a snake game, it included a rabbit with basic run-away algorithm aside from apples.
-One or two months ago I made a shoot’em up type of thing with pygame which you are controlling a plane and there are two monsters in screen and background is scrolling.
-And now I made this.

So I hope you won’t blame me now :) Strength lies in knowing your weaknesses, they say. I knew I couldn’t try anything more complicated. At least I learned some basic things.

So what I present you is a miner racing game (where one racer rides the mine tracks and the other, well, the ceiling) with real fake 2d physics and polynomial interpolation as a track editor. Cars act like roller coaster, they can’t leave the rails. Did I mentioned no sprites?

So first, what I was able to pull;

– If I had 2d physics, I needed 2d collision detection too (even though pygame can collide some stuff). So I made a fake 2d physics engine. It just calculates the impact of gravitational force and then everything is 1d. Still looks 2d.

And what doesn’t work as expected but still better than nothing

– I wanted to let the user enter an array of 2d checkpoints and then create a track from it by polynomial interpolation. Bad thing is I used Lagrange polynomials. I wanted to use them since they didn’t need any slope information. But midway I wanted to have horizontal start and finish lines. I should have gone with something smoother but I don’t really remember much of interpolation and I didn’t had time to read again.

– Appearently zooming in and out of a surface is expensive especially if the surface is big enough to hold your whole track. Something can be done if drawn polynomial tracks are optimised in some way, like rendering on-the-fly with level of detail. Still camera can track the arithmetic mean of 2 cars.

Things I would have added if I had some more time

– Fake collision detection in 1d. I was planning to have obstacles on road, throwing molotov cocktails at each other, rocks falling down(can’t think of a cavern game without this). And even changing tracks (like jumping up to the track above and hit the other car on the back)

– Calculating stuff so that I could tell if the tracks are colliding or seperated too much. Setting minimum margin so that the guys’ head don’t collide. Compare lengths of tracks. Putting vector rail woods every 10 unit and vector lights hanging down from upper track every 100 units. Simple calculus stuff like that.

– The racers (flowers on the pots) would have physics too. Like ragdolls, their heads would go back as you accelerate and hit their head to the front of the car if you lose speed suddenly.

– Everything’s ready to implement car graphics but I’m not sure if rotating surfaces work well in pygame. The tracks can have sprites too. (but someone has to draw them first, of course)

So here are some screens and a link to code if you want to try it. You’ll need numpy (scipy is not needed I guess) and pygame and a python interpreter of course.




Now that I used my extensive knowledge on high-school physics, basic calculus (taking derivative of polynomials really) and the numerical analysis course I took 2 years ago which I forgot everything except Lagrange polynomials, I can finally move onto real 2d stuff with linear algebra.

Of course I’ll fall asleep/faint on my bed first.

Leave a Reply

You must be logged in to post a comment.

[cache: storing page]