Reflecting on Drunk Driver
For my first project in Scratch I chose to emulate some elements from Atari 2600′s Night Driver. The first step to kick off this task was to watch gameplay footage and evaluate its mechanics. How did the game start/end? How did the car move? What peripherals were used to steer the car? What statistics were being recorded (score, speed, etc.)? What visual feedback did the player get in certain scenarios (crashing cars, exceeding road boundaries)? I eyeballed how difficult it would be to recreate certain mechanics and settled on three main aspects I wanted to rebuild:
- Incoming traffic
- Generating the road in perspective
- Translating the steering experience to a PC with its available peripherals
What seemed like a difficult task at first proved to be even more challenging as the project went on: Generating the road in perspective. The reason for this was because the visual assets, in this case merely a collection of six red road markers on the left and right side of the car, had to be repeatedly displayed in a way that a) felt absolutely synchronized to the other side b) effectively simulated the speed of the car c) became larger at an exponential speed as they moved closer to the car in order to create the illusion of perspective. And in addition to that, I wanted to create randomly generated curves. Before even touching any code I sat down and drew out the relationships between the different triggers and variables with pen and paper. I decided on a cosine function to simulate the curved road and an exponential function for increasing the size of the road markers Feeling confident I had mapped out functioning collections of interrelated code blocks I started implementing them one by one, always running tests to make sure they executed flawlessly. One thing I have noticed in Scratch is that some control blocks either conflict with each other or work according to a certain hierarchy – in what order often felt like it was subject to chance. What struck me later was the question of how to implement random curves in the road. Using cosine to simulate the road significantly increased the fluidity in its animation, however left me wondering how I could possibly create transitions between straight and curved roads. After experimenting for three hours I finally decided to cut that feature out completely and move on (while a thousand voices continued crying out inside me). There would have been no easy way to do it without changing the core code blocks that simulated the road. Having spent hours on fine tuning the variables for the road markers implementing incoming traffic was an easy task. Most of the code snippets from the roadblocks could be reused for the cars with little tweaks to the variable’s values here and there and added collision detection.

I won’t go into anymore detail on the car and scores as the code is pretty much self explanatory: Plus/Minus operations on variables, display variables, deduct/add points on collisions, etc.
A Short Game Summary
After our short insight into the scripting approach let’s take a look at the gameplay for Drunk Driver. The first thing you might ask yourself is “why the name Drunk Driver? Isn’t that a little inappropriate?”. To be fairly honest I haven’t spent too much time and energy on my search for a meaningful name. The only thought I put into finding a suitable name was “who would drive at night into oncoming traffic?”, and there you have it. Another argument might be that you cannot win this game. It simply ends when you run out of lives. If I really tried to convince you of its name I would in all likeliness argue there is an underlying metaphor to it.
But let us not get into semantics here. As I have mentioned before Drunk Driver does not end by reaching a goal or driving for a certain time. You run out of lives and have your final score at the end. The objective of the game is to steer your car by moving your cursor and dodge oncoming traffic. For every half second the player survives points are added to the total

score. It is possible to collect health as well however the spawn time is significantly delayed. One thing I had overlooked when writing the code for the cars is that they should not spawn at the same time. This is ultimately the reason why you cannot win this game. And that is all there is to it. If you would like to try out the game for yourself or create your own version from it feel free to head over to the official Scratch website. Constructive feedback is always welcome!