Great news! We passed Apple certification for our Scrap Metal app for the iPad, iPhone and iPod Touch! The game will be available on the App Store on Friday the 11th of March for $2.99, and it will run on all devices that support OpenGL ES2 (iPhone 3GS and up, iPod 3rd generation 32Mb and up, and iPad and up). It supports the Retina display, and Game Center and it is also a universal app, so if you have an iPhone and an iPad, you only need to buy the game once!
So let’s talk a bit about what we did to make Scrap Metal a great experience on these devices. This is quite a long devblog post, and I should probably have split it up into multiple posts, but alas. I’ll put some screenshots of the iOS version of the game in between the text so it doesn’t seem so long. :) In fact here is one right now:
There are a few obvious differences between iOS devices and the Xbox 360. One is the control method, another is how the game is played, and of course technical differences. First, I’ll talk about the control method.
For the Xbox 360 version of Scrap Metal, we had two modes for steering: directional and remote control. In directional mode you push the stick in the direction you want the car to go, and in remote control mode you steer the car as if it’s a remote control car, so moving the stick left makes the car turn left from its own perspective. When we started on the iOS version of the game, we decided to look at some other games out on the App Store, and noticed that there’s a wide variety of steering methods out there.
The first method we tried was a steering wheel and an accelerate/brake button. We had some friends try it out, it quickly became obvious that it was next to impossible to steer a car around a track without slamming into the walls. So this was a no-go.
The second one we tried was tilting the phone to steer. The car accelerated automatically and you could brake by pressing the screen. This was a little better, but people still had problems getting the car around the track. Still not good enough!
The third and last method we tried was an adaptation of the directional steering controls in the Xbox 360 game. We basically made car drive towards where you point. If you point directly behind the car, the car will backup towards your finger. When we had people try this method, it was instantly clear this was the way to do. It even passed the girlfriend-test!
Ok, so now we had cars driving around, but how were we going to assign all the other buttons of the Xbox 360 controller? We decided to put nitro under a double tap. If the car is driving towards your finger, simply double tap and the car will fire a nitro (if you have nitro’s left, of course). Firing weapons was a bit of a tricky one, but we settled on automatically firing the weapons when there is something in front of you. This meant you could mostly concentrate on steering the car, and you didn’t really have to worry about shooting at the same time.
This ties nicely into the earlier point about how the game is played. For iPhone, iPad and iPod Touch, the general audience seems to be way more casual than for the Xbox 360. People want games to be simple, easy to understand, and quick to pick up. They want to be able to turn the game on for a few minutes while they are waiting for the bus or train for example. This made us look at our controls and our game in an entirely different light. We changed our controls to be as simple as we could make them, and we decided to add a quick-play mode. In quick-play mode, you could simply select a pre-made mission, and you were racing. Very few menus to go through before you are racing, and the mission only lasts for about 2 to 3 minutes. Perfect bite-sized action for your iPhone!
Then we looked at our campaign. The campaign for the Xbox had a few missions that were impossible to finish with the new control method on iPhone. We were struggling with properly getting the campaign to work for a long time. We tested the game over a few weekends, and on the Mondays we’d come in with a long list of bugs and things that needed to be improved. On one particular Monday Kees coined the idea of taking the entire campaign out of the iPhone game. At first I was a bit reluctant, because we had spent so much time creating the campaign in the Xbox version that it felt hard to take it all out. We decided to make a bunch more quick-race missions, and to remove the campaign from the game for the time being. Once we had the quick-races in place, I hooked up the Game Center leaderboards, and we started playing. It was a lot of fun, and we were battling for the top leader-board spots within the first few plays. This felt ‘right’, this is what the iPhone game should be, and Kees was totally right. So we developed it a bit further, and we decided to add four categories of race types: Race, Derby, Survival, and Time Trial. Each of these types has 5 different missions, and each one is hooked up to a separate leaderboard. Game Center Achievements are also hooked up to completing an entire set of mission types with a gold medal. We think this new quick race setup is a big improvement over our campaign based setup.
Now, for those that have been waiting for it, the technical stuff! In the Xbox 360 version of Scrap Metal we made heavy use of deferred rendering. Because even on the Xbox 360 this method is shown to be quite performance critical, we thought this would very likely be too slow on iOS, so we decided to switch to a forward shading method. We baked all our lighting into our textures, and we reduced the polygon counts on our meshes. This made the lighting look good, with the restriction that the lighting is static. This meant we lost the ability to change the lighting per mission, something we regularly did on the Xbox 360 version.
The next problem was the framerate. I thought it was actually running surprisingly fast for a mobile device, around 15 to 20fps, but obviously not fast enough to ship with. So we had to do a few more optimizations. The most notable one was to pack all our textures into texture atlases. We use a 2d-box-packing algorithm that can efficiently pack all the little textures into one giant texture, so we don’t need to switch textures with every draw call. This sped up the game by a few frames per second.
Another optimization was to be smarter with alpha polygons. Alpha blending is a lot slower on iOS devices than on the Xbox 360, so it’s critical to reduce the number of alpha polygons. After reducing the number of alpha polygons the game started to run fast.
Another problem we encountered was excessive loading times. For the Xbox 360 we used to load all data at the start of the game. The data was heavily compressed on disc, so when we read the data, we ran a de-compressor on another thread to unpack the data into memory. We had this running on the iPhone, but it turned out to be extremely slow. Loading times were upwards of 20 seconds, and, more importantly, we were keeping all the data around in memory all the time. Bad idea on a mobile device. So after a bunch of tests, and after reading John Carmack’s blog about Rage, we decided to try the memory-mapped-file method. I made a tool that combined all the data files into one big uncompressed archive, and we memory-mapped this file in the game. This means that we didn’t need to allocate any memory to load data, the system would take care of actually loading the file into the memory addresses we were accessing. This turned out to be a huge improvement. These iOS devices are bloody fast when it comes to streaming! In my test app I sequentially loaded a data-file of 600Mb, and I got average speeds of about 300Mb/s. That’s insane! So our loading times went from 20 seconds to hardly noticeable. We now unload all the game data when in the menus, and we unload all the menu data when we’re in game. The loading screens between these two states had to be artificially padded with a second or two so that it didn’t look like a bug. Seriously awesome. I am planning to use this system a lot more in future games, streaming data is the way to go for these devices.
Now lastly a little note about the ‘universal binary’ as Apple calls it. This means that the same app will run on iPad, iPhone and iPod touch. Every time I bought a game on my iPhone and I had to buy an ‘HD’ version of the game for my iPad for two or three times the price, I felt cheated. So early on we decided that the universal binary was the way to go for our game. Since our user-interface system can handle different aspect ratios (iPhone and iPod touch are 3:2, iPad is 4:3), and most of our game is in 3D, we felt that there was really no reason to be charging more for an HD version when we don’t have to do any work at all to make it HD.
So that’s it, I am done writing what I wanted to write. Let us know what you think of Scrap Metal iOS!
(PS: we’re working on an Android version for all you Android fans!)