Posts

Showing posts with the label game design

Come to Mochi London on Saturday (27th August 2011)


In my last post I wrote about how the Flash community feels in need of a reboot, to align it better with Flash's new users, and its new role as a games technology. Well, events like Mochi London are probably a big part of that reboot. Mochi London is a free 1 day conference, being held this Saturday (27th August 2011) at King's College London.

I will be speaking there with a brand new session called Addictive Game Design - ok, I've borrowed a lot of the content from my 2010 Flash on the Beach talk ;)

The other speakers include Merlin Gore from Flash Game License, and Mike Jones from Adobe, as well as a whole bunch of other developers. It's free but you need a ticket, so grab one on Eventbrite while there are still spaces. There's also a pub gathering on Sunday, but I won't be able to make it to that. Hope to see you there!

How to make a whole game in one day

There are game jams and Flash game competitions seemingly every weekend these days. While I don't really like the idea of pinning my eyes open with matchsticks and coding all night, I do like the idea of getting a complete game finished and released in a single day. I sometimes get a day or two of downtime between client projects, and rather than using this time to experiment on bunnies, I've been trying to work out how feasible it is to release 1 or even 2 games in these gaps.

My first couple of attempts have overrun by about double, and still aren't released (I'll keep you posted), but I have learned a few things along the way that I thought were worth sharing. I've also picked the brains of some other friendly developers for some suggestions (you know who you are, so thanks!)

Here's what I've worked out so far:
  • The game can't have more than 1 level that you need to design. So a single maze like Pacman would be ok, but you can't have every level be different.
  • You can't require any complex artwork. You need to use either free art, cheap stock art, art you already have kicking around, or art you can put together in 1 or 2 hours.
  • You need a game engine to start off with. Flixel and Flashpunk might work for you, but I prefer to use my own engine, which I have been revising and improving for well over a year. It's still nowhere near "finished", but I'm not writing much low-level code for each new game.
  • You need a template .fla and/or FlashDevelop template already set up so you don't have to write any boilerplate for Mochi-ads, screen management, preloading etc
  • Your game must have a way of automatically progressing - with either randomly generated levels, or a simple way of getting progressively harder automatically. Players expect to go on a journey of increasing peril, but that's hard to "author" in just a few hours, so automating it is the only way to go.
  • Your game can't introduce you to any programming techniques that you've never done before - e.g. new type of collision detection. Learning a new technique is a fine way to spend an afternoon, just don't expect a game at the end of it.
  • The game must have reasonably similar gameplay to an existing game, so you're not working every aspect of game design out from scratch. If you add even one or two elements to a game that are completely novel, you've done more than most. Combining game mechanics from different games that you enjoy seems like a logical starting point.
  • Don't try to make all the code you write reusable - just get the game done, you can always come and copy bits out of it later.
  • Don't throw your idea out half-way. Once you come up with your idea and started coding, you might as stick with it and do the best job you can to make it fun. Even if it doesn't turn out to be the new Tetris, at least you will have another completed game under your belt.
If you've got any more suggestions and lessons-learned from your own game-jam experience, please post them in the comments.

Gamedev and Indie Games Podcasts

Some decent podcasts about designing, developing and playing games:

Audio

Another Castle - Professionals talk game design.

Game Developers Radio - Great guests, a different game or development platform discussed each week.

Brainy Gamer - Game design from designer, journalist, academic and player perspectives.

DigiPen - Professionals and educators talk games.

IndieGamePod Interviews with developers about their games.

A life well wasted Arty, philosophical trip around gaming culture.

IndieGames.com Podcast (iTunes) (site) Fun interviews with A-list indie developers.

Infinite Ammo (iTunes) (site) In-depth 2 hour discussions on gamedev!

Irrational Behavior The team behind BioShock on how they make games.

Irrational Interviews Interviews with gaming luminaries.

Video

Bytejacker - Fun video reviews of great indie games.

Co-op - Fun video reviews and chat.

Flash on the Beach 2010 – This guy’s experience.


I’m writing this on the train home from Flash on the Beach. I should probably be coding a game like I did on the way to the conference, but I’m finding that after sensory overload from 3 days of sessions, a few late nights and the terror of doing two(!) sessions on stage, my brain is unable to do code right now.

My main session seemed to go very well, although I’m gutted for all the people who couldn’t get in because it was so packed. The demos from the session are already available at DullDudeGames.com/game-designer and I’m going to add a transcript of what I said and my slides very shortly. If you were an attendee there should be a video at some point, although I didn’t see any cameras so maybe it’s just a screen cast or something. It was my first full session at a big conference, and definitely an item ticked on my bucket list. I’m mega grateful to conference organiser John Davey for putting me up there, and Pokemon Trainer Seb-Lee Delisle for being my hype-man for the last 2 years. Without Seb, probably nobody would know who I am. He’s also a bloody ruddy nice bloke.


As happens at every talk I give (will they never learn!), some people asked me afterwards if I would share the source code from my talk. The demos are built on my work-in-progress game engine, so I can’t share the source to the games without also including the game-engine, which for business reasons I am not able to do, although a big chunk of it is already open-sourced in my Gamepad library.

The funny thing about geeks is, even when I do a session about design – purely the creative decision making side of games – geeks still just want to look under the hood! The main feedback was that people wanted to know the maths for the car handling physics, so I’m going to turn that into a tutorial and post that here on my blog. Also, if you’re more into the wizard stuff, I have the full source for a different Zelda-style wizard game that I made a while ago, that I am going to give away here too.

Slightly weirder was my last minute addition to the “jam throwdown” on the terrifying main stage. I was only asked to do it the night before, and had planned to show my complete greatest hits from the last 11 years of my work. Not having a chance to rehearse, I didn’t know that this was actually impossible, so what the attendees got was about the first 5 years, which was loads of terrible, daft lo-fi experimental Flash stuff and a few games. It seemed like people got the joke, but I did have a small bout of paranoia that everyone hated me straight after. Do not underestimate the social paranoia appearing at conferences can give you! I have had some nice feedback about the slot on twitter since though, so I feel ok about it now. People were probably just being nice, but thank you, I appreciate it!


