Gamepads for iPhone

April 3rd, 2010

Apple is patenting gamepads for the iPhone and iPad, according to this article.

This is good news because, let’s face it, controlling games with your finger and tilting sucks for just about everything besides driving games, puzzle games, and gimmicky apps.

Many types of games are just NOT possible.
Examples:
Megaman, Super Mario Bros., and any game that requires more precise control than can be achieved with a hot dog.

Attempts have been made to port some arcade classics, and most are terrible.

Putting a “controller” on the touch screen is just plain awful.

The bad news, or course, is that not everyone will have the gamepad.  And even if you have the gamepad, you’re not likely to have it with you every time you want to play a game.  Thus, games will have to be designed to support the standard control scheme anyway.

The best scenario would be to have actual physical buttons on the iPhone.  However, this will never happen.  Apple has spent a lot of money and energy to convince consumers that there is no need for physical buttons.

iPhone

iPhone 4 to support Flash!

April 1st, 2010

This just in.
Wait for it….

iPhone 4 will support Flash, along with the iPad.
Hooray!!

Just kidding.
April Fools, you idiot.

Uncategorized

Unity 3.0 2D Sprite Engine

March 24th, 2010

The upcoming Unity 3.0 will have a 2D Sprite Engine, as you can see from the press release:
http://www.gamasutra.com/view/news/27558/Unity_Announces_30_Platform_Support_For_PS3_iPad_And_Android.php

The press release makes it sound a little like the sprite engine is specific to the iPhone, but this is not the case.  You can see the “inside” info here (top secret):
http://forum.unity3d.com/viewtopic.php?t=47214

Creating 2D games is currently very clunky in Unity.  Basically, you have to billboard textures onto planes or boxes, etc.  There is no hit detection for pixels.

In case anyone misses the point, a 2D sprite engine makes Unity a one stop shop for game development.  This effectively provides competition to Flash and Silverlight, as well as the folks at Garage Games, and many others.

Being able to write games in 2D or 3D, and deploy to the PC, Mac, Xbox 360, Playstation, iPhone, Andriod, and Atari 2600… where do I sign up?

Unity 3D ,

Instantiating a prefab from the library in C# with Unity 3D

August 9th, 2009

Unity 3D is really geared toward visually building your game through use of the Unity 3D editor. However, there are times when you want to instantiate a prefab that you don’t already have in the Scene.

Instantiating a prefab from your library is easy, once you know how. Figuring out how is a pain. The biggest quirk is that your prefab must be located in a directory called “Resources” if you want to instantiate it using C#.

Here are the steps.

1. Make sure you create a directory called “Resources” and place it in your Assets/ directory.
2. Create a prefab. Let’s all it “FooPrefab”.
3. In C#, instantiate the prefab as follows:

1
GameObject go = Instantiate(Resources.Load("FooPrefab")) as GameObject;

Why does the prefab have to be placed in a directory called “Resources”.
Who knows?

C#, Unity 3D ,

Using C# with Unity 3D to achieve code completion (intellisense)

August 8th, 2009

I’ve been playing around with Unity 3D lately, and its pretty awesome.  Its not very difficult to make the leap from Flash to Unity.  However, one detractor to Unity is its poor coding environment.

As a Flash programmer, I’m very spoiled by several of the development environments available to me.  FlashDevelop, Flex, etc. all provide intelligent editors that give me code completion.  Unity’s built in editor does not have this feature.  Once you get used to code completion, you can never go back to a plain text editor!

The good news is that you can use Visual C# 2008 Express for all of your Unity coding needs, and its totally free!  Thanks, Bill Gates.

Below are the steps to set up your environment.  Have fun.  Don’t say I never gave you anything.

One time setup:

1. Download Visual C# 2008 Express for free:
http://www.microsoft.com/express/vcsharp/

2. Install it.  ;)

3. Download the following file, which is needed for tool tips as you edit in C#.
UnityDocs.zip
Place the 2 XML files here:
C:\Program Files\Unity\Editor\Data\lib
(or wherever you installed Unity)

