Category Archives: Blog

Should You Sell Your Source Code?

The Not-So-Golden Archbob

A thread erupted on the FlashGameLicense community boards surrounding this post by free-to-play Flash game portal owner Yinan Chen, AKA “Archbob”, who runs FlashGameNinjaClan (which we “featured” in our recent post Why Don’t You Host Your Own Flash Game Portal?):

Mochi Leaderboards and Mochi Coins

Understandably, members of the developer community took exception to a few things Archbob had to say:

I don’t care how much the developers earn. The ones that make good games can easily make several thousand or tens of thousands per game.

and this gem from another unnamed portal owner:

I am sure Flash Game Developers make a lot of money already. [Microtransactions are] kind of greedy.

Hulk … rage … building. Sigh. Don’t get me started.

Oliver Twist

Greedy?? i think Oliver Twist pulls down more in tuppence and gruel in a fortnight than most indie Flash developers see in as many months

In the article, Archbob does voice some valid concerns about the implementation of MochiCoins and competing services from his industry perspective. He also goes on to shock some Flash game devs by detailing his practice of paying developers $100-200 for full source code to a game. This has led to a number of threads and posts on the subject of selling source, not least of all this post from the Vortix Games Blog:

Thinking about selling your source code?

Your Question, Answered

At the end of the day, Archbob is just a bidnessman looking to make a buck and doing it the most efficient way possible. If some devs are willing to part with their code for a pat on the back and some lunch money, it’s on them, not on Archbob.

But now that we’re all here, Flash game devs, let’s talk about this whole source code issue. What’s the deal, anyway? Should i sell my source code?

The short answer to that question is “no.”

The long answer is “no.”

The answer, translated into French, is non which, loosely translated back to English, means “no.”

The answer in the African click language Mbukushu is “nglOCK”, which – you guessed it – means “no”.


N’guthu doesn’t think you should sell your source code either.

So a new question arises: have we, Untold Entertainment, ever sold our source? The answer there is actually “yes”, but to understand why, i have to take you back to a simpler time.

Let’s Do the Time Warp Again

Picture it: the year is 2007. George W. Bush is in the White House. “Fergalicious” by pop chanteuse Fergie (featuring tops the Billboard Hot 100, a popular music chart of the day. And the star of the Flash game development scene is a high-level programming language called ActionScript 2.

Avian Flu

Fergailcious and avian flu, all crammed into one sickening year

“AS2″, as it was known in jive-talking developer circles, was not a full Object-Oriented programming language. You could, with a little facial straining and a lot of undocumented wizardry, shoehorn it more towards an OOP mould, but most of us with a day job and one-week-long game production deadlines couldn’t be arsed. Those days, creating a new game meant coding it largely from scratch, or keeping a folder full of code snippets to copy-paste into a new file. Reusable code was a tale told by futurists and mad-men. Chaos and disorder ruled the day.

When our clients would request our AS2 source code for a week-long game like Eye in the Sky: Spot the Differences, it was hard to kick up a fuss. Many of our clients are kids’ television production companies who convince themselves that they’ll have the time and money to repurpose these games later, but nothing ever comes of it. If a different client were to come to us and ask for a nearly identical spot-the-differences game, i’d probably code it from scratch. The new client’s concept would probably be just subtly different enough to warrant a re-write.


Okay – we want a spot-the-differences game EXACTLY LIKE THAT ONE, except instead of spotting differences, you’re flinging Cinammon Munchy Cheerios, and instead of using the mouse, you’re using a mind control helmet. Plus, there are ninjas.

But then along came a stranger to the scene, a wild-eyed and vivacious newcomer with a mane of saffron-coloured hair and a tight pair of rhinestone-studded spandex pants. “Actionscript 3″ was his name, and the industry would be changed forever.

The difference between AS2 and AS3 is that Actionscript 3 has really lived up to its promise of code reuse. Problems that used to take us days or weeks are reduced to literally a single hour, leaving us to catch up on our knitting in those long, tranquil stretches of Wednesday afternoons. AS3 has also changed the way we negotiate our contracts with clients.

AS3′s Impact on Contract Negotiations

The clients will always ask for source code, and we will always say no, for these very valid reasons:

  1. By selling your source code, you are selling the right to use that code. You can’t (contractually) sell your code to someone and then turn around and re-use it in a new game.
  2. With each new project, we re-use and improve upon libraries that we used in past projects. If we sold the code in those libraries, we couldn’t (contractually) use them in our next project, so our profit margins would shrink because we’d have to [technically] re-write the code.
  3. The time and effort we put into some of our libraries is very valuable to us, and can represent literally years of development. We’re not going to let that fly out the door for the cost of a few weeks’ development.

To use an industrial analogy, selling your source code isn’t like selling a car. It’s not even like selling the plans or the autoCAD blueprints for the car. It’s like selling a machine which, when you push a button, makes a car.

Car Plant

Here, client. Would you like to buy our assembly line for two hundred bucks?

So no, clients cannot have our source code. But this presents us with a problem: what happens when the client’s database guy needs to integrate the game into the high scores system, but he’s only available in November, and we’re finished with the game in October? Or what happens when the game is a component of a much larger website, and the client requires source code to integrate the game? Or what happens when the style bible changes and the client wants to make a character’s hat blue?

These are all real-world examples from our actual experiences. You hard-lined developers might say “if they want the hat blue, they can pay us to make that change.” But our policy has always been to enable the client to make reasonable changes after the fact, without having to pay an expensive Flash developer for simple modifications. That’s why we try to link copy decks in xml files outside the project. The client shouldn’t have to pay us more money because they want the Registered Trademark symbol added to a product name. (And, honestly, we don’t really want to halt production on a new project to make such a small change to an older project anyway).


Staring into the cold, dead eyes of legacy code.

We’re currently building a music game. What if the client finds out down the road that the rights to the songs have changed? Should they have to pay us to put different songs in the games? In my opinion, no. So we’re building the game so that it’s easy to change the playlist externally.

And the hard-line approach does nothing to solve the problem of site integration. Clients simply need source code in that case.

So what is the solution?

Enter the Shared Source Agreement

Since we started developing games in Actionscript 3, we’ve signed a Shared Source Agreement on nearly all of our projects. That’s where we can:

  • Re-use
  • Re-configure
  • Re-sell
  • Re-skin

the source code, and our clients cannot. But we do give our clients the source code, with a license to modify that code within the current skin. That means that if we’re making a game about bears who love the delicious crunchy taste of Goorman’s Cookies, the client can’t turn around use the source code to create a game about a bee who can’t get enough of the satisfying crackle of BingBong’s Peanut Brittle. They can do whatever they want with it, as long as they stick to that bear with those cookies.

peanut brittle

Is brittle? Is problem.

The Honour System

“But if you give the client your code, aren’t they just on the honour system?” you ask. Sure they are. The client could turn around and do a variety of things with the code that weren’t contractually permitted. But as human beings, we rely on the honour system a great deal. The honour system is what keeps you from walking down the sidewalk and stabbing someone in the face. It’s what dissuades you from veering your car over the yellow line on the road and into oncoming traffic. i like the honour system. Let’s stick with it.

If it helps you with your own contracts, or if you’re one of our competitors looking to get an edge on us, here’s the kind of wording we use when we work with a client on a fee-for-service basis:

The source code for this project is licensed to [Client] under a Shared Source agreement. Untold Entertainment Inc. retains the exclusive right to modify, reuse, re-skin and sublicense the source code, and any non-brand-identifying multimedia assets. [Client] may modify the source code solely for the purposes of [project]. Untold Entertainment retains the know-how and materials to this project.

Know-How! (Contrariwise!)

When i first saw a client try to retain “know-how”, i actually had it stricken from the contract. How could someone else own my knowledge of how i did something? Did i have to erase my memory or try to blot knowledge from my mind? (Of course not. Apparently, i’m pretty good at naturally forgetting how to do things.)

i came to understand that retaining “know-how and materials” is strictly legal language pertaining to a research grant (SR&ED) here in Canada. He who writes that language into the contract gets to apply for the grant.

Let Us Retire to the Sitting Room

So this post is meant to help you out if you’re looking to do some fee-for-service work (we geev you the Flash, you geev us the monay) and you need this kind of help with your contract. i hope this post doesn’t serve as bait for an army of hobbyists telling me how great it is to sell your source code. As always, i welcome lively discussion either here or on the boards. And if this post has taught you nothing and you’re still interested in selling your source code to me for a few hundred bucks, please drop me a line. :)