(photo Copyright All rights reserved by oyvindnordhagen)

Even though I’m just a geek talking about geeky stuff, it’s really hard not to get a bit of a rush from making a whole auditorium of people laugh or go “oooh”. I wonder whether this is why people like Hoss Gifford and Brendan Dawes pack their sessions with jokes? I don’t think I got into speaking as a back door into stand-up comedy, but to be honest I have no idea why I did want to get into it. Certainly a large part of me finds the whole experience completely harrowing. What is “speaking” or being a “speaker”? Why do it? What is it for? I have genuinely no idea.

That’s enough about me though, what about all the talented speakers? Well it was a slightly strange one for me. For one thing, since last time I have become even more focussed on game development, and there wasn’t much representation for gamedev, so there weren’t many sessions that apply directly to what I do day-to-day. From the queue outside my talk and Jon Howard’s (excellent) session, there’s obviously a lot of pent-up demand for it among attendees. Maybe next year John could try to book some Flash gaming luminaries like Dan Cook or Adam Atatomic? I’ll definitely suggest it to him.

I want to word this next bit very carefully so that I don’t offend any of the amazing speakers who I saw and spoke to during the conference, and who are all some of the most talented and inspirational people you will meet in this industry. Here goes then: basically what I’ve noticed is that not every speaker can inspire you as much the second and third time you see as they do the first time you see them. Even though everyone updates their material regularly with new work, nobody has an unlimited supply of mind-blowingness. Ideas that are revolutionary when you first see them get synthesised into the way you see the world. The same idea can never inspire you again in the same way it did the first time. This is no reflection on the talent of the speaker, it’s just the nature of ideas.

And this is why I loved the elevator pitch so much. Twenty speakers from completely different disciplines blasting you with as much information as they can get into a 3 minute slot. I know from experience that each 3 minute speech has many hours, if not days and even weeks of preparation go into it. This shows through massively and you get exposed to more new ideas in this session than any other. Someone tweeted that speakers collect elevator pitchers like Pokemon. I kind of played Pokemon Trainer a bit this year, encouraging Andreas, Jasper and Tom to do the pitch. This reflects very well on how I choose my friends, because my Pokemon were easily 3 of the best in the whole session.

Andreas presented his DDConsole aka DoomsdayConsole which is a runtime tracing/hacking/debugging/tweaking console for Flash, inspired by the ones you find in games like Quake. It’s completely open source and completely ace. Through some wicked 8-bit graphics and animation, Tom presented his awesome sound effects generator AS3sfxr with such style that he also managed to subconsciously teach you how to do the creative side of sound design.

Jasper showed us all why Unity3D is the crown prince of 3D game engines by building his slide-deck as an Incpetion/Matrix inspired fly-through of a city falling into place. Nobody loves Unity as much as this guy. He’s thinking about it most the time. He’s probably thinking about it right now. What he didn’t tell you during his slot was that he taught himself to model in Maya just to make his presentation. And you’d never have noticed it, because his models looked awesome. I could tell that Jasper enjoyed the experience because I spoke to him after and he had a crazy look in his eye like someone who had just discovered crack. Anyways, if you went to the conference, please vote for these guys on your feedback form, they’re ace.


The stand-out session of the conference had to be Seb’s “What the flux?” There’s been a lot of mud thrown back and forth this year between Flash developers, HTML5/web standards advocates, and of course Apple, and Seb has spent a lot of time trying out these various competing technologies. He presented a some home truths that I don’t think everyone was ready to hear, but presented it a way that was optimistic, pragmatic and tried to build bridges. He had video interviews with some smart people from both camps, which he cut in with some political slogans, a game show skit and some jokes. I don’t actually agree with him that JavaScript and HTML5 are anywhere near ready to move into the immersive/experiential/flashy uses of Flash, but on everything else he was about right. He did point out that Flash is still the mofo daddy for web games.

Grant Skinner showed some cool physical device experiments like using Android phones as controllers for 8 player Asteroids and even as accelerator pedals for Scalextric. Also there was some marital aid hacking which raised a few eyebrows. In Grant’s session I began experimenting with starting rounds of applause, my first attempt failing and making it seem as if I was slow clapping, which was quite an amusing little moment that he dealt with like the pro he is. After that the audience really got into it, and through my further efforts I managed to increase the numbers of rounds of applause in all sessions I went to by at least a factor of 2 for the rest of the day. This is great for the atmosphere of the conference. If everyone is showing appreciation of a good speaker it actually increases the speaker’s confidence and makes for a better session. Towards the end of the conference I noticed an annoying trend that people were only clapping videos and not any other type of work that was shown. This is really silly and completely unfair on speakers who do different kinds of work, e.g. INTERACTIVE STUFF.

Other highlights were surrealist animator Cyriak Harris, design legend Stefan Sagmeister and designer/director Nando Costa who made this year’s amazing title sequence, which is frankly the sexiest form in which my name has ever been written. Watch it and see why. Nando showed some wicked film work he’d done with Modest Mouse (who I love) as well as other portfolio stuff. I chatted with Nando later about life in Portland and he’s a thoroughly nice bloke. I am now 1 degree of Kevin Bacon away from Modest Mouse which is a nice thought, although completely pointless.

I am completely exhausted now, so I’m going to get back to normality for the rest of the year, and take my Zero to Game Designer in 60 Minutes talk on the road in the new year. Thanks so much to everyone I met for being so supportive!

A code review of PewPew by Mike Chambers


A very rare event has occurred - the chance to look at, discuss and play with the full source for a Flash game! I've worked with the source to dozens of games by different developers, but I'm normally under a non-disclosure agreement so I cannot divulge the full horrors of what I found there. But Mike Chambers from Adobe has kindly released the full source to his game under MIT open source license, and I thought this could be a great spring-board to open up discussion on the architecture and best practice of making Flash games.

but you also need to download is framework from here: http://github.com/mikechambers/Simple-Game-Framework/archives/master

