Ok, perhaps the title is not quite correct.
I am re visiting a game I shelved months back, it was shelved because it was an exercise in meta tables and OOP. However this is irrelevant to my question
what I need to happen:
I have a wave of aliens, when they are all destroyed another wave is spawned. I want the wave to spawn lower down the screen each time up to a maximum of 5 times.
So I need to change the variable value of the spawning aliens each time they are respawned.
I have the game working perfect , at the moment I am just re-running the main game after each wave is destroyed.
Here is some code(stripped down to relevant parts)
I need to change the
[lua] levelDrop = 70 [/lua] value
to 140 then 210,280,350 (increments of 70) after each wave is destroyed please.
So when gameover() is called it will begin with the updated levelDrop value.
MAIN.LUA
[lua]
– CREATE ENEMY –
local levelDrop = 70
function createEnemy(x, y, row)
for j = 1, 5 do
for i = 1, 5 do
allEnemys[#allEnemys + 1] = enemys:new()
allEnemys[#allEnemys]:init(i * 60, j * 70 + levelDrop, j)
allEnemys[#allEnemys]:start()
end
end
end
– GAMEOVER –
function gameOver()
Runtime:removeEventListener(“enterFrame”, onEnterFrame)
Runtime:removeEventListener(“enterFrame”, movePlayer)
display.remove(leftWall)
leftWall = nil
display.remove(rightWall)
rightWall = nil
display.remove(ceilng)
ceiling = nil
display.remove(floorWall)
floorWall = nil
display.remove(player)
player = nil
display.remove(aBullet)
aBullet = nil
enemyCount = 0
for i = 1,#allEnemys do
timer.cancel(allEnemys[i].clock)
Runtime:removeEventListener( “enterFrame”, allEnemys[i] )
display.remove(allEnemys[i].image)
allEnemys[i].image=nil
end
allEnemys=nil
allEnemys = {}
layers:removeSelf()
layers = nil
enableFire = true
print(" Hey gameover")
cleanupBlocks()
timer.performWithDelay(4000,runGame,1)
end
ENEMY.LUA
elseif enemyCount == 2
then
self.rightHit = 0
self.leftHit = 0
self.movement = 0
self.movement = 10
print(“less than 2”)
elseif enemyCount == 1
then
gameOver()
end
end