Posts

Showing posts with the label flash

Learn Flash Games Development in Cornwall


A few months ago I had the crazy idea that it might be fun to teach an evening course about Flash games, here in Cornwall. Thanks to the awesome people at Truro college, it's happening - and it's starting just 2 weeks from now, on Tuesday the 20th of September 2011. The really great part is that thanks to the magic of government subsidies, the whole 10 week course is just £75 . What, £75 for the whole thing? That's AMAZING VALUE!!! So if you live in Cornwall (or Devon) and want to learn some ActionScript3 programming to make your own computer games - go sign-up.

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!

The Flash community needs a complete reboot

This is a cross-post from my Google Plus account. Join in the original discussion on there.

The Flash community needs a complete reboot. From Seb Lee-Delisle to Keith Peters to Jesse Freeman to Ricardo Cabello (mrdoob) many of the most well know Flash developers have either branched out to new technologies, or abandoned Flash completely. While I wish these guys all the best, this obviously has quite a negative effect on the Flash community. For young developers looking on, it must surely seem that Flash is dying, and anyone with any sense is jumping ship for the gold-paved streets of iOS or HTML5. And at the same time, the link-baiting tech tabloids are publishing more and more negative stories about the "obsolete" technology Flash, largely unchallenged by Adobe's former poster boys. Flash is surely dying.

But of course this isn't true. For many applications, such as casual/social games, media players and online advertising, Flash is still the dominant force. And the good news for Adobe is that new talent is entering the Flash world all the time. There has never been a better time to start-up as a game developer, and Flash can claim many of the hottest developers such as Zynga, Vlambeer and Bezerk Studios amongst its users. And while WebGL is having its moment in the sun right now, the bigger reach of Flash Stage3D will surely steal the browser 3D crown when Flash Player 11 is finally released.

What can Adobe do to fix the perception problem? Well for a start they need to reach out and embrace the new generation of Flash users. Why aren't framework developers like Adam (Atomic) Saltsman or Chevy Ray Johnston invited to talk at MAX? They are doing way more for Flash than an old guard who have clearly lost the faith.

The other thing Adobe need to do is start supporting the amazing open-source Flash community with some hard cash. Flash Develop, Away3D, Box2D, TweenMax, Flixel, FlashPunk and many more fine projects all deserve some financial support from the mothership. The Flash open-source community is strong, but how much more could it achieve with the resources it deserves?

Flash game development book ideas

I've been mulling over the idea of writing some kind of book or eBook in the future. Rather than being a set of example games like most Flash games books seem to be, it would arm you with the techniques to create your own games, so when you are stuck on a specific topic it is quick to look up.

The book would be almost completely source-code based (with plenty of comments). There would be almost no "waffle" sections of description. It would be more of a look-up (or copy-paste!) technique reference than a traditional "blah-blah-blah" book. Due to this format I think it would be better as an ebook than a dead-tree book. What do you guys think about that?

Anyway, here are my topic ideas. Could you please let me know if there's anything that should or shouldn't be in there?

Input
- Keyboard input and control (from scratch and using Gamepad library)
- Mouse input and control

View
- Top down (+2D Camera)
- Side-on (+parallax)
- Zelda style (+Depth sorting)
- 3D third person (using Away3D)
- 3D first person (using Away3D)
- Mini-map / radar

Rendering
- Blitting
- Using DisplayObjects efficiently

Maths
- Useful maths
- Vector maths

Security
- Site-locking a game

Game engine
- Time steps (basic, deltaTime, fix your timestep)
- Game loop (and pausing)
- Entity systems (inheritance-based, and component-based)
- Object pooling

Collision detection and Reaction
- Circle-circle
- Square-square
- Square-circle
- Line-line
- Line-square
- Line-circle
- Separating axis
- Using hitTestPoint
- Using bitmapdata getPixel
- Using bitmapdata hitTest
- Collision reaction for platform games (player and projectile)
- Collision reaction for top-down games (player and projectile)

Physics
- Top-down car physics
- Platform physics
- Projectile physics
- Using a 3rd party physics engine (Nape)

