Thursday, 4 October 2012

Geek's Got Game Too! (and has landed on the moon!)

For some reason or other, I can’t or refuse to remember why, I decided that my next App for Windows Phone should be a game.  Most coders when they were little hoped to someday grow up and write the next great “Planetfall” or “Earl Weaver Baseball”.  Remember those greats?  Never thought it could happen to me as I steadily moved down the path of providing top of the line business solutions (turns out it’s less of a dice game and easier to make reliable $$$).  I once considered doing the Apple iOS dance, but quite honestly, coming from a VB background, objective C development was just not a place I wanted to jump to.  Then along comes Windows Phone…  Hey, I can write in VB or C#... Cool!
I had just published three Apps to the Windows Phone marketplace that were UI based utilities (http://www.fwic.net/MobileApps.aspx) and I was looking for a challenge.  For some reason XNA  (Microsoft gaming platform) came to mind and I thought, I can do a game.  Something simple but fun would be best.  I thought fondly back to my youth and my old TI programmable calculator (yes, I come by "geek" honestly) and thought; “lunar lander”.  I was going to write a Windows Phone Lander game, call it "Fusion Invasion" add lots of cool extras including Camera Integration, Environmental customizations and Social Media (how does landing at a local landmark sound?).  I'll cover the extras in my next blog.
First, let me tell you that writing games is WAY WAY WAY more difficult and time consuming than business apps and utilities.  In a business app a user can occasionally do something to mess you up.  In a game, they can be doing it at 30 frames per second… yikes!  There are more than a few things that dropped me outside my comfort zone: graphics, animations and story as described below.

Graphics

I learned very quickly that your game can be good but without due attention to the graphics, perception of the game would be severely impaired.  I spent quite a bit of time creating the landing craft and the backgrounds.  I think they turned out pretty good but they did take more time than the coding probably did.  It is very satisfying and worth the time spent when it looks good.
TIP: Take the time to make your graphics look great.  (It covers for other deficiencies ;-)

Animations

XNA games generally operate at 30 frames per second.  That means if you want your lander to “blow up real good” when it crashes, you need to draw every frame of the explosion and make it look good.  I start with some pictures of flames to get the colour and then worked out a 30 frame sequence that looked explosive when done.  Figuring how to animate that was interesting too.  In XNA you have an “update” and “draw” routine that fire 30 times per second (if that is the frame rate you are working with) and you have to keep track of where you are in the sequence.  I did it by creating a class that contained all the explosion images and kept track of frame index and current image. 
TIP: Look to Codeplex for an Animation Library for XNA on WP7.  Use an animated GIF to test the visual presentation of your animation!

Story

The last bit took the longest to wrap my head around.  All the other stuff is just learning to code a bit differently with different “triggers”, story requires a different sort of thinking.  Some key questions that needed to be answered:
  1. How do we make it easy for “the newbie”?
  2. How do we up the difficulty?
  3. How quickly do we ramp up the difficulty?
  4. What is “Trial” and what is “Purchased” functionality?
The most difficult part was figuring out how to slowly ease the player into more and more difficult play without making it impossible.  Basically we tried different things and then played them.  I’m not a game player at heart so if I found it frustrating then I knew we were in trouble.
TIP: Make sure you set a non-time dependent boundary to “Trial” mode if you would like people to actually buy your game.  (e.g. Limit the levels, keep bonus elements out, limit on-line interaction)
AND
PLAY! PLAY! PLAY!

CONCLUSION


By the way.  There is nothing quite like whipping out your phone and showing a friend YOUR game that YOU wrote.  Then watching with utter joy and happiness as they quickly plummet to the earth, exploding in a massive ball of fire.  Ahhh, good times. 


Fusion Invasion -  Where you invade planets, moons or locations around you...  Awe your friends!

See More
 Space Junk! - Prevent the proliferation of space junk around our great blue ball, Earth!

See More    See The Video!