Archive for the ‘Games’ Category

AS3 Bitmap Cached Animations

Friday, April 25th, 2008

Rendering a vector for every frame of a repeated animation (like in most games) take a lot of CPU. It takes even more CPU to have lots of complex characters on screen - many the same sprite.

cacheAsBitmap in flash is good, but only if you have static objects but recreates the bitmap data of an animation every frame, making it run even slower. The best solution is to cache each frame of an animation as a bitmapData, and then switch between them each frame. This works well until you have multiple instances of the same sprite - You dont want to pre-render the bitmap data and keeping it in memory many times, so it is best to keep a library of animations, and then reference the cached frames for each instance.

View Example

Download Source

Another advantage of this technique is it seems to make use of Flash’s new multi-core support. On a dual core CPU it can, if you push it, take almost 100% of resources. Trying it on a quad-core seemed only to take up two CPUs though. I guess this is both a blessing and a curse as you’re more likely to grind a users system to a halt, even if they have multiple CPUs.

Animations copyright Nathan J. - http://www.scarygirl.com/

Joystick / Joypad in Flash

Monday, April 14th, 2008

I’ve always wanted to use a Joytick with my Flash games.

A while ago I was working on small game for Lorial - in-store advertising for Biotherm - through a great company Eness. It was a simple “catch the falling objects with a timelimit game” made in Flash, but needeed to be controlled using a joytick as it had to be simple and easy to use for anyone walking through Myer.

After a little research I found the amazing program AutoHotKey. This lets you specify macros to do things like using a joystick as a mouse or keys, or pressing a combination of keys and starting a program. Using this amazing peice of software (Windows only sorry) and hacking around with some of their joystick input exampels it was easy to map joystick movements and buttons to the arrow keys and “A” on the keyboard, which were then read by Flash.

On a recent game I’ve been working on (Scarygirl) I’ve found that user testing on the keyboard really gets in the way of the gameplay itself, especially for those not used to games. It was a lot easier to hand them a Playstation 2 DualShock controlller attached via a USB converter and have an AutoHotKey script running that converted the D-Pad and buttons to input. The hardest part of this is finding which button on the controller relates to what input into windows. The easiest way I found to work with this was Start->Control Panel->Controllers and just writing down a list of buttons as I pressed them.

So yeah. Easy. And fun. Some games are just so much better with a good controller - just never let me catch you playing an FPS on a console!

Mame with USB Controllers

Sunday, April 6th, 2008

We’ve finally nearly got our 40gb of MAME running- productivity boost! It took a while to figure out, but we finally have PS2 controllers to work - conected with a USB adapter. To run MAME with USB controllers on XP i’ve found:

  1. connect controllers & test that they work in the Control Panel > Game Controllers Panel.
  2. get MAME to create a .ini file
    You need to run ‘mame -cc’ this can be done at the command prompt, or by making a .bat file
  3. Edit the ‘mame.ini’ file (should be created next to your mame.exe)
    Change the line ‘joystick 0′ to ‘joystick 1′ - this enables joystick input
  4. Press tab when in MAME to get the key setup options.
  5. Rock out!!