Environments
- Tile-based techniques
- Using Flash as a level editor - parsing etc
- Creating an in-game level-editor.
- Procedural level generation

Animation
- Bones animation
- MovieClip animations
- Creating your own simple tweening system (+ easing, springs)
- Using a 3rd party tweening engine in-game (TweenMax)
- Sprites sheet / image sequence animations

Audio
- Creating a reusable sound manager
- playing sounds and music
- mute button / volume controls

Gameplay
- Scoring, achievements and saving your game.
- RPG characters - inventory, stats, health, buffs/debuffs.
- Weapon management

User Interface
- HUD
- level select menu
- Main menu
- Shop

Away3D 3.6 Essentials – Book Review

Ok, so here’s a book I definitely can recommend! ;-) Away3D 3.6 Essentials by Matthew Casperson (published by Packt) is a really great introduction to creating 3D content in Flash with the free and open source Away3D library.



For a brief time in the summer of 2008 I was the golden-boy of Flash 3D after my team at Bloc launched the Papervision-powered game/transmedia experiential play-node called Meta4orce, which I documented to launch my new blog. While my experience and high google ranking for the term “papervision developer” (#2 – boom!) earned me a couple more PV3D gigs, it all tailed off by the end of 2009. The fact that the Papervision3D team pretty-much abandoned development and moved on to new projects didn’t help, but there was also a sense that the novelty of 3D Flash content was wearing off (especially with such jaw-dropping competition as Unity3D’s island demo).

But 3D Flash content was not in fact dead, and the Away3D engine very ably filled the gap left by the demise of Papervision. I never kept up with developments in the Away3D world, so this book was a great re-introduction. So what I have I learned? Well one nice thing to see is that many of the techniques I had to manually create in my Papervision3D work are actually integrated into the Away3D engine itself. This includes things like:
  • level-of-detail (LOD) model-swapping, so that when objects are far away they use a simpler mesh.
  • flat sprites and multi-directional sprites like you see in Doom and Duke Nukem 3D.
  • splitting objects into individual layers and display objects, to solve triangle-sorting issues when a model sits on top of the ground.
  • skyboxes.
  • isometric camera.
  • depth of field effects using sequences of sprites at different levels of blur.
Matthew’s book gives a good explanation of the theory behind these techniques (and many more – the book is incredibly thorough and comprehensive), as well as how to apply them using Away3D. I also learned a bit of general 3D theory about things like UV mapping, triangle Z-sorting and effects like normal mapping and bump mapping. On the whole, though, this book is very much a practical manual of how to use each of Away3D’s features. If I have any criticism, it is that there’s not too much there that you couldn’t get through scouring the documentation and source code, and it doesn’t ever pulled together all the strands to make one amazing demo at the end. That’s up you to go off and do yourself I guess. One really nice addition is that this book does document Away3D’s bugs and offers work-arounds, which could well prevent you from pulling your hair out a few times.

Reading Away3D 3.6 Essentials has really re-opened my interest in Flash 3D, and I think I’m going to do a few experiments with Away3D in its current form, so that when the hardware accelerated magic of Stage3D and Away3D v4 hit Flash, I’m not playing catch-up.

Is Flash Cool?

Fab Five Freddie told me everybody’s fly,
DJ’s Spinning, I said “My! my!”,
Flash is fast, Flash is cool.
- Blondie
A couple of days ago I saw a really great bit of Flash work – Magnum Pleasure Hunt which was flying around twitter. It’s a really fun (silly) bit of interactive media combining gaming, video and animation in a seamless way that only Flash can do on the web at the moment. It’s a classic theFWA-style Flash site. A couple of years ago I used to check these kinds of sites out all the time. Now, not so much. Why is that? Is it just me reaching a jaded, “I’ve seen it all” phase? Or has the world moved on? Is Flash still cool?

So I turned to you guys on twitter and asked the simple question #isflashcool? (and give it a score out of 10 to be scientific)/ Here are your thoughts...

For many respondents, Flash developers themselves are the thing that keeps Flash cool:

Kyle Rodgers offered the pragmatic “8/10 - It's still far more capable than the alternatives (except unity) and filled with hilariously talented people”. James Whiteley: "Flash is 10/10 cool. The coolest people I know are flashers!" François Gillet: "Flash is cool because I use it and I'm the coolest guy in the world!"

For others, technology is irrelevant. Dan Stubbs: "Doing anything more creative than veging on a sofa, eating food from a packet & watching X-Factor is cool". One repsondant has never really got over his first love, Adam Montandon: "Is director cool? It's had 3d and physics for years!(wipes tear from eye)".

For some, Flash needs to work a bit harder to move with the times, and keep up with the competition. Miguel Arias: "I would say 7/10, it still has its space but needs to adapt to this new era." Simon Rohrbach: "Flash is an brilliant piece of technology, but its era is over. 0/10, but I'll give it a 1/10 because it ruled my childhood." Dan Rogers: "I'd give it 5/10, because it still has a place, but coolness is dropping."Mark Grossnickle: "7/10. Flash Needs to perform better on mobile. Future is promising with Molehill". Squize: "I think Clint Eastwood is cool, I think Flash is a means to an end and whose star is waning due to real competition". joseeight: "#IsFlashCool - it used to be 5 years ago; #IsHTML5cool - yes, it's the shizzle"

Although my twitter followers skew heavily towards Flash developers, there were still a fair share of detractors. Jon Gold: "Flash is as cool as Coldplay. 0/10". And we also had some jokers in there, like graham milton: "Flash is [THIS_CONTENT_REQUIRES_FLASH_PLUG-IN] cool".

Some rejected the premise of the question: Paulo Fierro: "I'm with @cspelsor. the tools don't matter, its what you do with them". Grant Garrett "It's ALL about how you use your tool!"

For some, the word “cool” was a bit of a stumbling block. Martin Darby: "Is this not a bit like saying are chisels cool?-Well if you want to carve wood yes. If you want to bake a cake, no." Matt Pearson: "Skateboarding = cool. Swearing = cool. Snorting drugs offa Angelina Jolie's back = cool. Can Flash do these? No." Chris Pelsor: "Wow, nice to see Twitter has made that final digression back to high school... it's called getting old. You reach a point where what's cool is your kid getting excited that they flew a kite for the first time."

But anyone who knows me, will know that I’m not really interested in “cool” in the sense of Ugg Boots or Ray Bans – I’m talking about cool in the intangible sense that The Millennium Falcon is cool, or doing a good deed is cool, or yes, flying a kite with your kid is cool. You look at it and say “cool!” But it terms of the highschool meaning of cool, many people noticed that Flash didn’t have the best public perception right now. Mark Burvill: "I'd give it 1/10 right now. But that's kinda why I love it more than ever. Being cool usually means you're a dick."

Richard Lord seemed to pinpoint the indefinable concept of cool the best, so I'll let him have the last word:

Flash is not cool, and hasn't been for some time (5/10). But it gets stuff done, which is more important. Boringly, iOS is still cool. Unity is cool. Kinect is cool. Scala is cool. On the other hand, Flash, C#, jQuery, XNA are not cool, despite being very good at what they do. I don't equate cool with useful, effective or high quality, which are more important in the tools I use. Don't chase the cool, build the cool.
I can't say it better than that!

Podcast Episode 4 - Flash Special (plus WebGL and Unity3D)



Flash is undead. It has been killed many times already - first by Ajax, then by Silverlight, then by web standards, then by Steve Jobs, then by HTML5 - and yet it moves! Watch in horror as this bloated, rotting zombie terrorizes the internet and Iain and Seb scramble to to find a cure before it is too late. Which is to say, go listen to the latest podcast.

Podcast Episode 3 - Molehill and Processing with Jer Thorp



The unstoppable juggernaut that is The Creative Coding Podcast continues on its inevitable rampage of destruction, this week flattening Molehill and making mince meat out of Processing. Special guest Jer Thorp jumps on board to crush those who would oppose us. Listen now!

Hackathon contest winners announced!


A while back I announced a Flash game contest I was helping to judge, and gave away some source code to get you started. Over 500 people downloaded the source code - however not one of those people managed to enter the contest! No matter though - six intrepid developers did get their games finished and in front of the judges eyeballs. Head over to Mark's blog to find out who won and play the games. If you didn't win - don't worry, there was something to like about all the games, and all entrants get a copy of FDT.

Podcast Episode 2 - iOS, Android, Windows Phone 7 and more!



Me and Seb are back with another episode of The Creative Coding Podcast. This time it's a mobile devices special, with iOS, Android and Windows Phone 7 under the spotlight. For your aural pleasure: The Creative Coding Podcast - Episode 2. Enjoy!

Molehill + Scaleform = hardware accelerated 2D in Flash?

This post is pretty much an open letter to Adobe, so if you know anyone who works there, please send it to them. I've had what I think is quite an interesting idea, and I think it's one that Adobe should have a long think about. The Flash player is about to add hardware accelerated 3D rendering with "molehill". The demos that have been released so far look great - amazing 3D scenes rendered with no impact on the CPU. All the rendering is handled by the GPU, leaving the CPU free to process your game logic, including physics, collision detection and AI - which allows for more advanced gameplay (and stops Flash-haters fixating on how much of their precious CPU the "bloated" Flash plug-in is consuming).

However, this will only apply to 3D games. In fact 2D games - which we must not forget are what has made Flash the number 1 gaming platform on the web - will see no benefit from this release. What's the message from Adobe here? That 3D is the future of gaming - 2D is not important, or at least 2D games already have good enough performance. But when you consider that native 2D iPhone and Android games have similar (if not better) performance than 2D Flash games on much inferior hardware, you can see there is plainly massive room for improvement. Now look at the iPhone and Android appstores, where there is a genuine choice between 2D and 3D games. The charts are dominated by 2D games like Angry Birds, showing that 2D is still the dominant style for casual games.

Ok, so what can we as game developers do about it? Well, we could make all our 2D games using bitmaps rendered on 3D planes, and so leverage the GPU rendering of "molehill". Now our CPU is free for game logic. But what have we lost? Well for starters the display list with it's powerful nesting features, filters, textfields, use of the Flash pro IDE for layout. In short everything that makes Flash what it is.

So what can Adobe do about it? Well, there already exists a technology called Scaleform that renders the Flash vector engine using GPU accelerated 3D by tessellating 2D graphics - effectively turning them into flat meshes of 3D polygons that the GPU is designed to render fast. This technology is used to make 2D user interfaces for console and PC games. Now, I'm no expert in scaleform or graphics hardware, but it seems to me that this technology or something very like it could feasibly be integrated into the Flash player, meaning whole Flash scenes and timelines could be rendered largely on the GPU. This would keep the Flash pro IDE as a relevant product, and take Flash beyond being the most popular platform for 2D games, to being the best platform for 2D games.

In 2008, along with many other developers, I asked Adobe for joypad support in Flash. At MAX last year, Adobe finally announced their plan to add this feature. I'm just as certain that I'm right that Flash needs hardware accelerated 2D.

This video shows how much power the GPU brings to Flash - wouldn't it be awesome to have that much power in our 2D games? Comments / reasons why I'm barking up the wrong tree are greatly appreciated! :)