Mike, hasn't made a game since Flash 4, so if you read this Mike, please take it in the scholarly spirit in which it is intended :)

and to everyone else, remember I am just one guy with some strong opinions, weakly held.

Ok here's my thoughts...

Repository - Mike has not included his framework in the game repository. I'd consider this a bad idea for 2 reasons.
  • A developer coming to the project cold cannot compile it. I believe that the repo of a project should contain everything you need to get started.
  • There is a strong chance that API changes could be made to the framework code that break the build of the game. You really want to use a stable version of a framework rather than having to fix errors every time an update is made to the framework. Then if you want to update to the latest version of the framework you grab the new version and fix all the problems at once. You don't want to come back to make a quick change to your game in 6 months, only to find that you can longer compile because you have changed the API of your framework.
Compiling
  • Mike has chosen to compile from the Flash IDE, which is fine with me and most design-driven agencies. Some developers won't like it, but who cares.
  • Mike has unticked the "include hidden layers" option in the Flash publish settings tab. This is one of my absolute no-nos as it means you can break the build just by hiding and unhiding layers while you're looking around the timeline. If I hadn't encountered this lunacy before, I might have spent hours figuring out why it suddenly wasn't compiling. In the end I had to revert to the original version because I couldn't remember exactly what should and shouldn't be hidden. This is what guides are for, people.
  • One mistake Mike's made that I see quite a lot is that he hasn't put his Main.as document class file in his package structure, it's just in the root of src with the fla. The Main class is just as much a part of the project as anything else, and should be in the package with it's friends.
Game Design
  • the game is a pretty basic asteroid-type shoot 'em up.
  • the home-made visual and audio style is acceptable in the Flash game world, although Mike could have chosen a more hand-written looking font, rather than Helvetica. There are lots of free handwriting fonts out there, and there's always Comic Sans!
  • the controls are optimised for a touchscreen mobile device, with a little virtual joystick in the bottom corner, so it doesn't control well on the desktop.
  • the joystick doesn't allow you to set speed, only direction. A simulated analogue stick would have been nicer.
  • There is some commented-out code for making the ship follow the mouse for browser play, but it is incomplete. Mike would have done better to have a boolean for isMouseControlled which could be switched when targeting the browser, rather than completely commenting out the code. I rarely delete or comment out working code, I'm much more likely to keep it in my class as a switched-off option.
  • At 480x800 it's too tall for a browser game, as you have to consider users with a minimum 1024x768 display.
  • The movement of the ship is not very graceful - it doesn't seem to accelerate or decelerate.
  • The speed of the bullets is way too slow.
  • The collision detection between the bullets and enemies is inconsistent, and bullets often sail under the wings of the UFOs without scoring a hit.
  • There are no roll-overs or even finger cursors on any buttons - again this is probably an artefact of originally being a touch-screen game.
  • There aren't any transitions between screens.
  • The enemies bounce around the screen like asteroids, but they are UFOs, which doesn't make any sense, as you would expect UFOs to know you are there and either attack or make defensive manoeuvres.
Library
  • Mike's library is beautifully arranged into folders with all the items named properly, and no Symbol 1's lying around. I rarely organise my libraries into folders any more - I just rely on the invaluable CS4/5 library search box.
  • Mike has linked library items directly to classes. This is what I often do as it is fast and makes it easy to understand what code relates to what graphics. It can have it's draw-backs though, for example if you want to runtime load assets from multiple swfs without having to republish them with every code change, and I'm coming round to the idea that it is often better to treat movieclips as "skins", with no code of there own, and have another class that controls them. It would be nice if at runtime you could tell Flash - take this movieclip and make it an instance of this class. That would be cool right, and totally feasible, Adobe engineers?
Code style
  • All Mike's code is beautifully organised, with well-named full-word function and variable names like isOnStage, displayTitleGraphic and onGameOver. This is painfully rare to see, so I salute you Mike!
  • Mike has commented to the point of obsession, which is great, but as his code is so well named and self documenting, most are unnecessary, such as:
    //start the game
    gameArea.start();
    //added to enemies vector
    enemies.push(enemy);
  • Throughout his code Mike has used // double slash comments on his public vars and functions, where he should have used /* slash star */ JavaDoc style comments. This would have allowed code editors like FlashDevelop to give the comment as a hint / tooltip. Really useful when working with an unfamiliar API.
  • There are some slightly strange things with splitting single lines of code over multiple carriage returns, with orphans tabbed weirdly across the page. This is either a Mac/PC formatting issue, or a sign of madness.
Architecture
  • Mike wrote in his blog that he thought he had over-engineered the game and he's not wrong. I ran a little app called cloc (count lines of code) on the folder and it told me that not including white space and comments there are 2420 lines of ActionScript. That's quite a lot when you consider that I managed to get a similar game running in 25 lines of code. Not all the code in a framework needs to be used on every project though, so it's not as bad as it sounds! If you ignore the framework it's only 1644 :) I have a feeling cloc might be over reporting because of block comments, but I might be wrong. So where is all that code going?
  • The GameArea class contains most the game logic, and is a fairly typical well organised game class. I has more white space and comments than it does code though, which I think makes it less readable. Overall this class is very sane though and doesn't include anything particularly wacky.
  • SoundManager doesn't do much - it doesn't even play sounds! Instead it returns and instance of a sound which you can then call play() on. It also contains constants for each sound class name in his library. This might sound like a good idea, but it isn't. Either use the class reference directly or just put the string in your function call. Not every string you ever type has to be put in a constant.
  • For entities there is an inheritance chain of MovieClip > GameObject > PewPewGameObject > Enemy > ChaserEnemy. I've used this kind of approach on many games, and it works up to a point, but it doesn't make your code very reusable, and you often have to hunt around different inheritance levels to find code. These days I use a very simple component system (nothing to do with native Flash components by the way) where functionality is broken down into modules which are owned by objects. So you would have a health component, a weapon component, a position/movement component, a sprite component etc. In Flash we lurve inheritance because it makes us feel like proper programmers, but composition is often a much better approach. This has taken me literally years to come to terms with, so I won't be surprised if lots of people disagree with me. Mike would also be in trouble if he wanted to adapt his game to use Away3D for rendering for example, as he has extended MovieClip. That said, you should always focus on the game you are making rather than worry about "what if" scenarios that will never happen.
  • Mike is using standard Flash events in his game. Again, I've done this many times myself, but since AS3Signals comes out I just use that - but TurboSignals is supposed to be even faster and so probably more appropriate for games. If you want real speed don't use eventing at all - give each entity a reference to your game class and call methods directly on that.
  • Mike has a reusable GameObjectPool class for object pooling, which is nice. However, when you ask it for e.g. a ChaserEnemy, it returns an instance of GameObject which must then be cast back to ChaserEnemy anyway, so he might as well of made an object pool that supports any class type, not just GameObjects.
  • Mike also has the start of some nice util classes for useful Maths functions, but they're not particularly extensive.
