Thursday, 20 January 2011

Free Flash game source code! Win Adobe Master Collection!



Update 2: The competition has now closed, but please still help yourself to the source code. My original example compiles with the Flash IDE, but Almog Koren has very kindly taken the time to create a version of the game source code for Flex.

I've decided to give away the full source to a Flash game! Here's why - Mark "ickydime" Grossnickle has organised a game development contest to coincide with Stanford University's annual charity "Hackathon". Anyone can enter (that means you!) and the top prize is a copy of Adobe Creative Suite Master Collection (that's all the Adobe software basically) worth $2500.

The theme of the contest is "benevolence" which basically means being charitable and generally a good person. Mark has asked me to help judge the contest, so I can't enter, but I thought my benevolent act could be giving away the source code to a game, to get you started or help you learn game dev.

Ok, so it's not really a full game, but it is a working game engine with a playable character, enemies, bullets and NPCs. You can see it in action here (arrow keys and spacebar) and download the source code here. It compiles in the Flash IDE, so if you want to use the Flex compiler you'll have to hack it a bit.

I originally put the demo together in 1 day, for a session I gave at dotbrighton a couple of years ago, so it doesn't really represent the way I currently structure my game code, but it should be fairly understandable and easy to extend or to copy and paste bits that you need. The character art is Creative Commons non-commercial, grabbed from here (where you can find more characters to use). The tiles are from Game Poetry and are completely free to use. I can't remember where the explosion animation comes from, so you're probably better off not using that one.

In case you're interested, here's more detail on how the code is structured and how I've moved on from this setup: The game has a base Entity class which extends MovieClip. This is great when you're getting started with making games, but becomes very inflexible. What if you want to extend Bitmap for better performance? What if you want to render the game with Away3D or with blitting? For this reason I would recommend composing a separate view class. The code also uses a deep class hierarchy with too many levels of inheritance, and these days I would recommend a modular, composition based code structure. Anyways, in context of this game, the code structure works fine, so enjoy!

6 comments:

Anonymous said...

Thanks!
I'll Try to learn something from the code
:)

Anonymous said...

Actually, game throws unhandled exceptions while trying to update view (tested pressing more than 2 keyboard buttons at a time)

But still, it's nice =)

David J McClelland said...

Kudos!

mehdadoo said...

So, mr. judge,
Seems no one really judges our games!
take a look at the submitted games please!

Iain said...

@mehdadoo the deadline has only just passed - I'll get on to mr ickydime and see where we're at - he hasn't sent me anything to look at yet

Stef said...

Oh, that's very nice to have included a Flex version, thanks.