Web games, HTML5 and Jangaroo on The Creative Coding Podcast



Me and Seb had nothing better to do at the weekend, so we had a chat about web games, HTML5 and Jangaroo, and we're releasing it as a podcast - hopefully the first of many to come! So here it is, The Creative Coding Podcast - Episode 1. Enjoy!

Free Flash game source code! Win Adobe Master Collection!



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

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

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

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

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

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

BunnyLandMark - a new Flash game benchmark



I learned a lot about Flash rendering with my BunnyMark benchmark, but I felt it was missing a few vital features that would make it a true test of game-specific performance. So I've come up with a brand new test: BunnyLandMark! Once again I created a version using display list Bitmaps, and a version using copyPixels blitting. Here are the new features:
  • a large scrolling world - about 4000x4000 pixels. I chose this size as it is roughly the biggest bitmap you can make in Flash player 10. With a bit more work it is possible to make infinitely large worlds, but this size was big enough for my purposes.
  • Perspective depth-sorting. Bunnies that are further into the scene are sorted to appear behind those that are closer to the viewer.
  • More bunnies - as off-screen bunnies don't need to be drawn, the total number of bunnies can be increased.
And here are the results (INSTRUCTIONS: use ARROW KEYS or WASD to scroll!)
  • The blitting demo can handle 90,000 total bunnies at 30fps, with about 1,900 on-screen bunnies at a time. Blitting was ridiculously fast! That's definitely more bunnies than you require! Depth sorting using blitting is definitely more efficient. Don't forget to scroll with the arrow keys.
  • The display list demo can handle 22,000 total bunnies at 30fps, with about 450 on-screen bunnies at a time. So, in this case blitting is about 4 times faster than the display list, versus only about twice as fast on the previous test.