Conclusions

Overall PewPew has the hallmarks of a disciplined programmer with good style. Unfortunately it also has many of the limitations that 90% of Flash games suffer, which is a lack of some basic features that you would have seen in games from 20 years ago:
  • A health bar rather than instant death.
  • A scrolling world.
  • A solid world with walls, rooms, corridors etc, rather than just an open void.
  • Basic physics like momentum
  • Ability to pause the game
  • Particle effects for trails and explosions
  • Animated sprites
Good on Mike for releasing his code for public scrutiny - I worry that this is the extent of Adobe's knowledge of game development though. Their gamedev hub http://www.adobe.com/devnet/games/ seems to have been mostly contributed by 3rd parties, and it even includes some advice on such topics as making games with Cairngorm, which is never going to end well. Flash is badly in need of an official gaming API/framework on the scale of Flex. I don't see that happening any time soon, so until then we're all just going to keep re-solving solved problems and repeating the mistakes of the past.




Goals, missions and quests

Games with little in the way of narrative tend to have quite abstract goals for the player to aim for. I've written before that "games are about the relationships between objects in space", and in a pure game like Tetris or Connect 4, the goal is simply to get some objects into a particular spatial relationship, for example a straight line. Most action/adventure games however, use three basic goals :
  • Kill enemies (like Space Invaders)
  • Collect items (like Pacman)
  • Reach Location (like Mario - although he also collects items and kills enemies)
Even a game like Gears of War is basically made up of just these goals - get to the extraction point while picking up weapons and ammo and killing locusts. But that's not what makes GoW exciting or fun - it's the obstacles that get in your way - environmental puzzles to solve, enemy behaviour to study and overcome, and the twitch skill you need to survive.

The problem with RPG quests, like you find in World of Warcraft, is that they often remove all the obstacles, puzzle solving and skill that GoW requires, so that all that's left is repetitive"grind" - fighting, collecting and trudging around, without any real thought going on. If the quest designer has the tools to make an interesting journey for the player, they can make something rewarding - if they are only able to define basic kill 10 rats scenarios, then the experience will be a chore.

Kill Enemies

It's worth noting before I get into this topic that "killing" doesn't really have to be as violent as it sounds. Killing an enemy can be as metaphorical as you want to make it. Maybe your enemies are only stunned, maybe you're freeing them from some king of mind control (wasn't Sonic like that?), maybe they're not really enemies at all but customers in your cafe that you need to serve. The gameplay effect is the same: you have tapped into the part of the human brain that has evolved to deal with understanding the behaviour of another sentient creature, in order to get what you want from it, be that to eat it, not be eaten by it, get it's money or win it's affections. In The Sims for example, aren't each character's enemies really their neighbours and housemates? They must be charmed and seduced in order for the character to get what they want from them. Failure to do so will send your character into a spiral of depression, which is ultimately the closest The Sims has to losing.

Each type of enemy should have a unique appearance, but most importantly should have a unique behaviour, way of moving and interacting. Encountering an enemy for the first time should be a mini-puzzle, where the player must figure out how they need to manipulate their avatar in order to avoid the enemy's attacks and hit with their own, even if that mental process happens deep in the reptile brain rather than through a concious decision. If the player has different types of weapons, abilities, special moves or unit types to control, then each should have a different effect and effectiveness against a particular enemy. Real time strategy games do this really well, where, for example, a commando can take out a person in a single shot, but is useless against vehicles, forcing the player to think strategically about which enemies to attack with which of their own units.

Collect Items

Collecting items can be for its own sake, or it can be because they confer some ability that is useful in achieving the player's other goals. A game like Farmville uses only this goal - the aim is to accumulate as many coins, crops and animals as possible. There are is no location to reach or enemies to kill or avoid along the way, and you are never in any peril. The only thing you can do wrong is to not login to the game to harvest your crops, but this doesn't require skill or strategy, only a tireless devotion to the game. This is how Farmville is so successful in attracting a non-gamer audience. The player is only rewarded and never punished, unless they decide they have something better to do.

In a game like Gears of War, the main purpose of items is to make the player more effective in killing enemies. A gun or ammo pack has no sense of worth, other than as a means of eviscerating the enemy, and a player will happily toss it aside when something else comes along. Now compare this to an RPG where a weapon also has a monetary value and might have been difficult to acquire, and you'll find that a weapon becomes much more a prized possession. RPG's are very materialistic in this regard - every item has a price and the player spends a lot of time studying and organising their "inventory" and shopping for new items. As in The Sims, there's a lot of playing dress-up/playing with dolls here, and this is something which actually appeals to boys as well as girl gamers.

Collecting items can also be used as a way to test the players skill at the game and knowledge of the levels, with items placed in hidden or hard to reach places. Even Gears of War has it's Cog Tags, which serve no purpose other than to demonstrate that a player has a trawled every virtual inch of the game, which brings me onto the next topic...

Reach Locations

