invaders: remove useless shots table
this commit removes the now useless table gamedata.shots and replaces it with a single variable of the name gamedata.shot
This commit is contained in:
parent
2a839ad875
commit
7c20b14ce5
|
@ -46,7 +46,6 @@ gamedata.field.h = 400
|
||||||
gamedata.field.w = 600
|
gamedata.field.w = 600
|
||||||
gamedata.running = false
|
gamedata.running = false
|
||||||
gamedata.ammo_max = 1
|
gamedata.ammo_max = 1
|
||||||
gamedata.shots = { }
|
|
||||||
gamedata.highscore = { }
|
gamedata.highscore = { }
|
||||||
gamedata.enemies = { }
|
gamedata.enemies = { }
|
||||||
gamedata.enemies.h = 10
|
gamedata.enemies.h = 10
|
||||||
|
@ -108,11 +107,8 @@ function shots.fire (x, y, color)
|
||||||
y = y })
|
y = y })
|
||||||
s.screen = 1
|
s.screen = 1
|
||||||
|
|
||||||
for i = 1, gamedata.ammo_max do
|
if not gamedata.shot or gamedata.shot.screen == nil then
|
||||||
if not gamedata.shots[i] or gamedata.shots[i].screen == nil then
|
gamedata.shot = s
|
||||||
gamedata.shots[i] = s
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -141,8 +137,7 @@ function shots.handle()
|
||||||
|
|
||||||
gamedata.ammo = gamedata.ammo_max
|
gamedata.ammo = gamedata.ammo_max
|
||||||
|
|
||||||
for i = 1, gamedata.ammo_max do
|
local s = gamedata.shot
|
||||||
local s = gamedata.shots[i]
|
|
||||||
if s and s.screen then
|
if s and s.screen then
|
||||||
gamedata.ammo = gamedata.ammo - 1
|
gamedata.ammo = gamedata.ammo - 1
|
||||||
local g = s:geometry()
|
local g = s:geometry()
|
||||||
|
@ -154,7 +149,6 @@ function shots.handle()
|
||||||
s:geometry(g)
|
s:geometry(g)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
gamedata.field.status.text = gamedata.score.." | "..gamedata.ammo .. " "
|
gamedata.field.status.text = gamedata.score.." | "..gamedata.ammo .. " "
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -215,10 +209,8 @@ function enemies.setup()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, gamedata.ammo_max do
|
if gamedata.shot then
|
||||||
if gamedata.shots[i] then
|
gamedata.shot.screen = nil
|
||||||
gamedata.shots[i].screen = nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, gamedata.enemies.shots.max do
|
for i = 1, gamedata.enemies.shots.max do
|
||||||
|
@ -247,9 +239,8 @@ function enemies.handle ()
|
||||||
game.over()
|
game.over()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if gamedata.ammo < gamedata.ammo_max then
|
if gamedata.ammo == 0 then
|
||||||
for i = 1, gamedata.ammo_max do
|
local s = gamedata.shot
|
||||||
local s = gamedata.shots[i]
|
|
||||||
if s and s.screen and game.collide(e, s) then
|
if s and s.screen and game.collide(e, s) then
|
||||||
gamedata.enemies.number = gamedata.enemies.number - 1
|
gamedata.enemies.number = gamedata.enemies.number - 1
|
||||||
e.screen = nil
|
e.screen = nil
|
||||||
|
@ -269,7 +260,6 @@ function enemies.handle ()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
local x = math.random(1, gamedata.enemies.count / gamedata.enemies.rows)
|
local x = math.random(1, gamedata.enemies.count / gamedata.enemies.rows)
|
||||||
if gamedata.enemies.speed_count == (gamedata.enemies.speed - 1)
|
if gamedata.enemies.speed_count == (gamedata.enemies.speed - 1)
|
||||||
|
@ -381,9 +371,7 @@ function game.quit()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, gamedata.ammo_max do
|
if gamedata.shot then gamedata.shot.screen = nil end
|
||||||
if gamedata.shots[i] then gamedata.shots[i].screen = nil end
|
|
||||||
end
|
|
||||||
|
|
||||||
for i = 1, gamedata.enemies.shots.max do
|
for i = 1, gamedata.enemies.shots.max do
|
||||||
if gamedata.enemies.shots[i] then gamedata.enemies.shots[i].screen = nil end
|
if gamedata.enemies.shots[i] then gamedata.enemies.shots[i].screen = nil end
|
||||||
|
|
Loading…
Reference in New Issue