Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

What algorithm can I devise for a 2D drag racing game to simulate a race?

The gameplay is 2D and the camera's perspective is from the right side of the cars i.e. cars are seen from their right side in the game. This means that the cars travel in a horizontal line, from left to right till they reach the finish line.

There can be many participants in the race however the algorithm must not be affected by the number of participants in a race. It must work for any and every car given the stats of that car and other race-time driving info e.g. the time of a gear shift, good shift, perfect shift, over rev, etc.

To rephrase my question I am just asking for an algorithm which simulates the car motion/velocity along a straight line according to the stats the car has and according to the way the driver shifts up/down and revs a car.

A car can have many stats. Some I thought of including in the game are:

General stats

  • Top speed (mph)
  • Acceleration (can be represented by just a number)
  • Power (bhp)
  • Weight (lbs)
  • Grip (can be represented by just a number)

Tuning stats

  • Nitrous duration vs. nitrous power (can be represented by just a number)
  • Final drive (can be represented by just a number)
  • Gear ratio for each gear (can be represented by just a number)
  • Tire pressure (can be represented by just a number)

Upgrading a part will usually vary these stats.

Each participant is able to shift up or down but once the race starts acceleration is automatic. Players will be able to choose from automatic and manual acceleration in a later release; for this release the acceleration is automatic. Players must only worry about gear shifting in a race. And outside a race players must worry about changing, upgrading and/or tuning their cars.

Also, the game is multiplayer on a single system and not on a network. That is, the kind of multiplayer we have on consoles with two controllers. No LAN/WiFi networking is involved so we don't have to worry about network lags. Actually, I'm developing the game for Sifteo Cubes.

If a single player plays the game we then have AI opponents. We can have any mix of human and AI players in a race as long as their number is within the capacity supported by that race.

Right now I am trying to build a prototype so this must be all there is to the game. However, the game will keep evolving after the prototype. It will even keep on evolving after its release; in the form of updates and sequels.

Any ideas from the gamedev community to make this game better or add/remove features are gladly welcome.

share|improve this question
2  
What have you tried? You probably won't get many replies because no one wants to spend hours figuring out an algorithm to give to someone else for free lol. If I were you, I'd maybe search google to find source code for similar racing games and deconstruct that :) Good Luck –  Savlon Apr 14 '13 at 2:00
    
I fail to see how all those choices would make the game more interesting. No matter how many parameters or complicated formulas you use it turns into a time it takes to complete the distance, the player will most likely not appreciate more than that. It is a very simple game that will probably appeal more to having a quick round of dumb fun with friends than any lengthy play sessions, the metagame should not be a lot more complex than the game itself. –  eBusiness Apr 14 '13 at 13:00
    
@Savlon I don't need any code. I just need some mathematical equations. Equations similar to these: If my instantaneous acceleration, velocity and engine power is this much where should my car be located in the next tick? I just want some ideas on the algorithms/equations. I don't want a full fledged research. All I am hoping for is that anybody who already knows some equations and/or algorithms about a certain aspect of drag racing can let everyone know about that in an answer. I am hoping to make something out of the answers I receive. To begin, I have posted an answer to my own question. –  Mubeen Iqbal Apr 14 '13 at 13:08
    
@eBusiness You're right in saying that at the end of the day everything boils down to the time required to cover the distance. However, if I make the game so simple how is one going to get the feel of a drag race? The gameplay may be 2D and very simple but the gameplay mechanics should be as realistic as possible. Cars will have different aerodynamics; even wind resistance will matter for each car. Each car's stats and shift must matter to, say, the hundredth part of a second. Gear ratios matter. The goal is to create extremely simple gameplay with extremely realistic dragster mechanics. –  Mubeen Iqbal Apr 14 '13 at 13:20

1 Answer 1

up vote 1 down vote accepted

So far I had been able to find a very nice white paper which includes most (if not all) of the equations I'd need in a drag racing algorithm.

Here's the link:

I guess this question is related more to engineering than to game development. :)

The equations provided in the white paper take in a mix of car stats (power, weight, etc.) and race-time driving info (e.g. the time when a shift is made, instantaneous acceleration, instantaneous velocity, etc.) and return some unknowns.

Also, I've found some equations related to horsepower, torque, RPM, displacement, tire diameter, final drive and gear ratios here:

Furthermore, I found a basic car equation here:

Also, here are some more links to webpages with auto math equations:

For people looking for a handbook on automotive mathematics follow these links:

Using the equations we can determine the position of each car in every tick of the game loop and render accordingly.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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