Since the earliest recorded times, stories have used a journey structure, where the protagonist sets out to reach a particular place and has an adventure along the way. Humans evolved to be semi-nomadic, and even the biggest homebody has a wanderlust somewhere deep inside. We love to travel, or climb trees or see what's around the next corner, even if we have no need to. Ever since the technology has permitted games with a playing area larger than a single screen, videogames have used this urge. But we tend not to make it too easy for the player to go exploring. Aside from enemies in the player's way, there are also environmental obstacles. I personally get nothing out of having to perform a set of perfectly timed jumps on every screen, but there are also environmental puzzles to test the player's logical brain, as you see perfectly executed in games like Half Life 2 and Portal.

So that's my breakdown of what I see as the 3 main goals a player has in a typical videogame: kill enemies, collect items, reach locations. Or if you wanted to be really reductionist, you could say that the goal of games is to keep some objects far apart and some close together.

Go any thoughts on this? Post them in the comments.

Some thoughts on character design

Some random things I remember reading about character design, and some things that have worked for me. Thomas the Tank Engine breaks both my first two rules, so should be an example of the bad character design, but somehow kids love it!

  • a character should be recognisable from just their silhouette.
  • Each character in a group should have their own colour scheme.
  • Simply-drawn characters are easier for the player/viewer/reader to relate to, because they are less specifically one person, and more of a vessel for the player to project themselves onto.
  • For the same reason as above, characters shouldn't say much - that's the Gordon Freeman effect. Most game characters don't talk, and when they do talk, on spin-off cartoons etc (e.g. Sonic), it's annoying.
  • In games you can express a lot about the character from the way they move and interact with the environment.
  • For unique costumes, raid the history books for crazy armour, uniforms, hats and dresses, and adapt to fit your setting.
  • Don't use anything that is too reminiscent of another famous character, e.g. blue spiky hair, red overalls etc
  • If your game/whatever is very focussed on the main character, name it after that character, as this will avoid confusion later. For example, all the Indiana Jones movies are called, "Indiana Jones and the..." except the first one is just called "Raiders of the Lost Ark", which could be a bit confusing. This is also true of Rambo - the first movie was just called First Blood, but most people think it was called Rambo. Possibly the worst naming decision ever made was Nintendo making a series of games called Zelda where that wasn't even the name of the character. This has confused the hell out of kids for 2 decades now!

Introducing Gamepad.

Gamepad is a free, open source project by me, Iain Lobb, with the aim of greatly simplifying keyboard input for Flash games. The idea was born out of 2 realisations – first, that since key.isDown was removed from ActionScript it has been more work for game developers to handle keyboard input, and second – that developers, me included, were not working with keyboard input at a sufficient level of abstraction. Trust me, if you make Flash games, you need this in your life. Update: I've had some feedback that it's hard to see the download button on Github, so please CLICK HERE TO DOWNLOAD if you prefer.



What does it do?

Gamepad simulates an analog joystick input using the keyboard. Many times when we access key presses, what we are really doing is pretending that WASD, the arrow keys or some other combination are actually a D-pad or joystick with an X and Y axis, and 1 or 2 fire buttons. Gamepad handles the event capture, maths and other details of this for you, so you only have to think about how you want your game to respond to this input. A detailed explanation follows, but why not just download the source code and play around?



A simple example

First we create a gamepad. It needs a reference to the stage so it can capture keyboard events, and it needs to know whether it is simulating a circular movement space, like a thumb-stick, or a square one, like a flight-stick. This argument is called “isCircle” I’ll get into this distinction later.

var gamepad:Gamepad = new Gamepad(stage, false);

Then in your update / enterFrame function, you simply adjust to the position of your character based on the “x” and “y” values of your gamepad. The “x” and “y” values are always between -1 and 1, so x = -1 would be mean the virtual D-pad is pushed all the way to the left, and x = 1 would mean it would be pushed all the way to the right. I have chosen to use y = -1 as up and y = 1 as down, so that it matches Flash’s screen coordinate system.

character.x += gamepad.x * 5;
character.y += gamepad.y * 5;

And to access the fire buttons, we simply look at the “isDown” property of the “fire1” button.

if (gamepad.fire1.isDown) fire();

That’s it! Your character will now happily walk around the screen using the arrow keys and fire when you press the CTRL key. As Gamepad also has easing by default, the character will also accelerate and decelerate smoothly!

The “isCircle” property

A common mistake that developers make in top-down perspective games, is to allow the player to move too fast diagonally. They say “If the up key is pressed, move up 5 pixels, and if the left key is pressed, move left 5 pixels, so if both are pressed move up 5 pixels and left 5 pixels”. This is wrong! Pythagoras tells us that the speed of their character would now be the square root of five squared plus five squared, which is the square root of fifty, which is about seven. So now their character moves 5 pixels per frame horizontally or vertically, but 7 pixels per frame diagonally. Disaster. Once you know this you can handle it yourself, but Gamepad makes it easy by giving you the isCircle option on creation. When you create your gamepad, simply pass in true for the second argument:

var gamepad:Gamepad = new Gamepad(stage, true);

Now the “nub” of the virtual joystick is limited to a circular area, meaning if you hold the “down” and “right” key together, it will report values of roughly x=0.7 and y= 0.7, instead of x=1 and x=1, and movement speed will be equal in all directions. Typically you would use this option is arena shooters and Zelda-style adventure games, and you may want to use it in scrolling shmups, but that’s a greyer area in terms of “realism”, as your vehicle is already supposed to be moving at a high velocity.

The “ease” property

By default, gamepad will give you a nice easing motion. One advantage it brings is that the player can “tap” the keys to achieve the effect of a half press on an analog input such as the XBOX 360 thumb-stick. Often, though, you won’t actually want to use this. You can easily turn it off by passing in 0, or pass in some other value for more/less responsiveness. Typically you’ll want easing activated for simple games, but in more complex simulations you handle acceleration elsewhere, so you may want it deactivated. To deactivate easing:
var gamepad:Gamepad = new Gamepad(stage, false, 0);

The “autoStep” property.

