My first exposure to programming was some time around the turn of the century with a program called Game Maker, which as the name suggests, was built for making games. Game Maker actually supported a decent amount of graphical programming by dragging-and-dropping icons around the screen to describe the behaviour of different objects in the game, but as soon as I learnt that there was another way to do it that had more features, I wanted to learn that.
The tutorial for the scripting language in Game Maker at the time walked you through programming a little game similar to Space Invaders, where you controlled a space ship at the bottom of the screen and the goal was to shoot the enemy ships approaching from the top of the screen. I followed the instructions closely, typing in all the code it supplied to define the behaviour for moving and shooting, including a cooldown for the gun so that you wouldn’t just fire off a shot every game tick. And then they gave you an exercise, to add a second weapon to the ship that was triggered from a separate key and that had its own cooldown. And I was stumped.
I looked back over all the code they had supplied to me so far. When
you press the Space key, it first checks the value of
can_shoot. If it’s
true, create a
false, then start
a timer for half a second. When the timer goes off, set
can_shoot back to
true again. Well that all
makes sense and it’s great for the first gun, but what’s the
can_shoot for the second gun? They didn’t
tell me the name of the second cooldown. I tried searching through
the documentation for the name of the second cooldown, but couldn’t
find it anywhere.
This really frustrated me, because I was having so much fun up until this point watching a game come to life on the screen in front of me based on what I was typing with my fingers. And now I was stuck because the tutorial missed such an important detail! I kept staring at my screen, hoping for a clue.
And then I had my first great epiphany of programming. I
can_shoot. It’s not special. It’s not some
magical thing built into the language that already knows how to
handle the cooldown for a gun. I made it understand how to
handle the cooldown for a gun. I explicitly wrote out every single
detail of its behaviour. Its starting value, how its value affects
the behaviour of the game, how its value changes based on the actions
that occur in the game, how the timer resets it. I made it do what it
does, and if I wanted to I could make it do something else. And that
was it, I was hooked.
Years later, when I taught intro to programming to first-year university students, I would have the privilege of seeing this same epiphany occur in the minds of hundreds of budding programmers. But we’ll get to that part of my journey later.
Continued in Part 2, Find a Purpose.