Friday, August 13, 2010

Closing a Flash Android App

I've just finished my first complete build of a Flash Game App for Android and I thought I'd share some code.

It's the little things that'll stump you, like figuring how to quit the app. So many apps make you use the HOME key and then the app continues running in the background. That's really frustrating. Use this line of code to kill your app:

NativeApplication.nativeApplication.exit();

And you'll need this import statement in your document class:

import flash.desktop.NativeApplication;

Another good thing to know is how to access the MENU, HOME and SEARCH keys. To do this, add a keyListener for a keyboard event:

stage.addEventListener(KeyboardEvent.KEY_UP,keyUpListener);

...then:

function keyUpListener(e:KeyboardEvent):void {
if( e.keyCode == Keyboard.MENU ){ }
if( e.keyCode == Keyboard.HOME ){ }
if( e.keyCode == Keyboard.SEARCH ){ }
}

Don't forget to add this to your document class: import flash.ui.Keyboard;

Simples! A few lines to code to help you with your Flash App for Android.

Remember to support Android - Android loves Flash, unlike the iPhone.

Saturday, July 31, 2010

Android

What I'm currently working on is getting some of my games packaged as Android apps. Mainly since I bought an Android phone (HTC Desire), I love it and I want to support Google's efforts in making it easy for anyone to make games and get them out to people who want to play them.

I'm pretty excited about it and I hope to post my progress here.

Sunday, July 25, 2010

What makes Red Dead Redemption a great game?


I'm about halfway through playing Red Dead Redemption on the 360, and I wanted to jot a few thoughts about what makes it a great game.



1 Immersion


Immersion is one of the most important aspects of game design. RDR stands out as the most immersive game that I have ever played. It nails the look and feel of the Old West. The language, the clothes, even the way people walk and react. It feels alive.


There is a massive map and very little repetition of things that you see. For example, to pick an older game, Far Cry, all the huts in each village looked alike. Every jungle path looked alike. In RDR, every trail, every hacienda looks unique.


2 Sandbox format


Rockstar games are famous for giving you a massive free-roam area to play around in. Plenty of players just ride around and get into trouble. I believe that the play area in Fallout 3 was probably a little bit bigger, but Fallout 3 didn't feel like free roam because you'd get attacked by something every 20 yards. RDR gives you the chance to take a stagecoach from place to place but you feel like riding instead because it's so much fun.


3 That five-year-old feeling


By which I mean that when I play an XBox game, I want something that makes me feel like a 5-year-old kid playing cowboys and indians again. Somehow, RDR manages to do that and still keep a decent level of realism.


4 A great script


Okay, the story is pretty straightforward, but the characters in the story are great fun. People sometimes argue whether a game should have a great story (or whether it's a work of art), but I'm a firm believer that a great story makes a great game.


RDR has a wicked sense of humor, too. For example, there's a guy who *loves* his horse in a way that is not quite appropriate, and there's a hard-drinking Mick by the name of Irish who swears incessantly. In fact, it's the first time I've heard the word c**t used in a game.


RDR pulls every Wild West cliche out of its ten gallon hat, but it's all in the name of good fun.

Tuesday, June 29, 2010

Pac Man For The Win is Ready


Pac Man for the win is ready and hopefully bug-free. Hope you enjoy playing it!

URL: http://www.flashbynight.com/pacmanftw

Monday, June 14, 2010

PacMan ftw





Since PacMan is thirty years old this year, I thought I might just do a homage and give pacman the old flashbynight treatment. By which I mean I take the game and mess around with the mechanics and the gameplay until I reckon I’ve come up with something different.

I’m calling my game, Pac Man For The Win because I used to really suck at the stand-up arcade version and I wanted to make something more casual. My idea is to come up with totally different mazes for each level and also to have different numbers of ghosts and powerpills and so on.

The first step was to build the ‘engine’ – basically a class which would recognize when pacman encounters blocks, dots, powerpills and ghosts. I could reuse some of this code to control the ghosts. After that, I was free to concentrate on level design, which is where I am now. I’ve designed 12 out of twenty levels and you can play the first three here:

www.flashbynight.com/pacmanftw

I’ll update the page and eventually the finished game will appear there, sometime around the latter part of June.

Another thing I did was to look closely at the AI of the ghosts in the original game. I always thought that they pressured pacman too much and made it a difficult game. However, the original designer claimed that he made the AI such that the ghosts would not chase pacman 100% of the time. I got this from a great article on ‘Ghost Psychology’ here: www.webpacman.com/ghosts.html


My ghosts have three modes:

1 random => they move randomly about the maze
2 pursuit => they actively home in on pacman
3 scatter => they flee from pacman

For most of the game, the ghosts are in random mode. Every so often, one or more will go into pursuit mode for a short time. If the player completes all 20 levels, he can replay them with all ghosts constantly in pursuit mode. (Without this feature, I couldn’t have a high score feature, because everyone who finished the game would have a similar score).

When pacman eats a powerpill, all ghosts go into scatter mode, but only for a few seconds (or else they end up bunched against the walls).

So as you can see, I had a lot of fun creating PacMan For The Win and I hope everyone has a fun time playing it.

Don’t forget to try my other reworked retro games:

Retris

Wednesday, June 2, 2010

New Tute: Creating a Document Class

There's a new tute available: Creating a Document Class:

www.flashbynight.com/tutes/doc_class/

A document class in AS3 allows you to keep all your code in an external .as file instead of the main .fla movie.

This tutorial is suitable for beginners to AS3 - you'll need to know how to create a document class before you can go on to do anything else, really.

Saturday, May 8, 2010

A Quiz Template

A visitor to my site recently commented on my tutorial for building a multiple choice quiz in AS3 and asked for help with a simple fill-in-the-blanks quiz.

I put together a template and I thought I would share it here. (Right-click and select save-as.)

I will probably put this into a short tutorial available on flashbynight. Until then, just contact me if you need any help with it.

I also have a drag-and-drop tutorial here.