Gamepad needs to update at the same rate as your game, so that the easing, and the “downTicks” and “upTicks” properties (which I’ll cover later) always keep in sync with your game. If you are simply using Event.ENTER_FRAME for your update, you don’t need to do anything, as this is the default. However, if you have some other system, you should pass in false for the autoStep property and manually call the public “step()” method every time you update.

I advocate using a frame-based tick, and using the “fix your timestep” methodology if you need to stay in sync with real time. This way your game is deterministic, you will have far fewer inconsistencies with collision detection, and you can safely use basic Euler calculations for acceleration. However, I understand that some developers, and some game engines, such as Flixel, use a deltaTime based approach. If you are using a time-based approach, you should use the “fix your timestep” principle with gamepad, by calling the “step()” function an appropriate number of times each update, based on how much time has passed since the user started the game.

The GamepadInput class.

Each Gamepad instance has a set of GamepadInput objects that represent individual “buttons” on a virtual joypad. These are up, down, left, right, fire1 and fire2. However, these do not map one-to-one with keys on the keyboard – one GamepadInput can be linked to one, two or more keys, so that you can easily provide simultaneous alternate control schemes. The classic example would be having both WASD and the arrow keys control your character, so that players can use whichever scheme they prefer without having to set any menu options.

For setting up keys, GamepadInput has the “mapKey” function. It takes two arguments: “keyCode” – an integer representing the key, for which you should use the constants in the handy “com.cheezeworld.utils.KeyCode” class - and “replaceAll” which specifies whether to overwrite existing mappings. If you want to have multiple keys mapped to the same input, pass in false.

In many cases, you will never need to call the “mapKey” function, as there are presets for the most popular configurations in the Gamepad class. These are the functions “useArrows”, “useWASD”, “useIJKL”, and “useZQSD” (which is for the French “AZERTY” keyboard layout, where WASD doesn’t work). All of these methods take a “replaceExisting” argument which specifies whether you want duplicate mappings, as discussed earlier.

Unfortunately, the keys developers use for fire buttons don’t seem to be as standardised, but I have done my best, by providing the methods: “useChevrons”, “useGH”, “useZX”, “useXY” (for German QWERTZ keyboard) and “useControlSpace”. These are all taken from popular Flash games, for example Nitrome’s “Double Edged” which handles 2 players by giving one player WASD for movement and GH for attacking, and the other player arrow keys for movement and chevrons, “<” and” >” for attacking. Gampad’s default: Arrow keys, CONTROL and SPACEBAR should be fairly safe for all players, but there are many, many issues around international keyboards, so it may be advisable to allow the player to set their own keys.

Once you have your inputs set up, you can get information about their state: “isDown” simply tells you if a key is being held down, “isPressed” tells you if a key was pressed this frame/tick/update, and should be used instead of listening for KEY_DOWN events, “isReleased” tells you if the key was released this frame/tick/update, and should be used instead of the KEY_UP event, and “upTicks” and “downTicks” tell you how long the key has been held or released for. Basically, “isDown” is your go-to, but the others are there when you need more info. Generally, you should use the x and y properties of Gamepad for movement, but sometimes you may want to access the D-pad as “buttons” instead, for example using “up” for jump.

The GamepadMulitInput class.

There are also a further set of “buttons” represented by GamePadMultiInput objects. These are special as they aggregate the inputs of multiple other “buttons”. These are “upLeft”, “downLeft”, “upRight” and “downRight”, which let you treat these combined directions as if they were individual inputs on an 8-way controller, and “anyDirection”, which lets you know whether the player is pressing in any direction on the D-pad.

The angle, rotation and magnitude properties.

You may need these additional properties from time to time: “angle” gives you the direction in which the stick is pointed as radians, “rotation” is the same value but expressed in degrees and “magnitude” is the scalar distance of the “nub” from the origin, ignoring the angle. For example, if you set the rotation of a character MovieClip to negative the rotation property of your gamepad, your character will face in the right direction when they move!

The GamepadView class

If you want to visually see what your gamepad is doing, simply create an instance of the handy GamepadView class, and initialise it with a reference to your gamepad and optionally a colour.

var gamepadView:GamepadView = new GamepadView();
gamepadView.init(gamepad, 0xFF6600);
addChild(gamepadView);

GamePadTester and PlatformGamePadTester

In with the source code, you will find two visual “tester” classes. It’s not quite test-driven development, but these are the classes I use to ensure all the functionality of Gamepad is working – they’re also great documentation for Gamepad’s APIs, or could even be the starting point for your own game! If you’re using the Flash IDE simply open GamepadTester.fla or PlatformGamePadTester.fla and publish. If you’re using the Flex compiler you’ll need to create a new project and set the “always compile” / document class to com.iainlobb.gamepadtesters.GamePadTester.as or com.iainlobb.gamepadtesters.PlatformGamePadTester.as.

GamePadTester shows the basics of doing car-style movement and top-down character movement. It also demonstrates duplicate controls, with both WASD and IJKL controlling the character. PlatformGamePadTester shows the basics of a two player platform game, including variable height jumps (although in the end it transpired that these are mostly handled outside of the gamepad class). It also shows how you can create two instances of the same character class with different control schemes, without a single “if” statement or use of polymorphism. Composition FTW!



Final thoughts

Well done, you have made it through all the Gamepad documentation! Please start using it and submit feedback to my blog, or on github. I’ve had versions of this class kicking around for almost 2 years, but I had no idea how much work it would be to actually pull it all together, test and document it to a state where I was happy to release it as an open source project. I have insane new levels of respect for anyone else out there running an open source library. The license is MIT, which basically means you can do whatever you like with it, as long as you don’t blame me when it goes wrong. I’d appreciate it if you didn’t change the package names, and removing the copyright notice is forbidden. There’s a sweet gamepad logo that you can add to your game if you like, but it’s by no means compulsorily, and if you want to hit up the donate button on github, I’m not going to stop you. Enjoy!

Oh yeah, follow me on twitter: http://twitter.com/iainlobb

Start Repeating Yourself

