Porting an iOS app to Windows 8

Posted by on Oct 29, 2012 in Everything | 0 comments

I just recently finished porting my iOS game, SimplePhysics, to Windows 8 Metro WinRT. SimplePhysics is primarily written in C++, with just a pinch of Objective-C to get it working on the iPhone. Fortunately, the new WinRT platform is written in C++/CX, so in theory I should be able to reuse almost my entire code base!

This was true for the most part, but there were still some significant hurdles that I had to overcome to get my app running on Windows 8.

Learning the Framework

The first problem was the fact that I knew nothing about WinRT. It’s a completely new framework written to replace the age-old C-based Winapi. Whenever I encounter something that I know nothing about, I turn to my secret weapon: Pluralsight. If you haven’t heard of Pluralsight, then I highly recommend that you check them out. They make extremely high quality training videos that can get you up to speed on a new technology faster than any other method. They are now my #1 stop when learning a new tech. It does require a paid subscription, but they have a free 10 day trial, so you can watch the training video on WinRT for free. This video was particularly good, because it was done by Kate Gregory, who has written over a dozen books and is amazingly knowledgeable about the platform.

No Support for OpenGL

You have two options when making an app for the new Windows Store: DirectX or XAML. OpenGL is not supported, and likely will never be supported. This is very unfortunate when the vast majority of indie game developers are using OpenGL. So now you have to rip all that OpenGL code out and replace it with DirectX…unless there is another way.

Instead of ripping out my OpenGL code, I looked into using an OpenGL to DirectX wrapper library. The idea is that you just link with this wrapper library that implements a version of the OpenGL API that routes your OpenGL calls to their DirectX equivalents. Quite a few wrappers exist, but I couldn’t find any that support DirectX 11 (which is what you’ll need to use on WinRT). So, I set out to write my own wrapper library. It wasn’t too painful in my case, because the drawing code in SimplePhysics is very basic and I was only using around 25 methods from the OpenGL API.

I put the code up on Codeplex, so feel free to download it and check it out. It’s licensed under the MIT License, so you can do whatever you wish with the code. It also includes a simple Windows 8 application project that demonstrates how to use XAML based UI and OpenGL graphics together.

Asynchronous File I/O

This was the biggest hurdle for me. WinRT really enforces the idea that if you want to do some long running operation, you must do it asynchronously. This is understandable. They just want their apps to feel more responsive to users and really this is something that all devs should strive for anyways. However, in some cases it is quite a pain to convert working synchronous code to its asynchronous equivalent.

For example, nearly every game ever written persists the user’s settings to a file. In SimplePhysics, this is just a handful of saved blueprints and is only a few kilobytes in size at most. This is hardly worth converting to asynchronous code because (a) it is only done on start-up, and (b) modern hardware can read a few kilobytes lightning fast. We’re talking milliseconds.

Unfortunately, in WinRT, all file I/O operations are done using the IAsyncOperation class. For instance, if you want to read a file, you’ll have to do something like this:

void ReadFile(Platform::String^ fileName)
   using namespace Windows::Storage;
   using namespace Concurrency;

   // First get the file...asynchronously
   auto folder = ApplicationData::Current->LocalFolder;
   task getFileTask(folder->GetFileAsync(fileName));

   // Then read the file...asynchronously
   auto readBufferTask = getFileTask.then([] (StorageFile^ f)  {
      return FileIO::ReadBufferAsync(f);

   // Then convert the buffer into something usable, like 
   // a std::vector......asynchronously
   readBufferTask.then([requestId] (Streams::IBuffer^ b) {
      auto a = ref new Platform::Array(b->Length);

      for (uint i = 0; i < b->Length; i++)

      // Now set a flag to indicate that _data vector is ready
      _dataIsReady = true;

The code in this method isn’t too complex. WinRT actually has some nice ways to handle async operations, as seen with the “then” method, but it can still have a significant impact on an existing, working, code base that is using synchronous file I/O. Initially, I started down this path of re-factoring SimplePhysics to use async file I/O, but it was just taking too long. At the end of the day, I found that even though WinRT doesn’t expose any synchronous file I/O, good old fopen, fread, and fwrite still work just fine. The trick is to know where to read and write your files. If you try to read or write from the wrong location, your fopen call will fail. I stored all of my user settings files in the LocalFolder, which is the “root folder in the local app data store.”

Here’s some code that demonstrates how to write to a file, synchronously, using fwrite.

auto localFolderPath = Windows::Storage::ApplicationData::Current->LocalFolder->Path;
auto filePath = localFolderPath + "\\test.txt";

FILE* file;
_wfopen_s(&file, filePath->Data(), L"w");
if (file) 
   unsigned char data[] = { 'a', 'b', 'c' };
   fwrite(data, 1, 3, file);

In Conclusion

Other than that, the port from iOS to WinRT was relatively straight forward and mostly painless, and it’s exciting to see SimplePhysics in the Windows 8 Store. I hope these tips will help some of my fellow indie devs, and if you have any questions feel free to contact me.

GoDaddy is Suboptimal for WordPress

Posted by on Oct 23, 2012 in Everything | 0 comments

I have a confession to make. I’ve been running a website on a shared GoDaddy web server for years. During that time I’ve really never had any problems. The tech support was fine. The performance was fine for my DotNetNuke blog and a handful of other ASP.NET pages that handle service calls from my iPhone games. I did seriously consider switching away from GoDaddy after the SOPA fiasco and the resulting backlash from the reddit community, but I did not. The thought of moving to a new hosting company was daunting and laziness took hold and squashed my desire to make a political statement.

Around a month ago, I decided to convert my DotNetNuke blog into a WordPress blog. WordPress is like a breath of fresh air after using DotNetNuke’s blogging module. The themes and plugins for WordPress are amazing and everything was going great until it became apparent that my shared web server was unable to handle the new platform. Several times a day the web site would timeout completely. I wrote a little app that pinged my web server and found that response times for a single blog page averaged around 13 seconds, with as many as 14% of the requests failing completely over the course of a day. This was unacceptable. I spoke with the GoDaddy support and they informed me that things would speed up a bit if I switched from a Windows server to a Linux server. That would be fine, except I was also running a few ASP.NET services for my iPhone games. I had to stick with Windows. They seemed to acknowledge that WordPress on Windows was slow, yet they still seem happy to sell that service with no up front indication that it performs terribly. The interwebs are filled with people complaining about the issue. Just to name a few.

I still tried desperately to make things work. I upgraded  to GoDaddy’s Ultimate 4GH plan and installed the WP Super Cache plugin (which is awesome, btw), but to no avail. It was becoming clear that a WordPress and GoDaddy were no longer an option. I started looking around to other hosting services and landed on GearHost. The process took about two days to get all of my stuff moved over, but overall it was not quite as painful as I thought it would be. The difference is nothing short of incredible. The average response times now are just over one second and I have yet to have a request fail. Not only is GearHost outperforming GoDaddy by a wide margin, but GearHost is actually cheaper than GoDaddy too. Here’s a break down in the comparison between the two services:

Service 12 Month Price Failed Requests Average Response Time
GoDaddy Ultimate 4GH $9.49 14% 13356ms
GearHost CloudSite $8.99 0% 1308ms

Here’s a graph showing requests over the course of a day between a WordPress blog page running on GoDaddy vs the same blog page rehosted on GearHost. Each bar represents the average of 6 requests, spaced 10 minutes apart, for that hour of the day.

I’m very happy that I finally made the switch. GearHost does have a weird delay with FTP, which is very frustrating, but other than that the service is solid and the tech support has been great.

Dummy Defense

Posted by on Mar 19, 2012 in Everything | 0 comments

Dummy Defense is a spin-off of the popular physics and engineering game, SimplePhysics. In Dummy Defense, you must use your engineering prowess to protect Melvin, the dummy, from an array of dangers, such as boulders, explosions, death pits, meteors, and more.  Using the same blueprints editor from SimplePhysics, the player must build a structure that is simulated using a physics engine in real time. Players can view how their design reacts in slow motion, fast forward, and they can even rewind time to pinpoint any weaknesses in their design. It’s an addictive game with a wide variety of levels, and players may even learn a few things about structural engineering along the way.

BridgeBasher for Android

Posted by on Jul 31, 2011 in Everything | 0 comments

BridgeBasher is now available for the Android platform! The game is ad-based and will be free for download. If you have an Android device, you can download it here:

Tags: android,bridgebasher

BridgeBasher Update with iPad Support

Posted by on Jul 11, 2011 in Everything | 0 comments

Last night I submitted an update to the app store that includes iPad support for BridgeBasher. The update will be free for everyone who has already downloaded BridgeBasher, but will not be available for BridgeBasher Lite.

I am also working on porting BridgeBasher to the Android platform. Things are going well, and I expect to be able to release it by the end of this month. If you have a less fortunate friend who has an Android device, be sure to let them know!

Tags: iphone,bridgebasher

New Level – Bomb Shack

Posted by on May 9, 2011 in Everything | 0 comments

I submitted an update this weekend for a new level for SimplePhysics, named Bomb Shack. In this level, you must build a small shelter to protect a crash test dummy from an indirect explosion. If the dummy gets blasted, or if he is struck by a falling support, then you fail. The level simulates realistic explosions, so you will have more success trying to create a slim, angled shelter to deflect the explosion, rather than a beefy shelter that absorbs it.

This update comes with more goodies though. Since I was creating explosions, I thought “wouldn’t it be cool if I could blow up all the old levels too?” So, I made it so. The finger test is now enhanced to let you create explosions on every level. Some are more fun than others, personally my favorite is the staircase level.

I also thought: “It would be awesome if the dummy supported ragdoll physics.” Be sure to play with him, he is a lot of fun. Throw him around, blow him up, he is quite entertaining.

After I implemented those features, I thought to myself: “Man, it would be extremely cool if I could slow the simulation down so I could watch the explosions in slow motion.” So, say hello to the slow motion feature. Watching explosions in slow motion is more fun than I anticipated, especially when it involves the new ragdoll physics.

This update has been so much fun to make and I think it opens up a whole new world to explore, so I am going to start working on a spin-off of SimplePhysics, tentatively titled SimplePhysics Bombs. Don’t worry, it will be free, and will have 5 to 10 levels, all similar in nature to this Bomb Shack level.

I hope you enjoy the update!

Tags: iphone,SimplePhysics

New Level for SimplePhysics – River Dam

Posted by on Apr 25, 2011 in Everything | 0 comments

I submitted an update for SimplePhysics last night that includes a new level, River Dam. In this level, you must create a dam that can withstand rushing water that slams into the dam, and some random debris that the water has picked up along the way. I hope you enjoy!

Tags: iphone,SimplePhysics

New SimplePhysics Update includes Universal Support for the iPad!

Posted by on Apr 19, 2011 in Everything | 0 comments

I submitted an update to Apple last night that includes universal support for the iPad. I must say the game looks quite nice on the larger iPad screen, and I think you will agree when you see it!

I want to mention that I could have released a separate app, solely for the iPad (i.e. – SimplePhysics HD) and jacked the price up, but I believe that my users deserve better than that. I have received so many great ideas that I felt compelled to give you all something extra at no cost. In fact, I feel more and more like SimplePhysics is becoming a community effort. Please, if you have any ideas for the game, visit my uservoice page. Let’s build a game together ;)

Tags: iphone,SimplePhysics

Two New Levels for SimplePhysics

Posted by on Apr 13, 2011 in Everything | 0 comments

I just submitted an update to Apple last night with two new levels:

Two Story Tree House

So you can build a tree house, but can you build one with two floors?



In itself not so exciting, until you throw in advanced robotics to smash your design to pieces! Also, I think you will rather enjoy the surprise I threw into the finger test for this level.


Tags: iphone,SimplePhysics

How I got to #7 in the App Store

Posted by on Apr 5, 2011 in Games, iOS, Marketing | 0 comments

I wanted to share my experiences over the past week, as a beacon of hope to my fellow indie game devs, as I sit here watching an app that I created sitting comfortably in the App Store’s Top 25 Overall.

The name of the app is SimplePhysics, and it became available in the app store Thursday (3/24/2011). I have been preparing for this moment for a few months now, starting back in December of 2010. I implemented a dialog popup in my other games that asked the user if they’d like me to e-mail them when I released a new game. Since that time, amazingly, I have been able to collect over 35,000 e-mails. This is largely due to a promotion I did with FreeAppADay.com, who I highly recommend if you want to boost your fan base.

I created an e-mail campaign at Campaign Monitor, and loaded in my list. I created an extremely basic e-mail, and got everything ready to pull the trigger.
Here’s the e-mail:


This is Andrew Garrison, the creator of BridgeBasher.
I am excited to let you know that BridgeBasher’s sequel,
SimplePhysics, is now available in the App Store! If
you like BridgeBasher, then you will love SimplePhysics.
You can find out more about it here:


Thanks, and I hope you enjoy it!

ps – If you do not wish to receive e-mails about my game
releases in the future, you can unsubscribe here.

At the same time, as I was setting up this e-mail campaign, I tweaked my other app, and I removed the e-mail signup dialog and replaced it with a dialog that linked directly to my new app. I submitted the update to Apple, and set it to “Hold for Developer Release.” Now I had all of my ducks in a row. When I release these updates, and my existing user base loads up the new version, they will immediately be hit with a dialog telling them about my new game, along with a link directly to the iTunes page where they can buy it.

SimplePhysics went live Thursday, March 24th, and I sat on it for a few days to make sure it propagated to all app stores worldwide. Last Wednesday, I pulled the trigger. I sent the e-mail and I logged into iTunesConnect and released all of my app updates. After less than 12 hours, SimplePhysics rose to #12 overall in the iTunes App Store. I had complete refresh-syndrome….constantly holding my iPhone, checking the charts every other minute. I watched in complete amazement as SimplePhysics rose to #1 in Games->Simulation, ousting NBA Elite, a game made by friggin Electrnoic Arts. It is almost euphoric to see a game that I made sitting on top of a game made by EA.

For those of you who are interested, these are the numbers for the e-mail:

35,704 e-mails sent
13,558 opens
1,574 bounces
20,572 not opened (misleading statistic, since some email clients block the tracking image)
334 people unsubscribed
45 people marked it as spam
6,182 clicks through to the iTunes purchase page from the e-mail

I do realize that this rise on the charts is fleeting. I realize that once all of my e-mails are opened, and once all of my users have updated, that the game will start quickly falling from the charts. Nonetheless, it is still extremely exciting, and I hope it will encourage my fellow indie game devs. The app store is such a great opportunity for indie game development. It is the only place that I know of where a little guy like me can outsell a major game company.

If you want to see the app, here’s the product page for it: