First Session with Corona Game Development Platform

Before reading this article please note that I don't have any prior experience with Corona SDK or game development . I do have considerable experience in developing applications for Android mobile. I am learning Corona to develop games for Android.

To start game development on Windows using Corona SDK, I first installed IntelliJ IDEA 10.0.3 IDE (JDK version is 1.6.0_21) which is about 90mb. I was trying to find support of Corona API on other Java IDE's (particularly Eclipse IDE because I am used to it) but I couldn't find one. Next I installed Lua For Windows
which is a complete all-in-one Lua scripting language environment on Windows. Lua is actually a light weight programming language which will be used in development of games. Corona is actually and API built on top of Lua. Then I downloaded Corona SDK from ANSCA Mobile's website. Since I am interested in development on Windows I am downloading Corona SDK for Windows. You have to register on their website before downloading it. Finally I installed Corona API which is developed by sylvanaar.

The Corona Simulator would look something like this



To enable Lua support on IntelliJ IDEA , I had to first install Lua Plugin. To install Plugin
Goto -> File -> Settings (Ctrl+Alt+S) -> Plugins -> Available Plugins
Select Lua and install it.




Okay, the setup and environment settings are now complete. I am now going to start building a test application in it .

Goto -> File -> New Project -> Create Project from Scratch
After that select it as a Lua Module, which facilitates in developing Lua applications




After Pressing "Next" it'll ask you to configure Lua SDK version. By default KAHLUA is selected but you should configure it to use your Lua SDK.

Press "Configure" -> Click on the "+" button and add your Lua SDK which is probably located in "C:\Program Files\Lua\5.1" (See below screenshot)





After that click on Lua 5.1.4 SDK you have just installed and add "Corona API" to the classpath (See screenshot below)






Press "Finish" and Select Lua 5.1.4 as your Lua SDK. Your Project will be created. Right Click on it and create a new Lua Script file and name it "main.lua" (which is the main lua file which gets executed.)




I also created a config.lua file which is a configuration file and wrote the dimensions of the the mobile on which this application is made. I also configured it to scale the content to other mobile dimensions while keeping the same aspect ratio.

My config.lua file consists of this

application =
{
content =
{
width = 320,
height = 480,
scale = "zoomEven"
}
}

In main.lua file, first I am just going to add a background so I write

local background = display.newImage("background.png")

I save the file and Run it ... Press Run ->Run (Alt+Shift+F10). It should ask for Run configurations. Click Edit configurations -> Defaults-> Lua Script -> And Select Path for Corona Simulator.exe (Screenshot below)






After that click OK -> Apply and Run Again . This time click main.lua to run the file . It should load the Simulator, with the background in it . (See screenshot below)








One thing I like about this IDE and Simulator is that, whenever you make any changes in the IDE, you don't have to save it. It does that automatically. And you don't have to run the Project again and again. Just goto the already opened Simulator and press Relaunch (Ctrl+R) and it reloads with new changes integrated in it


Now, I am going to add some grass on the floor. So in main.lua script add this

local ground = display.newImage("ground.png")
ground.y = display.contentHeight - ground.height / 2

Then I add one crate in it

local crate = display.newImage("crate.png")
crate.x = display.contentCenterX

Then using physics library I am making ground as stationary object and adding crate to it

local physics = require( "physics" )
physics.start()
physics.addBody(ground, "static")
physics.addBody(crate)


When I Relaunch the Simulator I get crate falling and bouncing off the ground



Hmm, this was my first official encounter with Corona SDK. After initial setup of the environment, it seems a good platform for game development. Well on the other hand, there are no Corona books available which might help me in game programming. Also the documentation is not so good, and the IDE support is also very limited at the moment. I'll expand this tutorial and add more features to it as I learn Corona.

P.S. There is a directory called "Sample Code" in Corona SDK Path, which contains sample Corona applications. They can be useful in learning.



Comments