On the latest Game Developers Radio is a great nugget of advice from Manuel Saint-Victor of infiniteunity3d.com, which is basically that you need to tweet / blog something 3 times before all the potential audience will actually see it. At first this seems like it might be annoying, but I decided to try it out, by repeatedly posting the youtube video of my Flash on the Beach Elevator Pitch from last year. The results were good. The first tweet took it from just 15 views to 29, then the next from 29 to 49. At this point some other people retweeted it, taking it up to 69, and it's still going up. That's 54 new viewers, when I had assumed that everyone who follows my output had already seen it, as I had already posted the Vimeo version here on my blog. (Update: a few hours later and it is up to 150 views). The crazy thing is that, even more people will watch it now after reading this post. And so far nobody has complained that I'm repeating myself annoyingly. One thing that you can't say enough though, is if you want people to respect you, *don't sell anything* - just educate and entertain. In my experience the rest will sort itself out.

http://www.youtube.com/watch?v=HUxAqjbmoic

I'm speaking at Flash on the Beach: Prepare for awesome!

Good news if you like Flash games and going to conferences: after the great response to my Elevator Pitch last year, I have earned a full speaking slot at this years Flash on the Beach! No session description yet, but my speaker bio is live, and I have a title: Zero to Game Designer in 60 minutes. Flash on the Beach is a great conference - I've been 3 times so far and loved pretty much every minute. See you in Brighton!

Creating Successful Flash Games (notes and slides)

Last night at The London Flash Developers and Designers Meetup Group I gave a talk called Creating Successful Flash Games. I think it was the most fun I've had doing a talk so far, and I've had some really lovely feedback:
"Great evening at South Bank Uni listening to Iain talk flash games. Always nice when you can tell the speaker is passionate about gaming."
"Great talk! It gets better and better. All I can say is thanks,
I learned a lot from your experiences. Also, you explain things really well, you empathize with the situation you are trying to explain. "
I love doing these speaking things so if you are organising a conference or user group I'd love to hear from you - hit me up at iainlobb@googlemail.com.

Anyway, as promised last night here my slides/notes. You can download them as a pdf or simply read them below. It's not the same without my jumping about and "acting" as one person described it, and a lot of the content I just did from memory, but there should still be something useful there. Anyway...

Design or Development?

Designers do graphics and developers do code?
But in games
  • artists do graphics
  • developers do code
  • designers make it fun!
So maybe we need a better definition.
  • Developers solve technical problems
  • Designers solve human problems.
So we all do a bit of both.

With experience and better tools, things move from the development side to the design side. Which makes the whole process more fun!
  • var sound:Sound = new ShotgunSound();
  • var transform:SoundTransform = new SoundTransform();
  • transform.volume = 0.5;
  • var channel:SoundChannel = sound.play(0, 1, transform);
Vs.
  • SoundManager.play(ShotgunSound, 0.5);
What are games?
  • Games are about the relationships between objects in space.
  • ... but videogames layer-on images, characters, narratives, sound and music.
  • Historically, most games are multiplayer (chess, football etc).
  • Videogames allow the computer to take on the role of opponent.
  • ... but multiplayer is still more fun!
Goals
  • Collect objects
  • Kill enemies
  • Reach locations
  • Match objects
  • Solve puzzles
  • Make friends (real or virtual)
  • Pwn noobs
  • Most games use a combination.
Constraints
  • Time limit
  • Health
  • Lives
  • Ammo
  • Money
  • XP / Experience
  • Inventory limit
  • Doors & Keys
  • Enemies, obstacles & puzzles
Modes of interaction
  • Control a single avatar
  • Command multiple agents
  • Manipulate objects
  • Match rhythms
  • Create entities
Input

Flash sucks at input!
Mouse
  • Left button, context menu, wheel.
  • sprite.mouseX and sprite.mouseY
  • No wrapping or moving the cursor.
Keyboard
  • KeyboardEvent.KEY_DOWN and KeyboardEvent.KEY_UP
  • Limited simultaneous presses.
  • CTRL, ALT and SHIFT are a no-go area!
Gamepad.as

Here I come to save the day!


Based on analog joystick input.
  • var gamepad:Gamepad = new Gamepad(stage, true);
  • character.x += gamepad.x * 5;
  • character.y += gamepad.y * 5;
  • if (gamepad. fire1) { fire() };
Use arrow keys, WASD or custom settings.
Duplicate keys and fire rate coming soon.

Mousepad.as
  • Coming soon...
  • For games where you move or aim with the mouse.
  • Similar abilities to Gamepad.as, but for mouse.
Top-down View

True top-down
  • Easy to rotate sprites.
  • Good for driving games etc.
Zelda-style
  • Art is drawn with false perspective.
  • Better for characters.
  • ... but you have to draw every angle.
Movement can be:
  • compass-direction (for characters)
  • or tank-style (for vehicles)
Side-on View
  • Great for showing humanoid characters.
  • Typically involves jumping around implausible vertical spaces called “platforms”.
  • Variable jumps.
  • Double-jumps.
  • In-air movement control.
  • “Brawler” view like Final Fight or Castle Crashers is somewhere between Top-down and Side-on.
Isometric View
  • Graphics are drawn from a fixed 45 degree angle.
  • Good for Sim games, puzzles and driving games.
  • Great for showing buildings – see eBoy.
  • Confusing for player movement – which way is left?
First person View

Either using a 3D engine or pre-rendered from a fixed perspective.
Great for shooting, exploration and puzzle games.

There are other views
  • Follow-cam (basically the same as first person)
  • 3rd person 3D camera (can track players)
  • etc
3D

All games are 3D.
  • A top down game where you can jump.
  • A parallax background behind a platform game.
  • So my new game engine is 100% 3D.
...but most aren’t.
  • Gravity means we live on a 2D plane.
  • We need a definite idea of up and down.
  • 2.5D works really well.
3D

3D is really hard, but the basics are easy:
  • var scaleRatio:Number = focalLength / (focalLength + z3d);
  • y = baseY + (( -z3d + y3d) * scaleRatio);
  • x = baseX + (( z3d + x3d) * scaleRatio);
  • scaleX = scaleY = scaleRatio;