Flash Game Industry: The “Clone” Wars

There’s a wave of excitement in the Flash game dev community, as a small band of respectable developers speak out against the villains in their industry, and slowly begin to turn the tide against negative public opinion surrounding Flash game development.

This week saw the removal of a post on monetizing Flash games by Russian developer Vadim Starygin (AKA Badim), whose tips included using a spritesheet of Mega Man or Legend of Zelda character animations for use in your own game, or producing an unauthorized sequel to some other developer’s game.

i shit you negative.

Stealing is only cute when these guys do it

Stealing is only cute when these guys do it.

Due to pressure from many members of the community, who disagreed with MochiMedia’s stance that they were just airing alternative viewpoints (no – they were tacitly endorsing copyright infringement), Team Mochi decided to axe the article. Badim continues to earn advertising revenue on sites like with his game Elite Forces: Clone Wars and its sequel:

Elite Forces:Clone Wars

The background behind the game is a stolen image of characters from the Star Wars property. The logo Badim uses in the game is the almost completely unmodified Star Wars: Clone Wars logo, which i reproduce here purely for the purposes of review and comparison:

Clone Wars

Copyright George Lucas Enterprises 1977-2087 inclusive all rights reserved void where prohibited please don’t sue Amen.

So while MochiMedia showed good faith by removing the post, we still have a Nonoba problem.

The Nonoba Problem

i know it must be next-to-impossible to police every single game on your distribution system. And while this is hardly a subtle infringement, i emailed Nonoba to let them know what was up. That was a few days ago – no word. i’m not sure a company would even respond if the complainant was not the original IP owner. Should they?

Apparently a buck’s a buck to Nonoba. And if not, i’ll call them out publicly right here: Nonoba, please honour the well-lit corners of the Flash community by following these steps:

  1. Remove Badim’s copyright-infringing games from your service.
  2. Reclaim any and all moneys paid to Badim for those games.
  3. Cut a cheque with your portion and Badim’s portion to LucasArts and mail to:

    LucasArts, a division of Lucasfilm Ltd.
    Attention: Legal Department
    P.O. Box 29908
    San Francisco, CA 94129

    Or call Yoda’s Help Desk. That dude is hilarious when he talks tech.


    Check your video card manufacturer’s site for the latest driver updates you must.

    And while we’re on a roll, what’s up with GamerSafe featuring Badim in their latest newsletter last week? Regarding Badim’s post on MochiLand, the GamerSafe guys said “hey – leave us out of it!” on Twitter while this whole thing went down, claiming that they don’t knowingly support games that have copyright-infringing material in them. i explained that allying their service with devs like Badim invited a negative association that their company could do without. He may not perform a ritual killing on-camera, but nevertheless, you still don’t invite Charles Manson to guest-host the Oprah show.

    Charles Manson to host Oprah

    Everybody gets a caaar! (and a swaaaastika on their foreheads!)

    Why Not Just Let it Slide?

    So what’s the big deal? Devs who steal stuff aren’t hurting anyone. If IP owners like LucasArts cared enough, they would ask for the games to be removed themselves. We don’t need anyone policing our industry.

    Here’s the issue in a nutshell: i make no bones about the fact that i want to make money from my own original games. The game creation tool i know best is Flash. The Flash game dev community is packed with young hobbyist boys who don’t see too much of a problem with yanking assets and code from wherever to create their own games and make a quick buck through ad revenue sharing.

    As a result, the Flash platform is synonymous with low-quality, piratey IP rip-off games, and badly-animated 2D pornography. Many of the people who play the games are the people who create the games. Those people don’t have credit cards. The people who do have credit cards – the people whose money i want to have – are more likely to spend their cash on a more reputable segment of the entertainment spectrum. But Flash is always good for a laugh – as long as it’s free.


    A quick trip to the Newgrounds front page today turns up an unauthorized Pac Man sequel, a fat anime collaboration promising larger breasts, two Legend of Zelda rip-offs, and something called “Dick Neck”. Wait right there – let me run and get my credit card.

    My plan: to encourage the more professionally-minded Flash game devs to make a bigger noise than the hobbyists – to set the tone for the industry that the young among us strive to emulate. i’d like to see some semblance of mentorship in our industry. i’d like to see the more mature developers modelling behaviour that the younger devs aspire to.

    And once we’re all resolved to improving our entertainment offering, we may change the attitudes of the customers we want to attract. When we change those attitudes, our audience expands to include players with both money and taste.

    Money and taste: two things the free-to-play Flash game industry could benefit from.

