From bedroom to App Store: How I made an app on my iPad
Using Lua development tool Codea
Codea is an iPad app that enables you to make things like "simulations, visual ideas, and interactive creations".
In the app's screenshots, people are shown messing around with code and making basic games.
What I wanted to know was: could I make a full iOS game with this app, release it on the App Store, and then make enough money to cover Codea's £6.99 / $9.99 price tag?
That was my goal. First, though, what does this app actually do?What is Codea?
Well, Codea offers you a way to write programs in a straightforward - but still powerful - programming language called Lua. It's a nice language, so a lot of the abstract, hard-to-remember syntax and special characters that you see in other programming languages are done away with here.
Codea features a number of handy tools: you can search through your code; you can utilise a handy rack of extra buttons on top of the keyboard for oft-used characters; and you can mess with key iPad functionality like multi-touch, the accelerometer, keyboard, and camera.
Most importantly, you can run your code on the iPad. Your game starts instantly, and you can see how it runs or what it's like to play immediately.
If you were making an app the normal way, you'd have to run your game in an iPhone simulator on your Mac, or go through an annoying process of sending new builds to your device.Getting started
Being a complete programming newbie, I decided that my game would have to be something relatively simple.
I wanted to make a game full of those brilliant logic puzzles from Japan called nonograms or picross puzzles. Most of the picross apps on iOS leave a lot to be desired, and I was sure I could produce something better.
My game had to work on iPhone and iPad as a Universal app; be free but have in-app purchases; and have all the functionality you would expect from a picross game.
I didn't know much about code. I did know about 'if statements', 'for loops', functions, and classes, mind, which are almost like the grammar elements of programming. But that's about it.
In Codea, there's an extensive cheat sheet, with descriptions and example code for almost every function. Plus, there are example programs, including a game called Cargo Bot that was released on the App Store. All that said, I had to turn to some online tutorials to get started.
So, don't be fooled into thinking that making an app in Codea will be easy. It still requires thousands of lines of programming code, a great number of hours of work, and dedication.Writing code
Something that threw me a little is the fact that every line of your code under the 'Draw' function actually runs 60 times a second (the frame rate of the iPad).
It makes sense that you want your display to refresh at the same speed as the device, but it's quite hard to get your head around. You need to think about whether you want your code to run once (like when you're generating the puzzle), or run consistently (like when you're displaying the screen).
But other than that, programming in Codea is a comfortable and enjoyable experience. You're given all the tools you need to make a game - it's down to you to figure out how to use them.
For me, programming is like playing a puzzle game that doesn't have a creator. There is no level designer who has a very specific solution for you to find. All that matters is that you get to the right answer - how you get there is up to you.
There are a hundred different ways, for example, to make a program that can 'read' the blueprints for a picross puzzle and then turn it into a functioning playable puzzle.
My solution was to list the puzzles as long strings of '1' and '0' digits, where '1' was a tile you had to hit and '0' was one you should avoid. Then, the code would read through that string, one character at a time, and set different parameters for each cell based on whether it encountered a '0' or a '1'.
But you could potentially do it by making the code read pixels in an image, or come up with a clever algorithm that lets you store the puzzles as something shorter than a 100-digit long number. It's up to you.Codea drawbacks
There are certain limitations with Codea, though. If you want to use pinch and zoom, for example, you'll have to code it yourself. By contrast, touch gestures are as simple as clicking a button in Apple's Xcode developer program.
Codea also has a habit of slowing down if you draw too many individual sprites on the screen at once. This meant I had to program it so those 100 picross tiles were stored in a single mesh object. That certainly complicated matters.
You can't use custom fonts in Codea, either. So, I had to build a text class from scratch to get that authentic pixel-art lettering. Oh, and you can't use custom sounds in Codea. There's a synthesizer, sure, but if you've played my game, you'll know it's not very effective.
Codea is, however, consistently getting updated with new features. The app I used at the beginning of the project and the app I used just before submitting my game to the App Store were two very different beasts. Proper sound support, for example, is definitely on the way.Finishing touches
So, skip forward through several months of programming and a lot of testing, and we have Pixel This!, my new picross game. The next step is to hit 'Export', which gives you a file you can open in Xcode.
Now, if you want to release a paid game without special features like iCloud save games or Facebook support, you simply need to set an icon and a launch image, and send it off to Apple for review. Job done.
But I wanted to include in-app purchases in my game and the option to post about the time it took you to finish a puzzle on Twitter. For those, you need Apple APIs - StoreKit and Social, to be precise - to which you cannot gain access from within Codea itself.
A right clever clogs named David Such has, luckily, come up with a way to use such tools. His code essentially enables Codea's Lua code and Xcode's Objective C to 'talk to' each other.
So, you might, for instance, run a function in Codea like restoreIAPs. Xcode will pick that up, run the relevant code (calling up the App Store and seeing which level packs the player has previously purchased), and then send the data back to Codea.
Right now, David's tutorials only cover Game Center and iAds. But with a little tweaking - and a lot of help from my infuriatingly smart (and app developer himself) brother - I managed to convert the Game Center code to work with Twitter and IAPs.
All that was left to do was submit my game to Apple. No easy task, mind you, for it involves several contracts, lots of menus, and a few headaches. But the app got through Apple approval without a hitch, and Pixel This! hit the App Store on September 26th.Next steps
I got my first sales figures on September 27th, and I was pretty pleased. I had a few thousand downloads, a handful of in-app purchases, some kind reviews, and - yes - enough money to pay for Codea (and, a few days later, my Apple developer licence).
An app developer's work is never finished, though. The game crashes on iOS 5, people want more level packs, and all sorts of other feedback. The latest Pixel This! update is now with Apple and should be available soon.
If you've used those aforementioned Apple APIs, making an update to your app in Codea's is tricky. If you go back to your iPad and export your code again, you'll lose all your IAPs or Game Center support or whatever. So, you have to edit the code in Xcode (without any helpful colours or autocomplete to guide you. Eep).
I'm proud of Pixel This! I set out to make the best picross game on the App Store. And while I don't think I've quite accomplished that ambitious goal, I think I've at least done justice to the brilliant Japanese puzzle game I blatantly ripped off.
And I'm also very impressed by Codea. It has its limitations, of course. For a new coder who wants to get something up on the App Store, however, it's an incredibly powerful tool and I'm glad to have found it.
Whether I use it for my next app or 'graduate' to something like Xcode or Unity remains to be seen.
Best upcoming mobile games in 2021