Tuesday, June 15, 2010

Unresolved questions, resolved*

*subject to change

In my last post I had two unresolved design questions that I’ve tentatively come to a conclusion with.  That is to say, I’ve decided which direction I’m going to move forward with but as always that’s subject to change:

1. Will this be an iPhone or Windows Phone game first?

An iPhone game first.  Besides the obvious (marketshare), here are some main reasons:

    • I will be ordering an iPhone 4 tomorrow, which means I’ll have physical hardware to test on much sooner.  For example, I can test the motion-control difference between the iPhone 4 and my current iPhone 3G.
    • The Windows Phone toolset is very rough at this point and the performance of the emulator is lacking at best, frightening at worst.  I can theoretically complete the iPhone version with plenty of time to spare to get the Windows Phone version done when the toolset is more mature.
    • The iPhone 3GS and iPhone 4 support custom shaders, which is a feature I may support in this game if I want to achieve some exceptionally cool effects.  Windows Phone does not support custom shaders.

2. Will the levels be random or fixed?

I stressed about this in my head for a long time, but I’ve come up with a compromise that I’m happy with.  Rather than create fixed levels (which would necessitate a level editor – which itself would be a large obstacle to tackle since the levels would span humungous distances), I can have fixed themes with randomly generated levels on each theme.  For example, I can have a starbase level, a planetary cavern level, etc., and each could be completable (as opposed to a never-ending “Canabalt”-style game).  The difficulty of each playthrough would be about equal to any other, but the random variance would keep things interesting.  (I realize I’m rationalizing a bit.) 

I was wanting to avoid a never-ending single game in which your only accomplishment is the amount of time you stay alive before blowing up.  After all, the premise of this game is that you’ve just destroyed the enemy HQ; it’d be a shame if your heroic act always ended in tragedy (though I’m sure I’d get some emo indie points if I designed it that way.)

Friday, June 11, 2010

Upcoming game, codename “Escape”

Here’s a very simplified mock-up of the iPhone and/or Windows Phone game I’m working on. 


Not much, right?  Well here’s the premise: You know all those sci-fi games / movies in which the hero destroys the enemy mothership/starbase/etc. and escapes in his or her ship just in the nick of time, before the enemy craft explodes behind them?  Well the span of time between setting off the chain reaction and escaping safely is the entire premise of this game.

You’ll need to race your ship through corridors, twisting and turning to avoid obstacles and the walls on your sides in order to outrun the explosion approaching behind you.  If you’re not quick enough, you’re toast.

I still have many design decisions yet to make, but there are some I am pretty solid with so far:

  • The game will feature vector-based, “geo-style” graphics
  • The game will be controlled with motion controls (accelerometer and/or gyroscope).  I will need to test this on an actual device to ensure that it’s fun, but the goal is that the ship itself doesn’t rotate; the world rotates around the ship as you rotate your device.
  • It will be impossible to die aside from letting the explosion behind you catch up to you.  Everything else will just slow you down; scraping against the sides of walls, colliding with obstacles, etc.

And here are some I’m not so certain about:

  • Will this be an iPhone or Windows Phone game first?  The development environment for Windows Phone 7 (XNA, Visual Studio) is much more appealing, but the toolset is still in beta and the performance of the emulator makes me nervous – not to mention the big risk of placing a bet on WP7.  Additionally, Steve Jobs just announced the new awesome iPhone4 super precise motion controls, almost as if it were a personal gift to me for this project. SmileAlso, if I go the iPhone route, another decision may be whether or not I limit the game to the newer iPhone graphical capabilities (OpenGL ES 2.0) or if I support older iPhones as well.
  • Will the levels be random or fixed?  One plus side of the random option is that it avoids the need for a level editor and completely pre-defined levels, but it also eliminates the ability to “master” levels through practice, or be able to compare your accomplishments equally to anothers’.  I see a lot more potential for sharing/comparing/feeling a sense of accomplishment with fixed levels.  I’d rather escape from The Death Star than Random Level 46024.  Random levels would mainly just be a time-saver.  Of course, if you guys disagree and think random levels would be cooler, I’d be happy to do it that way.

There are also tons of stylistic considerations regarding how the ship and levels will look, especially related to the simplicity versus intricacy.  I may keep it very simple aside from some “juicy” particle effects.  But, though personally I am fine with a very emotionless, geometric world, I think the game could benefit from a little bit of “cuteness” or other personal touches.

As always, any feedback is welcome.  I’ll post more videos and images as the project progresses.

Wednesday, June 9, 2010

2D Line segment intersection detection in C# / XNA

For a previous game project, I needed a nice line segment intersection detection algorithm.  It was surprisingly difficult to find a good one in C#, but I found one in C++ that I converted. 

As it turns out, my upcoming game makes heavy use of this algorithm as well.  So here it is in case anyone else needs it.  This version is a little sloppy in that it uses 3D constructs despite checking 2D intersections, but it would be simple to convert this to its 2D counterpart.

Line segment intersection C#
  1. // Returns true if the lines intersect, otherwise false. If the lines
  2.         // intersect, intersectionPoint holds the intersection point.
  3.         public bool Intersects2D(LineSegment3 otherLineSegment, out Vector3 intersectionPoint)
  4.         {
  5.             float firstLineSlopeX, firstLineSlopeY, secondLineSlopeX, secondLineSlopeY;
  7.             firstLineSlopeX = this.Point2.X - this.Point1.X;
  8.             firstLineSlopeY = this.Point2.Y - this.Point1.Y;
  10.             secondLineSlopeX = otherLineSegment.Point2.X - otherLineSegment.Point1.X;
  11.             secondLineSlopeY = otherLineSegment.Point2.Y - otherLineSegment.Point1.Y;
  13.             float s, t;
  14.             s = (-firstLineSlopeY * (this.Point1.X - otherLineSegment.Point1.X) + firstLineSlopeX * (this.Point1.Y - otherLineSegment.Point1.Y)) / (-secondLineSlopeX * firstLineSlopeY + firstLineSlopeX * secondLineSlopeY);
  15.             t = (secondLineSlopeX * (this.Point1.Y - otherLineSegment.Point1.Y) - secondLineSlopeY * (this.Point1.X - otherLineSegment.Point1.X)) / (-secondLineSlopeX * firstLineSlopeY + firstLineSlopeX * secondLineSlopeY);
  17.             if (s >= 0 && s <= 1 && t >= 0 && t <= 1)
  18.             {
  19.                 float intersectionPointX = this.Point1.X + (t * firstLineSlopeX);
  20.                 float intersectionPointY = this.Point1.Y + (t * firstLineSlopeY);
  22.                 // Collision detected
  23.                 intersectionPoint = new Vector3(intersectionPointX, intersectionPointY, 0);
  25.                 return true;
  26.             }
  28.             intersectionPoint = Vector3.Zero;
  29.             return false; // No collision
  30.         }

Tuesday, June 8, 2010


Hi, thanks for checking out the blog.  Funcode is the name I’ve given my small game development operation consisting of myself and whomever is kind enough to work with me on fun projects.

Funcode is my passion; it represents a lifelong desire I’ve had to make games and software with small, personal teams, without the stresses or hassles of the corporate environment.  It’s more than a hobby for me; it’s a commitment and a fulfillment of a dream.

I’ll spare you the cheesy bio for now.  In my quest to achieve my goal of being able to wake up whenever I want, I’ve created three apps for the iPhone so far:

PhotoToons – allows you to add cartoony “stickers” to your photos as well as paint them, and save them to your image library.  My artist friend did most of the artwork for the stamps.

Crab Crawl – A fun “never-ending-falling”-style game in which you play a crab who is desperately trying to avoid getting caught.  Along the way you encounter all sorts of hazards and bonuses.  This was my first iPhone game and I had a blast working on it.  You can check out a video here.  My girlfriend can take credit for the art, and her good friend Bernadette Choy provided the great music.

Dave and Steve’s Droppings – This is a promotional app I made for my friend’s humorous podcast (The Dave and Steve Show).  This friend also happens to be the artist behind PhotoToons.  This app is like a soundboard that lets you play a big selection of audio clips from the show (mostly potty humor), from each of the hosts.  It also lets you queue up multiple sound clips and play them in a row, completely out of context and offensive, of course.

I’m currently working on a new game that I’m prototyping on the Windows Phone 7 emulator, but very seriously considering developing on the iPhone initially.  I’ll announce more details once I feel it’s worthy of an unveiling.