Let's get started with introducing the variables we'll be using to create our game. There will be a combination of display objects and integers to keep count; we also need to preload the main sound effects used during game play. Follow the steps to declare all the required variables:
display.newGroup()
group called gameGroup
:display.setStatusBar( display.HiddenStatusBar ) local gameGroup = display.newGroup()
local physics = require "physics"
local background local ground local charObject local friedEgg local scoreText local eggText local livesText local shade local gameOverScreen
local gameIsActive = false local startDrop -- Timer object local gameLives = 3 local gameScore = 0 local eggCount = 0 local mRand = math.random
local eggDensity = 1.0 local eggShape = { -12,-13, 12,-13, 12,13, -12,13 } local panShape = { 15,-13, 65,-13, 65,13, 15,13 }
system.setAccelerometerInterval( 100 ) local eggCaughtSound = audio.loadSound( "friedEgg.wav" ) local gameOverSound = audio.loadSound( "gameOver.wav" )
We continued creating a similar set up of our variables, like we did in the Panda Star Catcher game. It's more efficient to organize them by separating groups, display objects, audio, and so on.
Many of the variables displayed have designated integers that fulfill the goals of game play. This includes values such as gameLives
=
3
and eggCount
=
0
.