The Red Bull Diary   Recent Posts
RSSRSS Friday Free Games
"Your 'reality', sir, is lies and balderdash and I'm delighted to say that I have no grasp of it whatsoever."
— Karl Friedrich Hieronymus, Freiherr von Münchhausen

The Diary of a Space Avenger

Two weeks ago, I decided to take a stab at Flash development. I had tried Flash very early in my career (circa 1998) and couldn't get the hang of it, and so I gave up. But my reasoning was this: I'm a professional programmer. I love games. I've seen hundreds of these dopey Flash games all over the web. I know a lot more than I did back then. How hard can it be?

As it turns out, Flash has come a long, long way as a platform and I have come a long, long way as a developer. It wasn't long before it became fun. Lots of fun.

I downloaded the trial version of Flash from Adobe, and started familiarizing myself with the environment. The Flash scripting language, ActionScript, is a direct descendant of JavaScript, and I have used JavaScript for web development since 1998, so picking up the basics was a snap.

I spent my first Saturday banging my head against the wall trying to figure out how to capture keypresses. The event paradigm is a little weird, and you're doing this stuff in real time, unlike a web page scenario where you're just responding passively to user events. I found this tutorial at "Steve's Tutes" to be particularly helpful at the very beginning; it showed the basics of hooking into the onEnterFrame to do your main loop and gave me some clues as to how you can leverage the concepts behind object-oriented programming (something I'm very familiar with) in Flash. Later, I went through a bunch of the material on Kirupa.com for some more advanced techniques. Slowly, I got the hang of how to lay out animations and use scripts to drive the interaction. I decided to start where I suppose every aspiring game developer starts: with a Space Invaders/Galaxian clone.

First, I needed some graphics. I'm not much of an artist, but I can draw passably, so I decided to take a stab at drawing a few space ships. Flash has a full set of vector art tools, but they took a bit of getting used to. For example, you have to double-click to select a shape and its outline; otherwise you drag them independently. Also, you have to be careful to separate everything into layers (anyone who's used Photoshop knows this one). Otherwise, your shapes erase one another, even though they're independently draggable. Eventually, I was able to put together a good-guy (white) ship and a bad-guy (red) ship. A few lines for bullets and presto! The beginnings of a Space Invaders clone. I ganked an animated GIF for the explosions. Importing that into Flash was simple enough. When a bullet hits a ship, remove the ship, add the explosion, and add to the score. Simple.

The next tricky part was sound. I scoured the web for free WAVs and eventually found most of what I needed in the "Science Fiction" section of the "Absolute Sound Effects Archive". Then I downloaded a freeware version of EXPStudio Audio Editor to do some manipulation. Flash was free, the sounds were free, the graphics were free, and even the sound editor was free. As a developer, I think free software is a bad idea, but as a consumer, how can I complain?

Once I got the basic mechanics working, I decided to add wrinkles. I added in capsules that you can pick up to upgrade your ship. First, I did the easiest ones: extra lives, speed boost, rapid fire. Then, I decided to implement "Teleportation", allowing you to move off one edge of the screen and appear on the other. That wasn't too hard. But then I decided to get fancy: multiple shots. Sounds simple enough at first. Two bullets instead of one. Not too bad. The only gotcha there was that since they were firing at the same time and my bullet object triggered the laser sound, dual-firing was twice as loud. That was distracting, but fairly simple to fix.

Then I went to three shots. It was easy, but it wasn't much more useful than two. That's when I got the bright idea to make the shots spread out. Suddenly, everything wasn't traveling in straight lines. I scratched my head and thought back to eleventh grade: trigonometry. Sines, cosines, radians, all that. After going through Kirupa's and Cody Lindley's Flash trig tutorials, I was able to figure it out over the better part of this past Sunday.

And so now in two weekends, I have produced a game that is actually playable, starting from zero: no experience, no materials, just a desire to make a game and an internet connection. I present the beta version of Space Avenger, my first Flash game.

Labels: ,

Comments on The Diary of a Space Avenger
  Comment from Blogger gnome at Wednesday, August 30, 2006 1:41:00 PM
It is actually fun .. really! Just a bit easy, but for a first try most impressive...

And the blogpost is quite an interesting tutorial.

Great! (thanks too)
  Comment from Blogger Red Bull at Wednesday, August 30, 2006 2:43:00 PM
Hey thanks, Gnome. I agree with your assessment that it's a bit too easy, mainly because of the admittedly lame AI I gave the enemies. That's actually one of the things I am working on for the next version.

I'd like to make this game more fun and worth playing more than just once or twice. Anybody out there have any suggestions on how to make a 2D shooter not just another 2D shooter?
  Comment from Blogger gnome at Thursday, August 31, 2006 3:54:00 PM
Not sure if this could help:

http://ludology.org/
  Comment from Anonymous Anonymous at Friday, September 01, 2006 4:11:00 AM
Well, I can not tell you how to make your game better, but I do like the fact that its easy because it boosts my self-esteem and makes it fun because i can get past level 1 for a change (hooray for me...I even got to level 6). But I do like the pretty pills that you get every once in awhile! :o) Good job! Keep up the great work!

Pandora: My Favorite New Songs
LibraryThing: What I'm Currently Reading
Archive Links
Friends of the Red Bull


Sinfest by Tatsuya Ishida

Order of the Stick by Rich Burlew
The Red Bull Diary Is
The Red Bull Diary is the personal pulpit and intellectual dumping-ground for its author, an amateur game designer, professional programmer, political centrist and incurable skeptic. The Red Bull Diary is gaming, game design, politics, development, geek culture, and other such nonsense.