Luckily libraries are available to make your life easier.
3D art is more labour intensive to create, but is much more flexible. Animation is harder still.
If you’re serious, consider switching to Unity3D.

Collision Detection

Built in
  • sprite.hitTestPoint()
  • sprite.hitTestObject()
  • bitmapData.hitTest()
Pythagoras
  • dx = sprite1.x – sprite2.x;
  • dy = sprite1.y – sprite2.y;
  • distance = Math.sqrt((dx*dx)+(dy*dy));
Bounding box (sorry conversion to HTML has broken this)
  • if (bottom1 <>
  • if (top1 > bottom2) return false;
  • if (right1 <>
  • if (left1 > right2) return false;
  • return(true);
More advanced:
  • Line-line
  • Line-grid
  • Line-circle
  • Point-grid
  • Circle-grid
  • Point-polygon
  • Polygon-polygon
  • And many more!
Physics

Gravity
  • speedY += gravity; y += speedY;
Bouncing
  • speedY *= -0.9;
Beyond that it gets really, really hard!

Luckily there are libraries to help you
Tile Grids

Present since the earliest games.
A neat simplification for games.
  • var gridX:int = sprite.x / tileSize;
  • var gridY:int = sprite.y / tileSize;
  • var grid:Array = [[“air”, ”air”, “trap”, “platform”], [“air”, “platform”, “air”, “air”]];
  • if (grid[gridX][gridY] == “trap”) {killPlayer()};
Helps with collision detection, path-finding, level design.
Powerful but restrictive.

Blitting

Working directly with image data rather than using the standard display list.
  • bitmapData.copyPixels()
  • bitmapData.draw()
  • Matrix transformations
  • “buffers”
  • graphics.beginBitmapFill()
  • graphics.drawTriangles()
  • Can be faster, but harder to do rotations etc
Libraries
Art

Flash is very flexible and can handle a range of styles.
  • Hand-drawn
  • Pixel-art
  • Cell-shaded cartoon
  • Painted
  • 3D rendered
  • Photographic
It normally doesn’t hurt to make your game look like a game though.

Animation

The best animation is done by hand.
Hand-draw frames and position manually.
Tweens are normally better off in code.
  • object.x += (target.x – object.x) * 0.3;
Tweening libraries save you many hours of work.
Tuning and polish
  • Weapon strength, time limits, enemy speed etc in easily modifiable variables or XML.
  • Jump height needs to match level design.
  • Particle effects, flashes, tints, screen shake
  • What happens when you walk into a wall? Do you slide, walk on the spot, flatten against it?
  • Good usability on U.I. – pictorial not text.
  • Freedom of movement, expressiveness, “feel”, playability
You need a hook
  • You need something which is unique to your game.
  • Hook, Unique Selling Point (USP), gimmick, or twist.
  • Character, weapon, unit type, mode of interaction, game mechanic.
  • Don’t just make a clone with different graphics.
  • If you’re going to copy something, work out what about it you’re actually trying copy.
Sound & Music

Can turn a good game into a great game.
Very clunky built-in support.

Fade-in/out, pause, mute, loop, etc:
For sound effects try:
Audacity, Sony Acid Music, Garage Band etc
Record your own!

Instructions
  • Players don’t want to read instructions.
  • Animation works better.
  • Walk-throughs or tutorials are even better.
  • Best of all is no instructions needed.
  • Keep the controls on screen all the time.
Saving

Really easy!
  • sharedObject = SharedObject.getLocal(“game");
  • sharedObject.data.score=9232;
  • sharedObject.flush();
Use “slots” to allow multiple saves.
Progress can also be saved to a server.
Or via level codes.

A.I.
  • Be pragmatic and come up with simple rules that work.
  • You’re not making chess computers here - don’t code the perfect enemy.
  • Enemies are generally slow and weaker than your player – even their bullets move slower!
  • A* path-finding etc is hard, but examples are out there.
Multiplayer

Easy to do 2 players on one computer.
Networked multiplayer adds a new level of fun but greater complexity.
Most solutions require you to have your own server:
But not all!
Turn-based and “deterministic” games require little or no server code.
Real-time games require some Java, JavaScript or C# code on the server.
Server-code may also be needed to stop cheating.
Multiplayer games are less common but command higher prices as they encourage repeat plays.

Business Models

Sponsorship.
  • Portals pay to add their branding to your game and add links back to their site.
  • Exclusive or non-exclusive licenses.
  • “Site locks”
  • Performance deals.
  • £100 – £10,000 per game.
  • http://www.flashgamelicense.com/
Advertising.
Sales.
Client briefs.
  • They pay you money and you make what they tell you to.
  • Steady income but less creative.
  • No chance of getting rich.
  • Can still be cool: e.g. Zwok!, Meta4orce.
  • £1000-£100,000
Thanks!
Double Edged - Nitrome - Play Free Games
Play Don't Look Back, a free online game on Kongregate
Fancy Pants Adventures | Armor Games
Play Boxhead: The Zombie Wars, a free online game on Kongregate
Xeno Tactic - to play free online games
STACKOPOLIS :"The most addictive game since Tetris!"- LCLFC
---===+==O[ Two KingdomS ]O==+===---
BBC - Switch Meta4orce - Launch
Escape game - Flash game
BBC - Switch Meta4orce - Launch
Play Red Remover, a free online game on Kongregate
Shaun the Sheep - Games - Home Sheep Home
Muzer's Blog
Car Drive On Terrain « Muzer's Blog
CANABALT
Play Pop Pirates, a free online game on Kongregate
Twin Shot 2 - Nitrome - Play Free Games

Game Developers Radio podcast - Flash game design special (with me!)

I was recently on a special 2 hour edition of The Game Developers Radio podcast with host Joseph Burchett, Ryan Henson Creighton of Untold Entertainment, Daniel Cook of Lost Garden and indie developer Edmund McMillen. It was a great laugh to record and has some great pointers about making Flash games too - I learnt a lot recording it, hope you get just as much from listening, so listen here.