Flash AS3: The Only Math You’ll Ever Need

i write this post at the risk of being laughed out of the industry by eggheads … but one of our goals is to help Flash game developers produce the very best content possible. So if this post helps you, we’re happy to be of service. So let the eggheads laugh.


Go ahead and laugh, Poindexter. i’m not afraid of you.

It’th a Total Mathacre

Are you like me? Are you terrified of numbers? Does the thought of performing a simple math equation give you dry mouth and sweaty palms? Do fractions give you restless leg syndrome? And have you been afraid to really dive into programming because you’re worried about the amount of math it requires?

If you’ve even dipped so much as a toe in programmatic waters, i hope you’ve discovered that programming is more about logic than it is about math. You can create quite sophisticated games with branching storylines and interactivity without ever touching a floating point number (whatever that is).

i’ll level with you here: math scares the Hell out of me. But somehow, i’ve been building Flash games professionally for nearly ten years, and my arithmophobia hasn’t stopped me. What i’ve noticed in all my years of game development is that there’s one simple piece of math from back in grade school that i’ve used over and over again. I’ve probably used it in every single game i’ve ever written. But i remember a time when i couldn’t wrap my mind around what i was trying to do, because i hadn’t committed those certain math operations to memory.

So i’ll share them with you today, and i’ll share the cases where the math comes in handy.

The bit of math i’m talking about is just simple ratio stuff. A ratio is a relationship between numbers. Let’s jump into a real-world example right away.

Health Bar – Timeline

You have a game character, and he has a health bar. In code, the character’s health is expressed as a percentage: your character is at 70% health, let’s say.

You’ve built a graphic to depict this on the screen to your player. Here’s the absolute easiest way to go about displaying the health properly:

  1. Make sure your health bar MovieClip has exactly 101 frames

    101 Frames

    (image truncated to fit on-screen)

  2. Inside the health bar, create a rectangle. This will be your character’s health indicator.


  3. Press F8 and turn the rectangle into a MovieClip symbol.

    symbolize the bar

    Use that little grid to put the registration point at the left edge of the bar

  4. Select frame 101 and press F6 to add a keyframe there on the bar’s layer.

    keyframe on frame 101

  5. On frame 1, set the width of the bar to 0.1. On frame 101, stretch the bar out to its full width. (note: you may need to turn on the snap tool and move the white registration dot in the middle of the bar to its left edge on both keyframes)
  6. Right-click frame 1 and select “Create Motion Tween’ in CS3 or “Create Classic Tween” in CS4

    create motion tween

  7. When you need to display the character’s health, tell the bar to gotoAndStop(health + 1). So if health is 0, the bar goes to the first frame. If health is 100%, the bar goes to the 101st frame. If health is 50%, the bar goes to the middle. (note: MovieClips don’t have a frame zero, which is why we’ve offset everything by 1 frame)

So that’s the old-school way of doing it. And if you’re starting out, it’s still a very viable way of doing things. Don’t let the eggheads laugh at you because you are using timeline animation.


There was a time, long long ago, when the timeline meant something

But what about cases where you want to do everything with code?

Health Bar – Cheaterpants Mathless Method

What we’re trying to do is to change the width of the health bar using Actionscript 3 code, so that it matches the player’s health value. Here’s the easiest way to do that:

  1. Make sure your graphical health bar, at full health, is 100 pixels wide
  2. When you want to update the player’s health, set the width property of the bar to the health value. At 50%, it’s 50 pixels wide. At 100%, it’s 100 pixels wide.

Sounds great, yeah? We dodged the math bullet for another day.

Dodge a bullet

i’m pretty conviced that, like the Matrix, math is meant to distract us from realizing that we’re all leading sedentary lives getting our essence sucked out of us

Health Bar – Still No Math Required

But wait … what if a 100 pixel-wide health bar won’t fit in your interface? What if it’s too big or two small?

Resist the math at all costs! Just do this:

  1. Scale your health bar. Even if you squish the MovieClip, the width of the bar inside is relative. It’ll still be 100px wide at full health, but it’s inside a clip that’s getting squished or stretched to make it look like it’s shorter or longer than it actually is. This will work out very well if your bar is a vector graphic, because you won’t get any jaggies when you scale it.

Um … Ryan? My health bar isn’t vector.


Let’s just cut to the chase and use some of that ratio math, huh?

Biting the Math Bullet

Alright – we’ve done everything we can to avoid using math to solve this problem. Let’s take a look at the math that we need.

First, let’s gather some information. Let’s identify what we know, and what we don’t know.

What do we know?

  1. We know that our character’s health is 70%
  2. We know that 70% is a number out of 100. If we write it as a fraction, seventy percent is 70/100 (or “70 over 100″, or even “seventy one-hundredths”)
  3. We know how wide our health meter can be (let’s say 360 pixels)

What don’t we know?

  1. We don’t know how wide the bar inside the health meter is supposed to be

So that leaves three knowns, and one unknown. In algebra, our unknown value is often written as x.

Finding x

Ah, x. My old nemesis. How you’ve plagued me with nightmares over the years. But this time, i have nothing to fear, because i’m armed with knowledge, and i’ve been drinking Scotch all afternoon.

A ratio is a relationship between numbers. Do you see the relationship between the number 70 seated inside the number 100, and the width of your health bar seated inside the maximum possible width of the health bar? 70/100 is the same thing as something/360. (remember: 360 is the maximum width our health meter can be.)

So to put that a more mathy way, 70/100 = x/360.

Or, to express it as something you’d see in a grade 5 math textbook:


Freaked out yet?

Oh teh noes! We’re in Math Land now! Everyone hold on to the rope, and don’t stray off the path. We’re gonna get through this thing.

Ninja Moves, Bitches

There’s a bunch of stuff that we can and need to do to this math thing … this statement … in order to figure out what x is. Anything we do to this statement is called an operation. You can think of operations as ninja moves. Let’s learn the punches, kicks, and spine cracks we need to extract the info we need – x.

Let’s see if we can beat the crap out of the other numbers to isolate x. We want x on one side of the statement, and every other number on the other side. Then we’ll wind up with a statement that says “x = some number“. That’s the number we want!

Ninja Move #1: In an equality statement like this, we’re saying that the thing on the left is the same as the thing on the right. So we can swap sides any time we like. Let’s swap sides now.

Equation Swap


Ninja Move #2: Just the same, we can flip the fractions upside down, as long as we do it to both sides at the same time. Let’s do it!!

Equation Flip


Ninja Move #2.5 Ok, that kinda sucks. It’s easier if x stays on top of the fraction. Let’s reverse that last ninja move!

Equation Flip


Ninja Move #3 It looks like we can do anything we want to one side, as long as we do it to the other. x/360 is another way of saying “x divided by 360″. If you take a number and divide it by something, and then you multiply it by the same something, you wind up with your original number. Let’s see that in action with some easy math:

6 / 3 * 3 = 6;

(Six divided by three equals two. Two times three equals six – the same number we started with.)

And again:

2 / 4 * 4 = 2;

(Two times four equals zero-point-five. Zero-point-five times four equals two – the same number we started with.)

So at the moment, our math equation says x/360. If we multiply x by 360, we’ll get x all on its own. It’s like we’ve made that /360 part disappear.

Multiply by 360


BUT REMEMBER: This is an equality statement. If we kick one side in the face, we have to kick the other side equally in the face. We multiplied the left side by 360 to get rid of the divided-by-360 part, so we need to multiply the other side by 360 as well. Here we go:

Multiply by 360


How awesome is that? x is all alone on one side of the equals sign. Now we just do the math on the other side, and we have our answer.

x = 70 /100 * 360
x = 0.7 * 360
x = 252

So there’s our answer! If the character’s health is at 70%, and the maximum width of our health bar is 360 pixels, we need to change the width of the health bar to 252 pixels to make it look right.

This is just one real-world example where ratio math comes in handy. Here are a few more examples where knowing the same ninja moves helps again and again and again:


You have a character on a big scrolling background, and you want to show a dot on a mini-map in the corner of the screen.

The character’s x position within the width of the background is the same as the x position of the dot within the width of the mini-map.

Ratio math helps with your mini-map

(the background extends past the viewable game area)

character.x/background.width == dot.x/miniMap.width; // dot.x is our unknown!

Ninja move! Flip sides!

dot.x/miniMap.width == character.x/background.width;

Ninja move! Isolate the unknown!

dot.x/miniMap.width*miniMap.width == character.x/background.width*miniMap.width; // multiply both sides by miniMap.width to get rid of it on the left side!

Ninja move! Dividing a number by something, and then multiplying by the same something is the same as doing nothing!

dot.x == (character.x / background.width) * miniMap.width;

Solve for x!

dot.x = 57; // (this is after substituting nubmers for character.x, background.width and miniMap.width)

Colour Slider Control Handle!

You have a colour slider bar. The player can crank it up and down to adjust a colour swatch from 0-255. You want to know the colour value out of 255 based on where the slider was cranked.

Ratio math helps with your color slider

The highest red value is 255

sliderTab.y/maximumSliderRange == x/255;
x/255 == sliderTab.y/maximumSliderRange; // swap sides
x = (sliderTab.y/maximumSliderRange)*255; // get rid of the fraction on the left side
x = 42; // (again, we dropped in the number values for sliderTab.y and maximumSliderRange to arrive at this number)

Flash Video Progress Bar!

You have a progress bar on your flv video player. You want to know how far along to position the progress marker based on how much of the video has played.

Ratio math helps with your video player

Play us out, Keyboard Cat

marker.x = movie.position / movie.duration * totalWidthOfTheProgressTrack;

Shooter Game Accuracy Rating!

You have a shooter game. The player scored 37 hits out of a possible 553 targets. You want to express that as a hit accuracy percentage when the level ends.

accuracy = 37 / 553 * 100;

See, Mr. Sprague? That’s How It’s Done

i was never really terrible at math – i just didn’t enjoy it. i didn’t like the fact that there was only one right answer, and that in early grades, we were timed. In the first grade, we had to compete “Minute Math” sheets – one minute to burn through a page full of sums. i appreciate the thinking behind this, but wtf? There was no such thing as “Minute English” (write the alphabet as fast as possible) or “Minute Art” (string together a painted macaroni necklace in under a minute or face failure).

In high school, i finally failed my first math course – grade 12 finite. One of the reasons i never really took to math – and it’s a big one – is that i never had a math teacher who taught it to me like it needed to be taught. If my high school math teacher had told me that by learning physics, i could make a video game character jump and react to gravity and push boxes around, or that by learning trigonometry i could code my own billiards game, i would have lapped it up. As it stands, i still struggle with my fear of numbers in my professional career – the fear of failure, the constant imagined tick of the clock while i try to figure something out.

Just talk about ninja moves and video games, and everything will be fine. Ratio equations may not, honestly, be the only math you’ll ever need, but if you have a bad history with numbers like i do, it’s a decent start.

LolCat Ninja

For more Flash AS3 Tutorials and a pile of other useful stuff, check out our Flash and Actionscript 911 feature.

12 Types of Puzzles in Graphic Adventure Games

One of our clients has contracted us to build a Graphic Adventure game, and we’re jazzed. This is my absolute favourite video game genre, one that died in the mid-90′s as jocks started playing games, and the focus turned from story, humour and character design to action, violence and tits.

Duke Nukem and Lara Croft

Action, violence and tits are among my least favourite genres

Most of my unproduced game ideas are for Graphic Adventure games. So i’m toying with the idea of using this project as an excuse to build a Graphic Adventure Game engine, so that i can more easily produce additional games in that style.