Repeat for each project:

1. When you create a new Unity 3D project, you need to create a new C# project somewhere in the Assets/ directory.  It can be right in Assets/, or you can make a sub directory.  Making a sub directory might be cleaner as C# will create solution files, etc.  Use “Empty Project” as your project type in C#.

2. Add a reference to the Unity dll files in your C# project.
In C#’s Solution Explorer panel (on the right), right-click the project and choose “Add Reference”.
Browse to and add UnityEngine.dll.
(you can add the editor dll as well if you are going to write editor code)

3. Create new class files from within C#.  If you do it from Unity, they don’t show up automatically in your C# project (there is probably a way to add them, but I don’t know it).

That’s it!
Code completion, tool tips, hints… it’s all there.

C#, Unity 3D ,

Book: ActionScript for Multiplayer Games and Virtual Worlds

July 29th, 2009

Jobe Makar’s new book, ActionScript for Multiplayer Games and Virtual Worlds, will be available this Monday (August 3rd).  I’ve already read the book and it’s fantastic!

ActionScript for Multiplayer Games and Virtual Worlds

I really wish something like this had been available years ago.  I create lots of multiplayer games and virtual worlds.  This book would have saved me tons of time and effort.

In addition to being a fan of Jobe’s books, I had the pleasure of contributing to this one.  Jobe did me the honor of having me to write Chapter 11: Cooperative Game Play.

The chapter discusses various cooperative game concepts.  Also, I created a fully working multiplayer game to go along with the chapter: Super Blob Brothers (Thanks go to Scott Smith for writing all of the server side code to support the game).  Of course, the book comes with the full source code for the game.

In Super Blob Brothers, two players must help each other complete each level by navigating from the starting point to the Goal Pad.  The game is unique in that cooperation is required.  No level can be completed by a solo player.

Super Blob Brothers

Obstacles include rocks, laser gates, and laser towers.  Rocks can only be pushed by two players working together.  One player has the ability to defend against lasers.  The other player has the ability to disable laser towers.

Other games in the book include a real-time tank game and a fully working virtual world example.

Be sure to purchase the book as soon as possible!  On a scale of 1 to 10, I’d give it an 11.

Uncategorized

Flash CS4 Bug: Kill the Compiler With One Line of Code

January 6th, 2009

I just found a nasty little bug in Flash CS4.  One line of code will result in a project that compiles with no errors and yet no trace statements work either.

Simply put the following line of code anywhere in your project (including in any class, or on any frame on the time line):

1
var version:Number = 0.0.1;

That’s it!  Your project will (seem to) compile with no errors.
You won’t get any trace output either.

Imagine burying this line of code in a random class in a project that has hundreds of classes.  How could anyone find it?

I’m Tellin’ Y’all It’s a Sabotage.

Bugs, Flash

Modules in Flash

December 22nd, 2008

Modules are SWF files that can be loaded by an application but cannot run indepedently.  Modules are built in to Flex 3, but it takes a bit of finagling to use modules in Flash.

I have been able to use modules successfully in Flash.  Below are the steps to follow.  I have also included the sample source code:
http://michaeljbowen.com/examples/modulesInFlash.zip

Step 1
Grab the latest Flex SDK.  I used 3.2:
http://www.adobe.com/products/flex/flexdownloads/

Step 2
In the Flash IDE (I’m using CS4), create a reference to the Flex SDK:
File > Publish Settings > Flash > Settings > Library Path
Add a reference to frameworks\libs (see the following image)

Advanced ActionScript 3.0 Settings

Advanced ActionScript 3.0 Settings


Step 3:

Create a module by creating a class that extends mx.modules.ModuleBase.

1
2
3
4
5
6
7
8
9
10
11
12
13
import mx.modules.ModuleBase;
...
public class ModuleAlpha extends ModuleBase implements IModuleAlpha
{
   public function ModuleAlpha()
   {
      trace("ModuleAlpha created.");
   }
   public function addNumbers(a:Number, b:Number):Number
   {
      return a + b;
   }
}