So here's my conclusion: depth sorting on the display list is pretty slow. In fact, before I came up with some optimisations, it was much, much slower and I couldn't even handle 2,000 total bunnies at 30fps. In my first iteration I used setChildIndex to order the display objects, ignoring those that are offscreen. But when you think about thousands of bunnies slopping about in the display list, you can guess that this was incredibly slow. I don't know how the display list works behind the scenes, but it doesn't like you changing depths. The trick I came up with was to loop through and removeChild every bunny, and addChild back only the ones I need on screen. This meant my displayList was much shorter and so all my display list operations were much faster. I still think 450 on-screen, depth-sorted entities at a time is going to be plenty for most games, but I can definitely imagine a few scenarios where it wouldn't be enough.

Ok, over to you now readers! Please test and report any differences in frame rate you get. I'm particularly interested to see if Mac Safari performs as woefully on this display demo as it did on the last. I have updated the source zip to contain all the bunny demos.

Display list vs. blitting - the results!



To get some actual evidence for my opinions on the joys of the Flash display list, I created two demos that I'm calling "BunnyMark", a test of rendering small bouncing bunny pngs with alpha transparency. Since first posting, lots of readers helped by testing on different browsers and operating systems, and I have updated this post with their results.

The results were quite interesting, and not quite what I expected. Blitting was really fast, although actually a little bit slower than I expected, but gave a consistent rendering speed across all platforms. Bitmaps were also pretty fast, although in Safari on Mac performed really badly. I emailed Tinic from the Flash player team about this issue, and he has said he will look into it. Ok so here are the results:
  • The display list demo could render 4000 bunnies at 30 fps on my PC without slowing down. This was replicated by readers on all Mac and Windows browsers except for Mac Safari, where it was down to 10-20 fps. Based on this interesting blog post from Tinic Uro (suggested by Richard Leggett), this seems like it may be something to do with the recent adoption of the Core Animation APIs in Safari. The demos has a lot more layers stacked up than you would need for most games, so this performance drop is unlikely to affect a real game - although I will be following up with a new benchmark to test that hypothesis. Bitmaps faired very badly on Android - it couldn't even render 10 bunnies at 30fps.
  • The blitting demo could render 6000 bunnies at 30 fps without slowing down on my PC, and people with faster machines have reported up to 11000 bunnies at 30 fps. Blitting was also much more effective on Android, where it got up to 600 bunnies at 30 fps, certainly enough performance for an arcade-style game. (Thanks to Philippe Elsass for the Android tests).
