Baby Steps: Checking Out Corona

After some discussion about what a game is and what makes them fun, we rolled up our sleeves and took a look at our SDK (software development kit), Corona.

Why Corona? Well, mostly, it’s what I know. I’ve used xCode and GameSalad, and I can’t imagine either working very well for our needs. Lua (the language that Corona uses) isn’t super difficult, and, after you get the hang of it, it just seems to make sense. Although I know I’ll end up spending a lot of time proofreading and correcting code, I’m hoping we’ll have one or two naturals to do the bulk of the coding (I’m looking at you, Katie).

For those of you playing along at home, here’s the code from the sample app we made together:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
display.setStatusBar( display.HiddenStatusBar )
physics = require("physics")
physics.start( true )
physics.setGravity(0, 0)
middleX = display.contentWidth/2
middleY = display.contentHeight/2
math.randomseed(os.time())
math.random()
--physics.setDrawMode( "hybrid" )

leftWall = display.newRect( 0, 0, 10, 480 )
rightWall = display.newRect( 310, 0, 10, 480 )
topWall = display.newRect( 0, 0, 320, 10 )
bottomWall = display.newRect( 0, 470, 480, 10 )

physics.addBody(leftWall, "static", {density = 1.0, friction = 0.3, bounce = 0.2, isSensor = false})
physics.addBody(rightWall, "static", {density = 1.0, friction = 0.3, bounce = 0.2, isSensor = false})
physics.addBody(topWall, "static", {density = 1.0, friction = 0.3, bounce = 0.2, isSensor = false})
physics.addBody(bottomWall, "static", {density = 1.0, friction = 0.3, bounce = 0.2, isSensor = false})

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

function changeColor(event)
if event.phase == "began" then
randomRed = math.random(0,255)
randomBlue = math.random(0,255)
randomGreen = math.random(0,255)
event.target:setFillColor(randomRed,randomBlue,randomGreen, 255)
event.target:applyForce(math.random(-1000,1000),math.random(-1000,1000),0,0)

end
end

function makeBall()
ball = display.newCircle( math.random(100,300), math.random(100,400), 30 )
physics.addBody(ball, "dynamic", {density = 1.0, friction = 0.3, bounce = 0.2, isSensor = false, radius=30})
ball:applyForce(math.random(-1000,1000),math.random(-1000,1000),0,0)
ball:addEventListener("collision", changeColor)
end

function makeLotsOfBalls(howMany)
for i=1,howMany do
makeBall()
end
end

makeLotsOfBalls(10)
No comments

Comments are closed.