How I made my 737 Flight Simulator

How I made my 737 Flight Simulator?

You might wonder how it is possible to write your own game if you have full time job, family and no spare time. It is actually possible. How I did that? I did that in tube. What is tube you might ask if you don't live in London. It is a train that connects you between your house and your daily job. In London it takes me 36 minutes to get to work via train. If you double that time you can get up to over 1h everyday to do your stuff. Some people read, some play games but I am programmer so what could I do? My macbook pro 13" is small enough to fit in a backpack and it takes me 2 seconds to take it out or put it back. 

Ok so as you know how I saved every single second of my time let's focus on my engineering process that lead me to create my game.


First, the concept.

I was always interested in aviation, it started when I saw the discovery series called Air Crash Investigation. It was so absorbing so I think I watched every single part that was emitted in TV. It was little scary to fly with a plane after watching all these crashes but it was a good learning exercise how all these things work.

Recently I started wondering why there is no single game that shows realistic crashes of the planes. I did some research but couldn't find one. There are many good simulators but when it comes to the crash, it's just awful. Then iOS7 has been announced with SpriteKit, so I thought it is a great opportunity to learn new apple's technology and write good airplane crash simulator.



One of the biggest challenges for me was how to make physics simulation looking nice with limited cpu power so the app could run on iPhone4 which was one of my testing devices. Since SpriteKit is supporting physics engine my initial decision was to use it so I would have complete graphics solution in place.


First steps.

As a proof of concept I realised I need to create a plane that could be crashed. Since SpriteKit physics is based on box2d I started looking at all available tools for modelling box2d objects. There were a couple of alternatives but the most interesting one I found was R.U.B.E. (Really Useful Box2D Editor). So my wife bought it for me and I tried to create my first plane. I have been using box2d before in my "Robot Saga: Diamond dash" game but this time it was much more complicated than I thought initially. Since I didn’t know what I could do with SpriteKit initially I modelled my first plane as a collection of distance joints to see how it behaves. I spent like 3 hours trying to create my first model. Then I ran simulation mode in R.U.B.E. It was a total disaster. The “plane” collapsed immediately without any interaction. How could a collection of springs work without any solid mass inside? It was so naive. Ok so I thought about what I learned at school and realised I need to have multiple bodies connected together with weld joints. Weld joints can be destroyed manually during runtime as I have learned when I was making my robot game. So keeping that in mind I created initial structure of bodies connected with joints. It was an iterative process. I had to learn a lot about planes and their masses to make appropriate model for my new game. 


I ended up with:

The aviation rules.

It was the most difficult and also enjoyable part. All the 737 laws and forces like lift, drag, move and thrust were so beautiful so I enjoyed every single second when I was making all these calculations. As a base for the initial plane I took 737-700NG model. The next generation 737 planes are just gorgeous. 

Once I created my plane model in R.U.B.E. I wanted quickly to try it with the new SpritKit engine. At the time I was doing that I was working with some early beta version of new iOS7. I created a special importer for my model. R.U.B.E. was able to export all necessary data in raw format so I could easily convert it to new SpriteKit object collection. Everything was going well. Eventually I had my 737-700 showing up in SpritKit view so I could work on the physics and make it flying. After some time I had simple version of my new engine ready. Initially it was just a plane with horizontal line as a terrain. 



Next step was to focus on graphics elements. I was never involved in graphics design so all I know I learned by myself. I realise it’s not perfect but I am still trying to learn it. I created airport and grass images, I found some great free resources which I could also use. Initially I thought it will be just a collection of predefined tiles but then I realised I need to generate terrain dynamically. I created a special mathematical function to generate terrain height so I could easily make different terrains with minimal number of variables. In the end it was a collection of different sinus and cosinus functions. Once I had this function I could probe it every X meters and place a sprite of a terrain. These sprites combined together generated nice dynamic terrain effect.  

After I created terrain I had to do the plane indicators. How would you control a plane without them? I focused only on indicators which were totally necessary to fly a plane like horizon, vertical speed, airspeed, altitude and thrust power. I wanted my game to be very simple so even people with simple knowledge about aviation could play it easily.

All these indicators were hand made and are drawn from code. That way I could scale them easily on iPad where the resolution is really big, especially on retina displays. 


Big disappointment.

Everything was working well, I had my plane flying, all my indicators in place. I was about to start working on levels and game logic, but then I had a big disappointment. 

BOOM, my plane exploded, yes it was like that when I installed new version of iOS7. With new beta apple did a great job with fixing a lot of issues, unfortunately they also introduced some scheme changes to SpriteKit. I had to redesign things a bit, it took me a couple of hours to recover to the previous working state. I was happy with result so I focused on the logic. My happiness didn’t last for long because new iOS7 beta was out there in next 2 weeks. This time like previously it was a total disaster for my plane game. All the physic was just broken. When a plane was crashing, the game was hanging for 5 seconds due to box2d solver issues which I had no control over at all. I realised I need something stable so even apple changes it’s internal physics implementation it would still behave the same way. So I started redesigning my game to use original box2d implementation. It was really convenient to use SpriteKit because physics engine they used (box2d) was wrapped very well with Objective-C language. But, I had to change to something I could control. So my natural choice was box2d. I though I need to create new importer just for box2d, but then after some research I found R.U.B.E. creator Chris Campbell created special class to import everything into a convenient structure (b2dJson class). I am really satisfied with the service Chris provided. He was responding to issues in 10 minutes after I submitted them. He is very knowledgeable person to ask about box2d related stuff.

So I used b2dJson to import my model and converted everything to native box2d solution. Since that time I had no issues with my physics behaviour. Probably now with official version of iOS7 the physics engine is much more mature so it should be fine for you to use. I really encourage everyone to use it because of it’s Objective-C nature.



As I learned a lot from Air Crash Investigation series I decided to create missions based on real life events. In the game you will find missions like President Flight to Smolensk, Famous landing without gear in Warsaw or landing on Hudson River. Main purpose of the game is to save the plane. My idea was to show people how hard it is to actually to control the aircraft when unexpected events occur. You can imagine that pilots do enormous job to save their aircrafts.  


Happy ending.

I really enjoyed this project, I received a lot of good words about it for which I am very thankful. It was made with great passion so I hope you will enjoy it as I do since there is part of my heart inside.


I made this game for my loving wife and together we dedicate this game to all who lost their lives or suffered injuries in airplane crashes.

You can follow me on twitter and like 737 Flight Simulator on facebook.

If you want to download my simulator click this iTunes link.