So i started to think about what that engine would look like – what sorts of toolsets i would have to build, and which common Graphic Adventure game features i would need to support. i started thinking about the way in which players interact with these games: puzzles, the gameplay mechanisms than enable players to progress through the game. Here then, for your edification, is a list of different types of puzzles found in Graphic Adventure games.

Advanced warning: here be spoilers.

1. Item Use

Nearly all Graphic Adventure games have some sort of inventory, a place where the player can store items he’s collected throughout the story. The player applies these items to characters or objects in the environment to effect a change. The most simple example is a lock and a key: apply the key to the door lock and the door opens.

Modern MMO fetch quests are simple lock-and-key puzzles. Give the pirate some rum to get onto the ship. Give the seagull a french fry so that you can walk past him and climb into the dumpster.

Dizzy's Fantastic Adventure

“Dizzy” games featured a 3-slot inventory and simple lock-and-key fetch quests

Item puzzles can be daisy-chained so that a single solution requires multiple item/environment interactions. My very favourite example (from my very favouritest game ever) is in The Secret of Monkey Island 2: LeChuck’s Revenge.

You need money to charter a ship. The only place hiring is a restaurant, and they’ve already hired a chef. Through devious adventure game logic, it’s clear that you have to get the chef fired so that you can take his job. It amuses me that as soon as i found a rat on a nearby screen, i knew exactly what to do. By using three different items in your inventory, you construct a trap to catch the rat. The puzzle is one big lock using multiple keys. (The rat somehow ends up in the restaurant’s soup, and the poor chef is sent packing.)

Monkey Island 2

Just thinking about this game makes me giggle.

Using items on the environment could complete the puzzle, or it could produce a new item. In this case, use three items to build a rat trap, which gives you a rat as an inventory item. The rat is part of a bigger puzzle.

2. Item Combination

Puzzles can get even more complicated when the player has to combine two items in his inventory to form a third, new item. The new item becomes a key to open a lock. In Simon the Sorceror, use the “rope” item on the “magnet” item to create the “rope and magnet” item. Drop this item down a hole to swipe money from a dragon’s cave.

Simon the Sorceror

Simon the Sorceror: an underrated adventure game series

While item combination can be very rewarding, game designers have to be careful. As with all Graphic Adventure puzzles, designers should ensure that the reason for combining items – the goal – is clear and logical. Otherwise, you wind up with a game like Return to Mysterious Island, which features almost arbitrary item combinations and recipes. Long stick + twine + grey rock = fishing rod, while short stick + rope + black stone = hatchet. Ugh.

Return to Mysterious Island

The only mystery is why you’re still playing

Item combination can also include reverse engineering. Sometimes the player can manipulate or examine an item, or use another item on it, to break it into two or more component items. A classic example of this is opening a flashlight to produce a broken flashlight and a pair of batteries.

3. Environment Puzzle

Picking up “anything that isn’t nailed down” is tons of fun, but some puzzles simply require the player to fiddle with items right on the screen. A simple example is pulling a lever to open a door.

A creative take on the environment puzzle crops up in the opening scene of Full Throttle. Tough guy Ben extracts info from an obstinate bartender by grabbing his nose ring and smashing his face against the bar.

Full Throttle

“You know what might look better on your face? The bar.”

4. Navigation

Navigation puzzles require the player to carefully steer the character around the screen, or risk a penalty. As par for the course in Sierra On-Line Graphic Adventures, this penalty was usually a frustrating death sequence.

In Space Quest II: Chapter II: Vohaul’s Revenge, Roger Wilco has to tread lightly through a deadly maze of poisonous plant tendrils.

Space Quest II plant

Well this certainly looks annoying.

Similarly, in King’s Quest III: To Heir is Human, Gwydion has to schlepp his way up and down a perilous mountain path not once, not twice, but like a million times.

King's Quest II:To Heir is Human cliff

] Take elevator ( “I don’t understand ‘elevator’” )

A variation on this is the Endless Maze. The player reaches a rigged maze of endlessly repeating rooms. The player can only survive by learning of the correct route and taking it directly, or risk perishing in the wilderness. In The Dallas Quest, the path through the endless wheat field is etched on the tombstone of a pervious adventurer.

The Dallas Quest

i don’t care who shot J.R. … this wheat field is enough to kill any gamer.

5. Diversion

Prevalent in many LucasArts adventure games, the distraction puzzle pits the player against a non-player character. The npc usually won’t allow the player to steal things in the immediate vicinity, so the player cooks up a distraction to occupy the npc, leaving him free to pad his inventory.

In Zak McKracken and the Alien Mindbenders, Zak has to nab a number of probably crucial goodies from his seat in the airplane. But would you believe it? The witchy stewardess is constantly telling him to put the stuff back. Zak could travel to the back of the plane and clog the sink, and then to the front of the plane and nuke an egg in the microwave, creating enough of a mess to busy the meddling stewardess.

Zak McKracken and the Alien Mindbenders airplane scene

Fly the friendly skies.

6. Order of Operations

Some puzzles require the player to perform a discrete series of actions in a certain order to succeed. Return to Zork had the player perform a very specific toasting ritual.

Want some rye? Course ya do.

While it’s not a graphic adventure game, it’s worth mentioning the legendary babel fish puzzle from the Infocom text game The Hitchhiker’s Guide to the Galaxy. Trapped aboard an alien ship, the player has to obtain a babel fish from a vending machine. The fish will help the player understand alien languages. In a timed sequence, the player has to push the button and watch the elusive fish disappear multiple times – through a hole in the wall, through a robot panel in the floor, swept up by a cleaning robot, etc. By using inventory items (a dressing gown, a towel, a satchel) to circumvent these problems one by one, the player essentially constructs a Rube Goldberg machine of failure:

A single babel fish shoots out the slot. It sails across the room and hits the dressing gown. The fish slides down the sleeve of the gown and falls to the floor, landing on the towel. A split-second later, a tiny cleaning robot whizzes across the floor, grabs the fish, and continues its breakneck pace towards a tiny robot panel at the base of the wall. The robot ploughs into the satchel, sending the babel fish flying through the air in a graceful arc. A small upper-half-of-the-room cleaning robot catches the babel fish and exits.