So in this example, blitting is about twice as fast. But as I hope you can see, realistically 3000 bunnies is still a lot more than you are going to need in most situations. You can download the source code and see if you can improve the performance of either demo. A couple of readers have recommended performance optimisations, for example suggesting I use a fixed-length vector and using lock() and unlock() on my bitmapData, but neither strategy noticeably improved performance on my machine.

I also wondered whether switching the wmode in the HTML can fix the Safari issues - it doesn't. If you want to try them: Opaque, Transparent, Direct, GPU (both Direct and GPU give 5 fps in Chrome on Windows!). This post from way back in 2008 may possibly shed some light on this topic:
"Just because the Flash Player is using the video card for rendering does not mean it will be faster. In the majority of cases your content will become slower." - Tinic Uro
Just a final note - I ran a similar test to this 2 years ago in Microsoft XNA and was able to get something like 50,000 bunnies going at HD resolution, and 60 fps. I think molehill is going to make this discussion somewhat irrelevant next year - GPU blitting will annihilate both of these approaches. The question will then be, can the display list also be speeded up by the GPU, or is it just too wacky and different to what graphics cards are designed to handle?

In defense of MovieClips, Sprites and the display list (...the case against blitting?)



“This is why I always run a raster pipeline. The DisplayObject API is a trick played on the gullible and the trusting…” — @bengarney
Ben Garney is a very smart game/engine developer with a background in C++ and known for developing the Torque engine, who has now moved into the Flash world with Pushbutton Engine and games like Social City. I come from the complete opposite direction. I’m a Flash guy with a background in quick turn-around, design driven creative Flash projects, who now focuses on game development. This difference in backgrounds, and dare I say *ideologies* is why I thought I should write a response to Ben’s recent post about blitting, and stick up for the display list a bit. If you haven’t read Ben’s article, I suggest you go do that, but for the sake of clarification, blitting is basically using copyPixels to manually draw your graphics to a single bitmap data object that you display via a single Bitmap object on the stage.

