I meant to buy a book on DirectX but I’m glad I got Game Programming All in One (2nd Edition) instead which focused on Allegro. Slowly and patiently trying out all the functions written in the book and keeping note of the ones that I thought were important, it was the book that introduced me to game programming fundamentals. From simple 2D vector graphics to loading bitmaps and drawing animated sprites, I was armed with the tools to make my first top-down car physics simulator. I learned the API by working on Velocita side by side, everything that was usable would be copied from the book and pasted into the project. The end goal was a free roaming car physics simulator in an open world and I had myself convinced that I can’t go wrong with it. It was my first and last lesson on Feature Creep, something I’ll never forget. So I took a small simple bitmap of a car and a large 5000x5000 bitmap showing the top down view of a city baked in MSPaint. The map consisted of a few extra squares and rectangles for buildings, bitmaps that doubled up for the collision model as well.
I included a particle system for the dust, smoke and skidmarks, had Gourad shaded sprites for doing a day/night cycle and translucent images for car and street lights. Tinting all the sprites in real time in Allegro wasn’t one of the brightest ideas I had. As the game slowed down to an unbearable framerate, I tried a few tricks to speed things up a bit, and soon I discovered scrolling. If only I had read a few more pages of the book, I would’ve saved a few days work, but figuring it out myself was a great experience. Cropping the visible part of the world map around the position of the camera and blitting(copy) to screen was an amazing find in my opinion.
The game entered it’s longest stage of development when I started working on the physics of the car. I had no clue as to how car physics worked but I didn’t let that stop me, soon I saw myself trying out random mathematical functions that related the throttle and steering to the speed and angle of the car respectively. Failing miserably, I searched on Google for a simple article that explains 2D car physics for games. After looking for days and rejecting a few dozen complicated articles, I found that one article that I still have saved on my computer to this day - “Car Physics for Games by Macro Monster” or the “Monstrous Car Physics Tutorial”. Even though the article was simple, I had a hard time understanding it. My brother did most of the work actually and later helped me understand how it all really worked. This article is very dear to me, I spent days staring at it, brings back good old memories of being in class and having the printed pages hidden inside the history textbook!
The racing game came to life when the car started to react in a more realistic way, with the sound of a skid playing in the background with it’s volume and pitch attached to the speed and angle of the car respectively. You could now go to specific buildings to select custom colors and spoilers for your flat 2D car and change the weight or cornering stiffness to adjust it’s performance. Obviously influenced by Need for Speed, all these features slowly found their way into the game which came as no surprise. I soon found myself trying to incorporate a 2D side scrolling shooter in one of the buildings, with frame by frame animations exported from flash, and muzzle flashes from Max Payne 2, by taking snapshots from the game by pausing it in the middle of an action sequence, a not so minor distraction that I’m not particularly proud of.
I had no track of time whatsoever. There was nothing to worry about and no deadline to take care of, it was pure fun, creating whatever came to mind. I wouldn’t call it all a waste of time, I spent days trying to have the cop car figure out the position of the racer by shooting rays into the world not realizing that the position of the racer is already sitting in a variable which is accessible to me. I did a lot of stupid things, like, planting a dummy pixel on the tip of the gun so that the program can iterate through the world map to find the colored pixel and spawn a bullet at the right location. The good part is that a lesson was learned even though countless days were spent doing foolish things, I ended up with lots of experience of doing all the stuff the wrong way.