The online portfolio of interactive artist Dan Cassar

From the Blog

Aug
30

Design Log: Space Avenger

Posted by admin on August 30th, 2006 at 11:52 am

This is an old post of mine from 2006 where I talked about my experiences coming back to Flash after a long while:

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 I came back. My reasoning being 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 for many years, 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.

Leave a Reply


*

  1.  

    |