Firstly, there is a lot of truth in what Ben says. Here are the advantages I see for blitting:
  1. Renders faster if you have thousands of sprites.
  2. Although Ben didn't mention this, if you use the Flixel, Flashpunk or Pushbutton engines you get some other game engine functionality for free, although most of the benefits of e.g. Flixel are nothing to do with the fact that it uses blitting.
  3. Erm...
Now here are the advantages for using MovieClips, Sprites and Bitmaps in the native Flash display list:
  1. You get rotation, scaling, alpha, filters and colour effects for free. Want to add a glow or blur to something? It’s one line of code, and adds no filesize to your app. If you use blitting you have to somehow prerender all these effects, either as pngs that will increase the filesize of your game, or prerender at runtime, which will add a lot of complexity to your code and add to your development time, and in the cutthroat world of Flash games, time is money. If you combine the display list’s built in effects with an engine like TweenMax, you can make amazing animated effects in just a few lines of code.
  2. You can work easily with interactive designers. Most creative agencies have designers who are experts at using the Flash IDE to create beautiful layouts and animations that you can easily breathe life into with ActionScript. If you are working from flat PSDs for all your assets, you will spend a lot of time laying screens out in code, which is something you never really want to do. The reason Flixel etc are never used on advergames, e-learning games or other client projects is that there is no workflow for designers to add their branding magic.
  3. You get mouse events. You can easily create buttons and more complex interactive elements with complex hit areas. Now in a game it is very possible to use blitting on your gameplay area but still use the display list for all menus/gui, and I would definitely recommend this option over blitting *everything* like Flixel does. However, sometimes you want to have interactive menus and buttons inside the gameplay area, in which case it will be much easier for you to use the display list in your game rather than recreate all that functionality from scratch inside your blitted area.
  4. You can nest things inside other things. This is very useful for things like menus, but is also very a great way to create dynamic animations that can be altered at runtime. For example, if you have an animated character holding a weapon, if the weapon is a sprite inside the character sprite, you can easily swap out the contents of the weapon sprite to change weapons. If you are using blitting, this feature will be time consuming to recreate.
  5. It’s not as slow as people think. If you are just moving Bitmap objects around in the display list you will easily be able to have hundreds of sprites on screen, in a typical game. And as only displayObjects within the viewable stage area are drawn, you can actually have a game play area with thousands of sprites, so long as you can only view hundreds at a time. Turning off mouse interaction for the display objects (mouseChildren = false, mouseEnabled = false) makes everything run significantly faster too. I have a demo with 40,000 tiles scrolling on the display list smoothly at 120fps – as Flash only renders those tiles inside the viewable area of the stage. You can also use a hybrid blitting / display list approach by having a Bitmap objects on the display list which you animate by changing the value of the bitmap.bitmapData property. This is very fast and you still get all the advantages of the display list effects. The best of both worlds!
