Stephen W. Moore

August 28, 2009

geoDefense for iPhone: Add Custom Levels

Filed under: Uncategorized — Moors @ 1:09 am

geoDefense is a game for the iPhone 3G(S). Using SSH, it is possible to access the application directory and edit new levels.

You must have a jailbroken iPhone and have SSH running. Let your iPhone connect to your wireless LAN and take note of the ip address. SSH into your iPhone. I use PuTTY for Windows. The login information is:

  login as: root
  root@192.168.1.198's password: alpine
  iphone:~ root#

Next, find the directory of geoDenfense. Move up to the root directory and run the find command:

  root #/ find -name 'geo*'

The directories use apparently random generated directory names which are very hard to manage. Mine was under the ./mobile/Applications/xxxxx ….. xxxxx directory (a big long string of characters). Use the ‘cd’ command to get to the directory and then go into the application subdirectory /geoDefense.app.

  cd /private/var/mobile/Applications/xxxx …. xxxx/geoDefense.app

All of the geoDefense levels are *.xml files.

geoDefense Directory

geoDefense Directory

Create a new file for your new level. My favorite level is Eternity (hard map 9), so I duplicated Eternity to a new file:

  cp GAME_LEVEL_H_0009.xml GAME_LEVEL_H_0013.xml
  nano GAME_LEVEL_H_0013.xml

First thing I did is rename it. For my first try, I called it “Eternity version 2”:

  name="Eternity v2"

Voila! It shows up on the levels menu! I also added a couple extra waves of creeps. More on that later.

geoDefense Levels

geoDefense Levels

Now I created my own custom level. This required understanding the coordinate map of the screen. I measured the screen and calculated 6.4 pixels per mm. Later, I found the actual number is 6.417, so I was pretty happy with my measurements. The harder part was figuring out the positioning of the geoDefense grid within the 320×480 screen. My best estimate:

  left edge:	x = 16
  right edge:	x = 304
  bottom edge:	y = 80
  top edge:	y = 464

Reality will show my estimates aren’t exact, but very close.

The next step is to draw a map and make x-y coordinates for the various segments. My first map is a spiral, which I will call “Event Horizon”, relating to the Schwarzschild radius (http://en.wikipedia.org/wiki/Event_horizon) around a black hole. My first drawing has the following coordinate map. I wanted the pathways straight along the grid lines.

  0   , 80
  64  , 144
  64  , 416
  256 , 416
  256 , 128
  128 , 128
  128 , 352
  192 , 352
  192 , 192
geoDefense Coordinate Map

geoDefense Coordinate Map

Some experimentation showed I wasn’t exactly on target. A little tweaking gave the following coordinate map:

   <point x="0" y="80" />
   <point x="62" y="144" />
   <point x="62" y="416" />
   <point x="258" y="416" />
   <point x="258" y="122" />
   <point x="128" y="122" />
   <point x="128" y="352" />
   <point x="192" y="352" />
   <point x="192" y="192" />

My initial estimates were very close.

Next, I added a few extra levels of creeps, in addition to those already specificed for “Eternity”:

   <wave>
   <spawn type="CHOMPER" count="25"/>
   </wave>
   <wave>
   <spawn type="WIGGLE" count="35"/>
   </wave>
   <wave>
   <spawn type="CHOMPER" count="25"/>
   </wave>
   <wave>
   <spawn type="WIGGLE" count="40"/>
   </wave>
   <wave>
   <spawn type="CHOMPER" count="25"/>
   </wave>
   <wave>
   <spawn type="WIGGLE" count="45"/>
   </wave>

Wow, that last wave of 45 wigglers is very difficult to beat. That’s because the creep’s health increases each level because of this line:

   <creeps waveHealthFactor="1" waveHealthFactor2=".2" waveWealthFactor=".5">

And you can tweak the starting health and speed of each type of creep:

   <creep type="CHOMPER" speed="40" health="100" />
   <creep type="SPINNER" speed="40" health="100" />
   <creep type="WIGGLE" speed="20" health="150" />
   <creep type="STAR" speed="60" health="75" />
   <creep type="CUBIC" speed="30" health="120" />

Overall, I was satisfied with my new level. Now the game has endless possibilities to create new challenging levels.

geoDefense Event Horizon

geoDefense Event Horizon

It takes a little tweaking to make the level playable.

geoDefense Event Horizon

geoDefense Event Horizon

Advertisements

1 Comment »

  1. Well done! Send me your best and I’ll include it in an update. 😉

    By the way, waveHealthFactor2 makes health go up non-linearly. If you want linear health progression, you can exclude that variable from the XML.

    — David (author of geoDefense)

    Comment by David Whatley — August 28, 2009 @ 2:11 pm | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: