Phil Hassey - game dev blog
Phil Hassey as Rambo
".. I've been there,
I know what it's like,
and I'll do it again if I have to."

Beast for the iPhone / iPod touch

February 23rd, 2009

Today marks the release of my first iPhone game release in five months.  It’s about time I got going on dev again.  I’ve been in the midst of many transitions in both of my businesses, so I decided to start out with something short-n-sweet.  The game is called Beast.

Beast is a re-make of an ancient MS-DOS game that I played ages ago (and I’ve re-made several times).  The original is here.  You may have followed my progress on twitter.  Here are some interesting “factoids” about the game dev.

The original game is pretty tough to play, if you have dosbox and have all the proper slow-down settings going, you’ll find it can be a challenge to surround the beasts and crush them with blocks.  The iPhone doesn’t have a D-Pad, so moving a character around the screen is a bit tricky.  I had to make several modifications to the original game so that it would work with the touch interface:

  • You can move the player around the screen by pushing your finger around.  However I had to make the player unable to move diagonally as I found the resolution of your finger movement made it near impossible to play and quite jumpy if I allowed diagonals.
  • You can touch any point on the screen and warp to that location.  The controls were still a bit tricky, so I had to add this feature so you could do quick movements to escape from a beast, or to attack it quickly.
  • I disabled the beasts so they can’t move diagonally, made the super beasts spawn into only 4 instead of 8 normal beasts, and slowed down the beast movement by about 50%.  These changes were all required to make the game playable.

All these changes turned an impossible to play on the iPhone into a reasonably fun diversion.  I also added a notable element of speed into your score.  This gives the player a good bit of replay value, since even after they beat a level, they can try again and try and “master” a map they are playing.

Overall the main point of this whole exercise was to get myself back into iPhone dev.  Really last year when I worked on Galcon I threw myself violently into that project for 3-4 months and came out a bit burnt out.  I knew this time I needed to do a small scale project to get going again.

I’m pretty pleased with the results of this project.  For some more interesting factoids about the game project, check out my game blog announcement.

Excuse to post this to the python planets: I actually made a python version of this game a few years ago.  It contains some really bizarre pure python sound-synth for both the music and sound effects.  Check it out.  Not only all that, but the whole game is a single 18k python file!  I ported from this code for the iPhone version.  Again, another great example of python prototype -> C++ final product!

(Silly side-note, actually the python code was a port of some C++ code I made ages ago.  So this is a great example of C++ code that was ported to python and then later ported back to C++.  I won’t bother you with details about my even earlier Java and C versions of the game.)

Bundling SDL_image.framework and SDL_mixer.framework

February 21st, 2009

So if you are trying to build a SDL + SDL_mixer + SDL_image + OS/X + Xcode game .. well .. when you build it using the SDL Application Templates, you’ll find that it includes the SDL.framework in the application bundle but it does NOT include the SDL_image.framework and SDL_mixer.framework in the bundle.

Which means, it will work on your computer if you’ve installed the SDL_image and SDL_mixer frameworks in /Library/Frameworks .. but it won’t work on any computer that does not have those frameworks installed.

The error they will see if they happen to run your app from the command line will look something like:

 

dyld: Library not loaded: @executable_path/../Frameworks/SDL_image.framework/Versions/A/SDL_image

  Referenced from: /Users/phil/tmp/ibeast_osx.app/Contents/MacOS/ibeast_osx

  Reason: image not found

This blog has some instructions on how to deal with this.  However I still found it confusing that I had no idea where these “New Copy Files” rules were being placed.  Especially since I knew the SDL template had one already and I wanted to just modify that rule, or duplicate it.
Here’s where to find those rules from your SDL template project:
Groups & Files > Targets > (name of your project) > Copy Frameworks into .app bundle >
And you can drag your SDL_mixer and SDL_image frameworks onto that list.

Can’t do everything ..

February 18th, 2009

Alas, I’m not going to be able to make PyCon this year .. Because I’m a finalist in the IGF Mobile competition 🙂  And the GDC is happening the same week as PyCon.  Oh well, can’t do everything.  I wish I could go to both, PyCon was a blast last year!

That said, some of us tinypy folks might do a tinypy sprint at the same time as the PyCon sprints.  So if there are any people at PyCon who want to sprint on tinypy, get in touch and we can all work together in #tinypy somewhere.  Further news about this sprint will be available in the tinypy mailing list.