So ultimately it becomes a question of how much rendering speed ya needs versus how much development time ya gots (read that last sentence in the style of the Clint Eastwood). From what Ben says about Social City, it looks like a poster child for blitting – it’s a scene with thousands of sprites drawn at once (although Ben’s claim that his display list tests were running at less than 1 frame per second suggests to me that he had not correctly optimised by turning off mouse interaction). Either way, display list *will* always render slower for a thousand sprites. But pretty much every Flixel game I have seen would have run perfectly using the display list. Ben says that the display list is the darkside of the force. In equally mischievous tone, I propose that blitting is for people who don’t actually like Flash, and they see everything that makes it unique and interesting, like the excellent Flash IDE and the vector display list renderer, as a negative. I will get some benchmark demos of both approaches up soon. Of course display list will lose, but it won't be as bad as people think. Comments appreciated!

AdvancED Game Design with Flash – Book Review

Lovely, lovely Friends of ED were kind enough to send me a copy of AdvancED Game Design with Flash by Rex Van Der Spuy. Just because they gave me free stuff, it doesn’t mean I’m going to give this book an easy ride though! This book has lots of good things and a few not so good things, as I will describe.

Let’s start by getting one thing out of the way – this book has almost nothing to do with game design. There is no mention of game design (as I understand the term) until Chapter 7, where Rex gives a few pages of good advice. The other 700 or so pages of the book are about game programming/development/architecture. (To be clear, my understanding of "game design" is: deciding what happens in your game and tuning the game mechanics to make them fun).

The best thing about this book is that it is very comprehensive, covering pretty much every hurdle you will meet when building a Flash game, including an extensive looks at collision detection, which is probably one of the hardest parts of game development if you aren’t using an engine like Unity3D, Box2D or Flixel. There is an explanation of many alternative methods such as bitmap collisions (including destructible bitmaps!), axis-aligned bounding box (AABB), circle, line and “separating axis theorem” for more complex shapes. It also shows you how to do “spatial hashing” which is a “broad-phase” technique for reducing the number of collision checks you need to do, which is very useful. Unfortunately it doesn’t include the “quad-tree” technique, which is the one I need to get my head around at the moment.

Another section you may find useful is the analysis of blitting. I think the benefits of blitting are a bit exaggerated, but this book takes a very even-handed approach, explaining when they will be useful and when they won’t. It also includes some benchmarks and shows you how to make your own, which you should ALWAYS do if you are making “optimisations”. Don’t believe a word that Rex, myself or anyone else tells you about optimisation without testing it yourself!

I’m not a huge fan of how the author organises his code. He’s gone for an MVC approach throughout the book, and even though this is a road I’ve been down myself many times, it’s not one that I would currently recommend (for the record, I favour a game object composition approach like you get in Unity3D). In general the code style is decent, with well named variables and plenty of comments. There are some places where the code could have been made both faster and more readable by greater type safety and less use of the dynamic properties on objects, movieclips and arrays. There are some places where variables are not well-named, for example calling a function “ln()” rather than “leftNormal()”. In the age of auto-completion there is really no need for abbreviated function names, but this book is by a long way not the only place you will find them.

Here is my most major criticism the book: for physics/movement Rex is using his own vector and “verlet” techniques, and I am dubious about both. I’m not an expert on integrators, but I’m very skeptical that Rex’s approach really is verlet at all. It seems to me that he’s using the standard Euler technique that most Flash developers use, but just storing his data in a different way. I would love to be wrong about this one, so if anyone has read the book and has a good understanding of verlet, please leave a comment. The vector class the book uses is also non-standard. The usual implementation of a vector has just an x and y position, and some methods to manipulate it such as add, multiply, divide, rotate, dot-product etc. The book’s vector class has these methods, but it stores two sets of x and y values – a start point and an end point. It all still works fine, it’s just not how it’s normally done.