Step 4:
Compile the module using the mxmlc command line compiler.
Note: If you’ve placed your source in subdirectories, you will need to let the compiler know your source path.
In my example, ModuleAlpha.as is located in the com.electrotank.modules package.
Thus, here is my command to compile:

1
>mxmlc "-source-path+=../../../" ModuleBeta.as

Step 5:
Create a “parent” application that will load in your module(s) via mx.modules.ModuleManager.
Here is an excerpt from the sample code provided:

1
2
3
4
5
6
private const URL_MOD_ALPHA:String    = "ModuleAlpha.swf";
...
_modules[URL_MOD_ALPHA] = ModuleManager.getModule(URL_MOD_ALPHA);
IModuleInfo(_modules[URL_MOD_ALPHA]).addEventListener(ModuleEvent.READY, onModReady);
IModuleInfo(_modules[URL_MOD_ALPHA]).addEventListener(ModuleEvent.ERROR, onModError);
IModuleInfo(_modules[URL_MOD_ALPHA]).load();

Step 6:
Create an instance of your newly uploaded module using the factory of IModuleInfo:

1
2
var modAlpha:IModuleAlpha = IModuleAlpha(IModuleInfo(_modules[URL_MOD_ALPHA]).factory.create());
trace(modAlpha.addNumbers(2, 3));

Done
That’s it!
Be sure to use your powers only for good and not evil.

Flash, Hacks

Flash 10 Speed Test: copyPixel vs. Scrolling Sprite vs. Scrolling MovieClip

November 29th, 2008

When Flash introduced the copyPixel operation a few versions ago, I was very excited.  Finally, I could create blazing fast games that worked more like “real” games instead of using MovieClips.  However, copyPixel is no magic bullet.

Here are the results of a simple test where I scroll a background image.  I guessed that copyPixel would yield the fastest results, but I was wrong.

Note that during initial testing it was difficult to get a big difference with an 800×600 drawing area.
Of course, that’s because I’m only moving 1 image around as opposed to hundreds as in an actual game.

Thus, to make the differences stand way out, I increased the drawing area to 1880×1024.
This will fill up Fire Fox if your resolution is 1920×1200, but you can still see the drawing area.

The frame rate is set to 120.
Note also that I am using a crazy big image of size 4095×4095 (3.5 Megs).

Various OSs and Browsers

# Method Mode Fps Fire Fox - Win Fps Internet Explorer - Win Fps Fire Fox - Mac
1 Copy Pixel opaque 21-23 36-38 36-37
2 Copy Pixel window 40-42 43-45 36-36
3 Copy Pixel direct 54-56 46-48 30-31
4 Copy Pixel gpu 27-28   (wtf?) 43-45 21-22
5 Sprite opaque 24-25 36-37 36-37
6 Sprite window 58-60 62-64 36-37
7 Sprite direct 80-84 58-60 35-36
8 Sprite gpu 120 solid  (wow) 61-63 33
9 MovieClip opaque 24-25 38-40 36-38
10 MovieClip window 58-60 55-62 36-37
11 MovieClip direct 80-83 58-60 36
12 MovieClip gpu 120 solid  (wow) 58-62 33

So, the really confusing thing for me is that copy pixel seems to drag down gpu mode!

Also, remember when “opaque” used to be the best wmode option for performance? Not any more (at least for this specific test).

Flash, Performance

Flex 3 Profiler Bug

August 18th, 2008

I am running Flex 3 on Windows Vista.  For some reason, attempting to profile an application would always fail.  There were no errors or warnings… the app would launch in my browser and simply run without profiling.

The following work around worked for me:

  1. In Flex 3, click on Window > Preferences…
  2. In the Preferences window, choose Flex > Profiler > Connections
  3. Set the Port number to something other than 9999.  10001 worked for me.

That’s it!

Profiler Preferences Window

Profiler Preferences Window

Bugs, Flex 3 ,