After multiple attempts to overcome the comedy or errors, the babel fish finally lands with a wet squish in your character’s ear.

7. Conversation

Many graphic adventure games use a conversation tree to enable the player to interact with different characters. The non-player character says something, and the player can choose from one of many responses at each break in the conversation. In some games, the player’s success entirely depends on the conversation options he chooses.

In order to avoid the terribly-designed fisticuffs mechanic in Indiana Jones and the Last Crusade, the player had to pick his way past each nazi guard in Brunwald castle by choosing his words carefully.

Indiana Jones and the Last Crusade Brunwald castle

Please – ANYTHING but “throw a punch”

8. Timing

On occasion, the player is faced with an animated sequence, and must click a hotspot winthin a few frames of animation to overcome the obstacle. The climax of each game in the Monkey Island series ends with this type of challenge.

In Broken Sword (AKA Circle of Blood), George has to do some fast clicking to get past an ornery goat in the game’s most difficult puzzle.

Broken Sword goat close-up

Use anti-goat spray on goat

Broken Sword goat scene

9. Mini-games/Riddles

Adventure gamers can be a strange breed. i remember when adventure games started introducing some fast-action elements (like the fighting sequences in Indiana Jones and the Last Crusade), adventure game reviews would explicitely point out which games had action sequences and which games didn’t, in case the player was averse to these types of gameplay. Many adventurers saw the presence of a twitch element as an intrusion in an otherwise mellow gaming experience, and lacked the fast motor skills and hand-eye co-ordination to pass these sequences. Personally, i missed the final quarter of Last Crusade due to the fighting sequences on the zeppelin. i like to think this had more to do with long Amiga 500 load times and terrible game engineering than my own deficiencies as a player.

A more common break sequence seen in adventure games is an appropriately-paced mini-game that involves turn-based movement or plodding strategy. MYST caused controversy when it appeared on the scene, as adventure purists argued over whether it was even an adventure game at all. Around the same time, The 7th Guest linked classic strategy, board game and paper puzzles in a full-motion video framework and called itself an adventure game.

The 7th Guest

The scariest thing about this game was the acting in the fmv sequences

Games like The 7th Guest often rely on pre-existing puzzles that the developer pulled out of the latest Dell Crosswords n’ Challenges newsstand issue. They contain tired riddles that you’ve likely heard before, and challenges that you’ve likely solved before, like the Tower of Bozbar (Tower of Hanoi) puzzle in Zork Zero.

Zork Zero Tower of Bozbar

Oh … goody?

10. The Implausible Item

The Implausible Item puzzle is just a straightforward take-the-item action, complicated by the fact that the player doesn’t immediately recognize that the item can be taken.

In Leisure Suit Larry Goes Looking for Love (In Several Wrong Places), Larry Laffer visits the Quickie Mart and shoves a thousand-gallon Grotesque Gulp down his pants.

Leisure Suit Larry Goes Looking for Love (In Several Wrong Places)

But an even subtler example is the bloodhound that Guybrush Threepwood stuffs inside his coat in The Secret of Monkey Island 2: LeChuck’s Revenge. ( “You’re coming with me, dog.”)

11. Real-World Research

As an anti-piracy move, some games shipped physical materials in the box that the player required to solve certain in-game puzzles. These materials were often included as a copyright protection measure. In Freddy Pharkas: Frontier Pharmacist, a line-up of customers asks Freddy to concoct some 19th-century meds for them. The player is completely lost without The Modern Day Book of Health and Hygiene that ships with the game.

In DreamWeb, lead character Ryan (no relation) can’t even enter his own apartment unless the player find the access code in the Diary of a Mad (?) Man in the game box.


While it’s not explicitely a Graphic Adventure game, Where in the World is Carmen Sandiego shipped with a world almanac that the player could use to track the game’s villains. (Indeed, teaching kids to research countries using the almanac was the sole educational goal of the game.)

12. Teamwork

Some of my absolute favourite Graphic Adventure games enable the player to play as two or more characters. This opens up a whole world of fun puzzle contrivances where, for example, one character has to pull a switch to let the other character out of a dungeon. This was exactly the situation in the original Maniac Mansion, where the player could control three different teenagers in their quest to save a cheerleader from a diabolical mad scientist.

The most exciting, hair-raising moments in the game happened when one character would ring the doorbell, and then hide in the bushes. The mad scientist’s mentally unstable son Weird Ed would answer the door, leaving a second character free to pillage his bedroom for a limited time. This is the diversion technique mentioned earlier, made far more challenging by having the player juggle multiple characters.

Maniac Mansion

Ring that bell, Dave. You won’t regret it.

Utter Nonsense

Unfortunately, one of the things that led to the death of graphic adventure games was the fact that the player could get hopelessly stuck on a puzzle, even early in the game, and miss out on the entire experience. Sure, companies sold hint books, but it was a bit of a kick in the teeth when you shelled out sixty bucks for a new game, and you were unable to fumble past the first third of it without coughing up another fifteen clams for the hint book.

Now that we have the Internatz (and, most notably, GameFAQs), the problem is moot. But back in the day, you could swear that certain companies were building their games with the express purpose of moving more hint books.

Sierra On-Line was a prime offender, with its King Graham mascot combining completely unrelated items to solve nonsensical puzzles, baffling the player within an inch of his life. (For a special treat, read Old Man Murray’s moratorium on adventure games, which puts a fine point on the topic with a hilarious conclusion.)

But if you were to put a series of games to death for its completely out-of-left-field puzzle design, it would be Gobliiins.

Gobliiins 2

Can you explain what’s going on here? Cuz i sure can’t.

Here’s an example from Tom Hayes’s GameFAQs guide for Gobliiins 2:

Get a feather from the helmet. Use the feather on the can of red paint. Use the cockroach on the hole. Use the brush, pepper and kind elixir on the cockroach.

The Gobliiins games combine many of the puzzle types listed here – teamwork, item use, inventory combinaton, timing – to such a completely inept degree that i recommend that you steal – not pay, STEAL – at least one of the Gobliiins games for a crash course in how NOT to design a Graphic Adventure game.