tinypy has progressed a bit since I last posted about it.  It’s probably sandboxed and it now has meta methods.  If there are some serious smart VM coders who are interested, we could use a hand.  tinypy is as fast as python for some tasks, but for other things it is around 1/2 the speed of python.  It also uses more memory than python.

From python to C++

February 14th, 2009

I think I wrote an article a few months ago comparing C and python.  I’m doing some new iPhone games now, and this time I’m using C++.  I found not having classes was getting to be too painful for me, so I’m trying out C++.  Here are a few things I’ve observed:

(As a side note – I’m writing my games /almost/ the same way I’d write them in python.  So if you’ve seen my game code, I’m doing almost the same stuff, except in C++.)

  • As usual, not having memory management is a bit of bother.  Fortunately, I’ve found there are only a few places where I actually need it.  The main thing I had to do was write some basic reference counting code for my state engine class.
  • I’m using structs instead of classes, since I have no use for private variables or methods.
  • Having separate .h and .cpp files is a drag.  But them’s the breaks .. It sure would be swell if C++ was a wee bit smarter about that.
  • For my in-game objects, I just define a single struct that has all the possible variables I need.  This is pretty much how I did things in python anyways.  I’ve never been a big fan of using much inheritance.
  • For writing my GUI classes, in python I was able to get lots of magic into them.  In C++ it isn’t so easy to get magic, so I’m doing without most of it.  It seems that most of the magic was gold-plating anyways.
  • Having written all this code in python before, getting clean C++ code seems pretty natural.  I know what I WANT my code to look like, so I try to get my C++ to be as close as possible to that. 
I think the bottom line of this post, is that my code is coming out pretty pythonic.  Maybe?

Galcon on twitter ..

January 29th, 2009

I’ve just created a couple twitter accounts for myself!

philhassey is going to be my dev twitter account, where I might be posting real-time stuff about game-dev, python, and whatever else comes up.  Should be interesting if I get into it :)

galcon is my twitter account for news about Galcon, galcon.com, new games, and other swell goodies!

P.S. Galcon for the iphone is an IGF Mobile finalist!  Check it out!

I’m on twitter now ..

January 29th, 2009

I’ve just created a couple twitter accounts for myself!

philhassey is going to be my dev twitter account, where I might be posting real-time stuff about game-dev, python, and whatever else comes up.  Should be interesting if I get into it 🙂

galcon is my twitter account for news about Galcon, galcon.com, new games, etc.

P.S. Galcon for the iphone is an IGF Mobile finalist!  Check it out!

Running OpenGL Apps on a Linux guest in VMWare Fusion

January 26th, 2009

Here’s my “tip of the day” for running OpenGL Apps on a Linux / Ubuntu guest in VMWare Fusion.  The problem is that while running VMWare Fusion on OSX, your guest Ubuntu system doesn’t have 3D acceleration.  Bummer!  I really like doing my game-dev under linux .. so after a bit of searching I found this neat trick:

1. Open a Terminal in OSX (host OS)

2. ssh -Y ip.address.of.guest.OS
(You can find out the IP address of your guest OS via ifconfig.)

3. run the game you are working on 

4. OSX pops up a window with your game running at full speed!

Via that SSH session I can run my games under linux, but the OpenGL stuff is forwarded to my OSX host, which renders it at full speed.  This is called X11 forwarding, which I had heard of before, but I didn’t know it included OpenGL 🙂

I’d love it if Fusion included 3D acceleration of linux-based Guest OSs, but in the meantime, this will get me by.  One thing to note, this isn’t perfect.  I tried running tux racer, and although it seemed to run at full speed, the view wasn’t centered and so I only saw the top left 25% of the game.

-Phil

OS X fails at synchronizing

January 10th, 2009

While I’m complaining .. the other big one I have is synchronizing our iPhoto and iTunes collections between two computers.

I want to be able to say “I want these two computers to keep each other’s iPhoto and iTunes libraries in sync.” And have it do so.

What I don’t want:

  • Use a shared disk.  This is pointless because these two machines may not be connected to the network, so they need to have local copies of stuff.
  • Use rsync.  This is what I’m doing, but again, this is not how things should be.  This is 2009, things should be easier than breaking out cron and command line utilities to get things done.  Not only that, it only HALF solves the problem, since now we have to decide that one of the laptops is “the master” and the other only receives updates.  Lousy solution, but it’s the best I’ve got so far.
  • Use some 3rd party utility.  This should be built in.  (From what I found, there were no real solutions out there anyways.  Just variations on the rsync theme.  So I figured I might as well use what I’m used to.)
  • Excuses about how syncing is complicated.  Yeah, I know.  That’s why I want YOU to fix it, not me.  Really.
So, c’mon people.  Let’s make computers that WORK.

OS X Inconsistent File Picker UI

January 10th, 2009

Well, I’m still quite enjoying my Macbook.  The biggest complaint I’ve got so far is the inconsistency of the file pickers.  These are things where my wife has said, “This isn’t working, look.”  And low-and-behold, due to some coder out there being too smart for their own good, have broken the file picker in various unusual ways.

  • When uploading a file to a website, the file picker that pops up does not let you navigate into your iPhoto Library.  The only way to get a picture out of it appears to be to open up iPhoto and drag a picture from iPhoto onto the Browse button on the website.
  • When changing your desktop background, accessing your iPhoto Library requires clicking on the little arrow to the left of the words “iPhoto Library” .. The whole word should be clickable.
  • My wife was confused by this and didn’t click the arrow and gave up.  Instead she tried last night’s work-a-round and loaded up iPhoto and tried dragging pictures from iPhoto into the “Pictures Folder” area.  This didn’t work.
  • Since we have 10,000 some odd pictures, the mini iPhoto Library browser that appears when you click the arrow is pretty much useless.  Especially how it removes the year from the listing.  So the only reasonable way we could figure to get a background picture chosen was to open the Finder and attempt to drag pictures from iPhoto onto the Pictures folder.  Talk about taking the long way.
  • When selecting a photo in the Finder and then pressing Delete, it doesn’t do anything.
So it seems there are at least 3 sorts of file pickers in OS X that I’ve seen so far.  They don’t work consistently.  As my father-in-law says, “They (Macs) are better than computers used to be, but they still aren’t any good for dummies like me.”

Setting up my Mac (part 2)

December 19th, 2008

(Okay, I’m going to syndicate this to the python planets, because well .. it seems general enough of interest that maybe other python folks might be interested.  However, if this sort of stuff is unwanted, please tell me and I’ll reign in my planet posts to being on-topic.)

Anti-Virus

So, I think I’m going to go with eset nod32 anti-virus.  From my research there are about a dozen pretty good anti-virus solutions.  I had tried this one out about half a year ago, and I found that it didn’t drain system resources.  My main objective with anti-virus is to have *something* and have it stay out of my way.  This one has one several awards in the past few years, so I guess it must be decent.

Folder Sync

I mentioned in my last post that I really wanted to be able to sync my photos, music, and documents between several machines.  I would use subversion, except somehow it just doesn’t seem like “the right tool” for the task of managing 1000s of photos and mp3s.

What I did find is the Unison File Synchronizer, which appears to do exactly what I want.  If we have a photo gallery and we add pictures to it, those pictures will get automagically synced to a central server and then automagically synced back to other machines.  It wouldn’t be a useful solution for source control, but it looks like a nice solution for managing a photo / music / document collection.

I’ve only given it the five minute inspection, so I can’t say for sure if it will work yet.  Stay tuned for a later report on it.  (If anyone has used it and has tips they want to give me, I’d love ’em!)

Python on Mac

Most people suggested MacPorts.  I guess I’ll give that a whirl sometime.  I think I need to update Classic Galcon at some point anyways.  (Okay, I did mention something about python.  I failed at being 100% off-topic.)

Virtual Machines

I haven’t resolved all the issues yet.  Right now I’m a bit vague on how many Windows XP licenses I’m using.  I’ve got Bootcamp, VMWare, and Parallels all with XP Pro .. Does that count as 3 licenses?  Or one?  Hmmn.  I suppose I should figure that out.  I was able to get Parallels to work with Ubuntu by disabling shared folders, disabling the sync time feature, and enabling the adaptive hypervisor. (As per some post on the Parallels forums.)  Hopefully though, they can fix the bug that causes it to hang with those features on.

Life In General

I’m looking forward to the Christmas break 🙂  A lot of things have been going on between my two businesses and life-in-general.  So a couple days off will do me well.  I must admit, the diversion of messing with this laptop has been pretty fun.  I was able to power up the gimp the other day and color in our Christmas card.  Merry Christmas to ya: