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:
- Top speed (mph)
- Acceleration (can be represented by just a number)
- Power (bhp)
- Weight (lbs)
- Grip (can be represented by just a number)
- 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.