Recently the first games written directly on the iPad appeared in the App Store, which personally makes me very happy. We can say that the tablet becomes not only a means of consuming content, but also its production.

Under the cut, I'll tell you how and where it is done, I will show a simple Hello World.
For everything described above, the Two Lives Left company, which created the Codea mobile development environment, is responsible. Codea is an ipad application that contains a handy code editor and simulator. All this joy can be obtained for $ 10 in the app store. Not a little, but this application is worth the money.
')
So, let's start in order to understand what it is and what it is eaten with.

Lua
Codea uses the Lua programming language.
Lua (Wikipedia):
In terms of capabilities, ideology, and implementation, the language is closest to JavaScript, but Lua has more powerful and much more flexible constructs. Although Lua does not explicitly contain the concept of a class and an object, object-oriented programming mechanisms that support prototypes (including multiple inheritance) are easily implemented using metatables, which also allow operation overload, etc. The OOP model to be implemented (as in JavaScript ) - prototype.
Development environment
Codea contains a nice code editor (it is possible to buy additional designs). There is a handy add-on above the keyboard that allows you to open the knowledge base and place the necessary characters. A fairly large set of sprites is available, which have already adapted to the retina screen of the new iPad.


Simulator
There is a rather convenient built-in simulator that can give odds to many simulators of other operating systems on a PC. There is a place for specifying parameters, which is extremely convenient when optimizing gameplay, the ability to record video, or take a screenshot.
Hello world
So, after my rather long introduction, let's get down to business. I will try to show how easy it is to make a little Hello World right on your iPad.
Task: make a display of multi-colored circles under the user's fingers (a kind of multi-touch test)
Perhaps we will begin. First of all we go to the function that is called when the application is started and add the creation of an array of touches there.
function setup() touches = {} end
Next, we move to the function that is responsible for touching the screen (called when a new touch appears, which in the Codea is simply called touch). While touching the screen, we add a touch to the array, and during its termination we remove it. Everything is extremely simple.
function touched(touch) if touch.state == ENDED then touches[touch.id] = nil else touches[touch.id] = touch end end
So, we have an array of active touches. What should be done next step? Right, draw circles with the center at the touch point.
To do this, we need to go to the function draw, which is called when the frame is drawn.
function draw()
Everything is done.
Result:

Epilogue
Codea is not a tool for developing something ultra-complex and big, but it is an ideal tool for indie developers who are starting to discover the apple technology market. Fortunately, since recently, the opportunity has appeared to publish their Codea applications on the App Store, but it’s not without the help of Mac.
And yet, I would like to say that I am very pleased with the trend that has appeared recently. The emergence of new languages ​​in which you can write under iOS can not but rejoice.
Thanks for attention.
Partially used is the source code of the example called “Multi Touch”.