Cars can be great fun, but the real thing is expensive and susceptible to damage. That’s part of the reason why cars can make a rich mine of content for video games, where many kinds of vehicles can be pushed to their limit in a fantasy setting. Designing a graphic-based car game is similar to designing other games, but with an attentive eye toward recreating the proper physics of cars—drivers have an intuitive sense of how a car stops, starts and turns. How close a digital car hits the mark, depending on the game’s goals, can make or break it.
1. List all the features you would like to see in the game. Determine what the goal of the game will be, whether it’s a comprehensively realistic simulation of actual cars, or whether it will take liberties with realism for the sake of a fun feature, such as accidental vehicle destruction. From there, you can determine whether the setting will be off-road, on a track, or in the streets, which cars will be included, and if you will include features in addition to the actual driving and racing of cars. It helps to know about the physics of cars, or experiment to find values that work for your application. If you plan to someday market your game, remember that there may be intellectual property legal issues connected to the use of trademarked or copyrighted car brand and model names.
2. Translate the car physics into computer code. Real world speed, acceleration and inertia are an innate result of engine performance and traction on the ground, but nothing can be taken for granted in games: everything must be taken into account and coded by the programmer. Represent acceleration by an “if-else” function, in which “if” the player is pressing the acceleration button, the car will gradually gain speed by a defined value per second until it reaches the set maximum speed. “Else” the speed will slow down by a defined value per second plus or minus the value assigned to ground traction, until the car speed goes to zero, a stop. Make turning contingent on the car having a speed value greater than zero—in other words the car must be moving forward to turn, just like a real car.
3. Program a master script that draws a graphical user interface on the screen. That interface should provide useful feedback to the player, such as the speed of the car, by checking that variable’s value and drawing it as a graphic representing the number on the screen.
4. Model the vehicles and racing tracks in your 3D modeling program, starting with basic shapes and subtracting from them until they are sculpted into realistic-looking objects. Group components of objects into more complex objects, such as the wheels and body of a car being grouped to create a whole car. Animate the wheels to move forward and backward in the full possible range of turns.
5. Import the 3D models to the game engine, assigning the relevant code files for each object. Compile all the components into an executable program.