On points like this I find it very difficult to draw the line between what is just differences in style and what would be considered “best practice”. As I already knew most of the information covered in the book it’s easy for me to worry too much about things I just do a bit differently. If you have never used these techniques, any implementation will be very useful to know. Ultimately, if it gets the job done, then it’s fine, and Rex’s implementation definitely gets the job done.

Some other useful explanations in the book include playing sounds, pathfinding (including a really good explanation of A*) and a full tile-based platform game engine. After my talk at Flash on the beach I had many requests for my source code, but as all my demos were built on my non-open-source game engine, I couldn’t share them. I would happily recommend this book to any of those people as it includes the vast majority of the code you need to make any of the demos I showed, including driving games and platform games.

Overall, I think that if want to do some more advanced Flash games and you don’t know where to start, this book would be a great place.


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!

Thoughts on re-skinning games

I just received an email from a Flash developer who reads my blog and wanted some advice about creating a pinball game. He wrote that he doesn't have much experience making games, and he's been given a really tight deadline, so should he try and find an existing game to reskin, or should he develop the game from scratch? So reader, this is my advice:
  • Firstly, don't even think about grabbing a game from a portal and decompiling it. It's immoral and it's illegal.
  • One idea might be to go to http://www.flashgamelicense.com/ or https://www.mochimedia.com/ and search for pinball games. You can then contact the developers and ask them if they'd like to reskin their game for you or supply the source files so you can do it yourself. This option may actually work out much more profitable than developing the game yourself.
  • If you do a google search for "flash game source code" you will find there are many companies selling source code for Flash games, often at really low prices, and you may be able to find a pinball game somewhere in there.
  • Finally, if you do decide to code the game yourself, your best option might be to try http://www.box2dflash.org/ - this physics engine will handle all of the hard maths and physics you would need to do a pinball game - you would just need to learn the API and hook up the graphics.
Bye!



Indie Flash Games 101

My buddy Adam, who has just started teaching interactive media at university in Denmark, emailed me some questions about how to get his students started with publishing their own indie Flash games. These days I can't write anything without making it into a blog post, so here's my getting started guide:

What technical issues should students be aware of?
- You need both a copy of Flash Professional (CS3, 4, or 5) AND a code editor. If you are on Windows download FlashDevelop - it's free. Otherwise try FDT, InteliJ IDEa or FlashBuilder, which all have free/cheap options for students/beginners.
- Use ActionScript3, Flash player 9 or 10.
-If you are confident with programming and want to make more advanced games in a short space of time, consider using Flixel or Box2D.
- Filesize should be less than 8MB
- Dimensions should be width: 400-720 pixels, height: 300-600 pixels.
- Game should be a single self-contained swf file.

What are the top sites to submit a game to, and how can they judge how good their game is?
- Kongregate - Signs of success: score 2.8 or higher on the user rating, get more than 500 plays, get some positive comments. Kongregate audience are very particular and are much more forgiving to long form fantasy RPG type games than other genres. Expect mini-games to get a roasting / be ignored. Getting featured on the front page or winning any weekly contests very unlikely for a beginner. Game can include Mochiads, which Kong will automatically disable, and instead give you nice share of their ad revenue.
- Newgrounds - Signs of success: score 3.2 or higher on the user rating, get more than 1000 plays, get some positive comments. Newground audience are lovable scamps with an open mind about any type of game. Front page feature unlikely but getting featured on any page or finishing in the daily/weekly top games is something to aim for. Game can include Mochiads.
- FlashGameLicense - in the current FGL market, beginner and mini-games are unlikely to sell at all, but it's still worth investigating this site.
- Add the Mochi analytics APIs, (and mochi ads obviously) and submit to Mochi distribution to see how a game does virally. Signs of success: 5000 plays, large number of sites featuring game.
- More portals can be found on this handy list.

What should students aspire to?
- Front page of Digg.com
- featured on mainstream games blog e.g. Kotaku.
- featured in print publication e.g. Edge, .net
- Front page on Newgrounds or Kongregate
- Millions of plays across various sites
- attract sponsorship from big name e.g. ArmorGames, Kongregate
- players produce fan art

Hope this is useful to someone. Remember not to take the negative criticism from comments too personally. Learn from it and move on to your next game!