Midterm: F1 Racing Simulator

Overview: 

This was definitely the hardest game I have made in Processing. I decided to be a bit ambitious and make a full on racing game. The result I came up with is a 2D style game where a player can try to set the fastest lap around a course as possible.

 

Workflow:

I started off by making a menu where a player could select a team. I decided to take all the F1 2020 teams and car liveries and make them options. To do so I loaded up the team names, logos, and cars into arrays so that a single index could select all of these attributes of a single team. I made a team class to hold all these various data points and within the team selection menu let users use the arrow keys to scroll through the options. I decided to make it look like one was active so drew the menu tinted and then the current teams logo not tinted to make it look highlighted.

Next I moved on to making a car drive around a track. This was the hardest part by far. The car physics weren’t too bad, but since I wanted the car to stay stationary and the track to pan, like in most games, I had to sort out how to move the entire track. At first I wanted to do Yas Marina Circuit. I downloaded an image from Google and began playing around

I could drive the car around Yas Marina but to make the map look not pixelated I had to increase the image size by about 20 times. This meant huge files and a picture tens of thousands of pixels wide. I then tried breaking up the image into a 20×20 tiles so only 4 map tiles had to be drawn at once but even this was too much for processing to handle and caused out of memory errors. With Processing’s limitations I decided to ditch such a large track and make my own.


I created a track with striped curbs and sand on the corners much like real circuits. I also added grass, a finish line and starting grid, and water to keep players from cutting across or going off the map.

I could then adjust the car physics with this new map by detecting what surface the car was on. If the car was on the track or curbs it was fine and it could have full speed or acceleration. If the car was on the grass or sand it would decelerate much faster with a capped max speed. If a player put the car into the water they would lose and the car would crash!

Next up I added some important game mechanics such as a lap timer and a timer to save the best lap time. It was tricky to detect when players crossed the start line. I also had to make sure drivers couldn’t go backwards over the start line to cheat the system and make it look like a faster lap when they had not gone all the way around.

Sound was probably the hardest part. In normal racing games you would take an engine loop sound and adjust the pitch and fade in and out acceleration and deceleration tracks. I had a really hard time with this so decided to stick to a single engine loop to get the engine sound effect. The only way to adjust pitch in processing is through the rate which had some limitations. It sounds a little digitalized but overall not bad.

Finally I wrapped it all up with a main menu, credits, and controls to help the player navigate the game.

Gameplay:

When a user loads the game they will be greeted with the main menu. All menus are navigated with the arrow keys, enter, or backspace. I imagined console like controls so the mouse is never used in this game.

From the main menu, users can access the controls, the credits, or start the game itself

 

With the game started, users can now use the arrow keys to select which team they want (have to go with Ferrari here).

Once they press enter, they will be loaded onto the starting grid on the track. Once they cross the Start/Finish line, the lap timer will reset and begin actively counting their lap.

Users can control the car by pressing the up arrow for gas, the down arrow for brakes, and the left or right arrows to turn left or right. The car will speed up when given throttle, slowly decelerate when not given any gas, and decelerate quickly when braking. The car will also decelerate much quicker on sand or grass and can’t go very quick. Avoid the water or the game ends as you won’t drive very far in the marina! At any time the user can go back to the main menu with backspace.

The goal of the game is to set the quickest lap time possible. My best is 38 seconds, can you beat me?

Here is a short video showing some gameplay (the quality isn’t the greatest as I had a lot of recording software issues)

 

Here are the game files

F1Game

Leave a Reply