i’m a HUGE advocate of purchasing games with your hard-earned cash, but in this case, i’ll make an exception. If you’re feeling guilty about stealing one of these steaming piles, take the money you would have spent on the game, and give it to a charity of your choice. Or set the money on fire and burn the game in a big expensive bonfire.

… but not before using Winkle to hold the chicken and then using Fingus to hit the chicken on the head with a sausage to make it lay an egg.

For further reading, check out Mark Newheiser’s article classifying Graphic Adventure game puzzles

Tutorial: Understanding Classes in AS3 Part 1

A reader named Ryan (no relation) recently requested that we create a post to help him and other beginners understand Classes. So this is an ultra-gentle primer on Classes – what they are, when to use them, and how to write them. If you’re stuck in an Actionscript 2 rut, or you’re new to Actionscript 3 and it’s blowing your mind, this should help ease you in a bit better.

The path i travelled from complete code newbie to the shock-inducing AS3 god that i am today ( er … hardly) went like this:

Beginner – i put my Actionscript code everywhere – on different frames of the timeline, embedded in nested MovieClips – if i can write code on it, i do.

Spaghetti Code

That’s called “spaghetti code”, and it makes your life as a programmer difficult.

Intermediate – Scattering code through my Flash movie makes my project an enormous pain to manage and update. i’m going to put ALL of my code on the very first frame of my movie, so i only have to look in one place for it.

First Frame

Placing all your code in Frame 1 was a good idea with AS2, but you can do better

Pro – i don’t understand Classes, but i have to take the plunge somehow. i’m going to move all of my first-frame code into a separate .as Class file. i hope that’ll be the first step to breaking everything up into Classes.

Code Goes Here

This is what we’re striving for

Shock-Inducing AS3 God – Man almighty – packing an entire project’s code into one .as Class file makes it an enormous pain to manage and update. i’m going to identify little modules of code and split them off into their own .as Class files. Hey … now i’m starting to use Classes like a superstar!


Not *THE* God – just *A* god

The Road to Pro

In this tutorial, we’ll help you move from Intermediate to Pro by moving your first-frame code to its own Class in a separate .as file. In Part 2, we’ll take you from Pro to God by discussing ways in which you can split that enormous file up into smaller Classes, and how to figure out which pieces would make good Classes.

Many of the AS3 tutorials you see on the Internatz are written so that you can just paste the code into the first frame and compile the project. This is because it’s easier on the tutorial writers – they assume that you know how to re-write that code to put it in its own Class. But what if you don’t know?

Let’s take a piece of frame code, and bring it outside our Flash .fla file into a separate .as Class file. Here’s the frame code we’ll be using:

var speed:int = 5;
var ball:MovieClip = new Ball();

addEventListener(Event.ENTER_FRAME, moveBall);

function moveBall(e:Event):void
  ball.x += speed;
  ball.y += speed;

This code grabs a MovieClip called “Ball” from the library and places it on the stage. On every frame, the ball moves to the right 5 pixels and down 5 pixels. We’re going to pretend that this code exists on Frame 1 of our Flash movie. (Note: you don’t need to copy/paste this code and try it, but go ahead. If you’re not sure how to create a ball MovieClip and link it in the library, you might be in over your head already. Read up a bit on super-basic Flash stuff, and we’ll see you again shortly.)

Now let’s create an empty, external .as Class file to hold all this code. So your project will consist of two files: the Flash .fla file, which has a Ball Movieclip in the library, and a Class file with an .as extension. This isn’t anything fancy – an .as file is just a plaintext (.txt) file that you save with a .as extension. So yes, you can even write this file using Notepad or your favourite text editor.

The .fla and the .as file should exist side-by-side in the same directory.

Side by side

Same directory. We can get fancy later.

The Care and Feeding of Classes

Classes demand a particular structure:

AS3 Class Structure Diagram

Notice a few things:

  1. Package (whatever that is) wraps the whole thing
  2. the Import statements (whatever they are) come next
  3. the Class Definition (huh?) wraps everything else
  4. the Instance Variables, Constructor Function and other methods/functions are tucked inside the Class wrapper. You can put these three things in any order, but this is how you’ll usually see them in the wild.


AS3 Class Structure Package Diagram

Let’s deal with that Package thing first. The Package declaration is a way of grouping all your Classes together. Let’s say you’re working on a project with Bob. You have a class called “Stuff”, and Bob has a class called “Stuff”. By uniquely naming your Package, your classes won’t conflict.

But are you working with Bob right now? Are you on a big project with multiple programmers? No. So don’t worry about it. Forget Bob – just start with a generic Package declaration, which looks like this:

     // All the other stuff goes in here, between those curly brackets

(note that “package” has a lower-case “p” … i’ve used an upper-case “P” in the article just to make the word pop out at you)

Import Statements

AS3 Class Structure Import Statements Diagram

Different parts of the ActionScript 3 language are already split up into packages. When you put your code on a frame in Flash, all of those packages are automatically accessible. You don’t have to do any extra work.

But when you work outside Flash, you have to tell the compiler to go grab portions of the AS3 language before you can use them. So if you say this in an .as Class file:

var myclip:MovieClip = new MovieClip();

the compiler will throw you an error, effectively saying “What’s a MovieClip??”

Use an Import Statement to explicitely tell the compiler that you are using a certain part of the AS3 language. This is a giant pain in the ass, and a real roadblock when you’re starting out. As a beginner, you don’t know the package names you’ll need. This is just a painstaking trial-and-error period of looking in the documentation, or referring to other people’s code, and eventually you’ll memorize this stuff. (Or you can use a program like Flash Develop, which automagically figures some of it out for you.)

So if you use a line like this later on in your code:

var myclip:MovieClip = new MovieClip();

you have to include an Import Statement like this at the top of the file:

import flash.display.MovieClip;

(note: small “i” on “import”)

It’s like you’re saying “OK, compiler – we’re going to talk about fish today. Go get that fish book out of the library so that we’re all on the same page.”

Class Definition

AS3 Class Structure Class Definition Diagram

This is where you actually start writing your Class. Here’s the format:

public class Main extends MovieClip
    // The Instance Variables, the Constructor Function and Methods go here

Let’s break down that line piece by piece:

public Class Main extends MovieClip

We don’t really need to bother with understanding public vs. private vs. protected vs. internal. Those keywords are all in the same family, but here’s what you need to know: you gotta use “public” here. Don’t worry about the other possibilities until you’ve got a handle on the basics. If you don’t use “public” in the Class that replaces your first-frame code, you’ll get an error.

public Class Main extends MovieClip

We’re writing a Class! i’m getting all tiingly.

public class Main extends MovieClip

This is the name of the Class. Feel free to use your creativity here – you can call it whatever you like. But there are a few important rules:

  1. You must use standard naming conventions. Don’t start the name with a number, and stay away from spaces and special characters.
  2. Use a capital letter to begin your Class name
  3. When you save the file, the file MUST have the same name as your Class. If your Class is called Main, save the file as If it’s called MyProject, save the file as If you don’t do this, there will be trouble.

public class Main extends MovieClip

In earlier attempts to understand Classes and Object Oriented Programming (OOP), you may have heard of the concept of “inheritance.” That’s what the “extends” keyword is all about. Without exploring too deeply, we need to extend / subclass / inherit from an ActionScript 3 Class called MovieClip. Why? Because if we don’t, we’ll get yelled at. So just do it. Strive to understand it later.

public class Main extends MovieClip

That’s the Class we’re inheriting from. It’s like saying “my Class called Main can do everything a MovieClip can do, and more.”

Instance Variables

AS3 Class Structure Instance Variables Diagram

Instance Variables, sometimes called Fields, are variables that you need to access throughout your Class. If you’re familiar with the idea of scope, you’ll know that when we do this:

function myFirstFunction():void
   var myVariable:String = "someValue";

we’ll get an error if we try doing this:

function mySecondFunction():void

That’s because myVariable is scoped to myFirstFunction. It doesn’t exist outside that function.

If you want variables to be accessible to all the different functions in your Class, you declare them in the orange area on the diagram. You’ll also need to decide whether you’re making these variables public, private, internal, protected, etc. This is not a decision you need to make when all your code is on the first frame. OOP purists would absolutely FREAK OUT if they were reading this, but i’m going to recommend you make all your variables public for now. It’s the least error-prone approach when you’re learning, and when you know more, you can get a little fancier.

So here’s what a typical Instance Variable would look like at this point in the .as Class file:

public var myVariable:String;

Notice that we’re not even setting a value yet. We can, but we don’t have to. We’re just reserving a spot in the computer’s memory for this variable so that the whole Class can use it.

The Constructor Function

AS3 Class Structure Constructor Function Diagram

This Main Class will be what’s called the “point of entry” into our Flash program. It’s the first place where code will start being activated. A Constructor Function is like the point of entry in any Class. It’s the first function that’s fired when a Class is encountered by the interpreter.

Here’s what our Constructor Function should look like:

public function Main()

As with Classes, you have to follow a few rules with your Constructor Function:

  1. The Highlander rule: “there can be only one”. i believe other languages allow you to have multiple Constructor Functions, but AS3 does not.
  2. The name of the Constructor function must be the same as the name of the Class.
  3. Make sure it’s public.
  4. Don’t return a value – not even “void”. Constructor Functions are not allowed to return a value.

Putting It All Together

Let’s slap it all together and see what we’ve got:

    import flash.display.MovieClip;
    public class Main extends MovieClip
        // instance variables go here

        public function Main()
             trace("It works!");

        // other functions can go here

Super! We’ve got the shell of a Class that we can use as our point of entry. (Make sure it’s saved as “”, or whatever you called your Class.) We’re just missing one step. We have to tell Flash that instead of looking to the first frame of the movie as our point of entry, we want it to look at the “Main” Class.

Open up the Properties panel in Flash and look for an empty field labelled “Document class:” (CS3) or “Class:” (CS4).

Document Class Flash CS3

This is what it looks like in Flash CS3

Document Class Flash CS4

… and in CS4

Note: you won’t be able to use this feature unless you’re targeting Flash Player 9 or above, with ActionScript 3 or above.

Type “Main” (without the quotes) into this field. Then save and compile. You should see the trace statement “It works!” in the Ouput panel.

All the Rest

Now that we have Flash looking to an external .as file to get the party started, let’s port over some of that first-frame code into our class. i’ll paste the clean version first, and then an identical copy with extensive comments so that you can follow along at home:

    import flash.display.MovieClip;
    public class Main extends MovieClip
        public var ball:MovieClip;

        public function Main()
             ball = new Ball();
             ball.speed = 5;

             addEventListener(Event.ENTER_FRAME, moveBall);

        public function moveBall(e:Event):void
                ball.x += ball.speed;
                ball.y += ball.speed;
    // This is the commented version.
    import flash.display.MovieClip; // since both Ball and Main are MovieClips,
              // we have to import the MovieClip Class 
    import; // Later on, we use the Event Class, so
             // we need to import it here.
    public class Main extends MovieClip
        // See how the Class definition and import statements
        // are inside the package curly brackets?

        public var ball:MovieClip; // We declare "ball" up here
             // so that the whole Class can refer to it

        public function Main()
             // This is the constructor function!

             ball = new Ball(); // Since we already declared "ball"
               // as an instance variable, we can just refer to it
               // directly without redefining it
             addChild(ball); // Where does ball get added?  Main
               // is representing our Flash movie's main timeline,
               // so that's where the ball appears
             ball.speed = 5;

             addEventListener(Event.ENTER_FRAME, moveBall);
             // note: no need for the word "this", in case you
             // were wondering

        public function moveBall(e:Event):void
                ball.x += ball.speed;
                ball.y += ball.speed;
                // Again, because "ball" was defined up top, 
                // the moveBall method can refer to it

Are You Smart Yet?

Hopefully, you know enough now to port your whole wad of first-frame code to a separate .as Class file. That’s a baby step towards actually using the power of Classes to save yourself time in the future, and to keep your code organized, updatable, and a pleasure to re-visit.

In the next part of this tutorial, we’ll look at ways you can pick through your Wall of Code and identify which pieces you can could out into their own Class files.

For more Flash AS3 Tutorials and a pile of other useful stuff, check out our Flash and Actionscript 911 feature.