invaders: code cleanup
This commit is contained in:
parent
3895c0cde9
commit
adcf32f9ed
|
@ -45,7 +45,6 @@ gamedata.field.y = 100
|
||||||
gamedata.field.h = 400
|
gamedata.field.h = 400
|
||||||
gamedata.field.w = 600
|
gamedata.field.w = 600
|
||||||
gamedata.running = false
|
gamedata.running = false
|
||||||
gamedata.ammo_max = 1
|
|
||||||
gamedata.highscore = { }
|
gamedata.highscore = { }
|
||||||
gamedata.enemies = { }
|
gamedata.enemies = { }
|
||||||
gamedata.enemies.h = 10
|
gamedata.enemies.h = 10
|
||||||
|
@ -90,8 +89,8 @@ function player.move(x)
|
||||||
end
|
end
|
||||||
|
|
||||||
function player.fire()
|
function player.fire()
|
||||||
if gamedata.ammo > 0 then
|
if gamedata.ammo == 1 then
|
||||||
gamedata.ammo = gamedata.ammo - 1
|
gamedata.ammo = 0
|
||||||
gamedata.field.status.text = gamedata.score.." | "..gamedata.ammo .. " "
|
gamedata.field.status.text = gamedata.score.." | "..gamedata.ammo .. " "
|
||||||
local gb = gamedata.player:geometry()
|
local gb = gamedata.player:geometry()
|
||||||
shots.fire(gb.x + 9, gb.y - 10, "#00FF00")
|
shots.fire(gb.x + 9, gb.y - 10, "#00FF00")
|
||||||
|
@ -133,17 +132,15 @@ end
|
||||||
|
|
||||||
function shots.handle()
|
function shots.handle()
|
||||||
if not gamedata.running then return false end
|
if not gamedata.running then return false end
|
||||||
if gamedata.ammo == gamedata.ammo_max then return false end
|
if gamedata.ammo == 1 then return false end
|
||||||
|
|
||||||
gamedata.ammo = gamedata.ammo_max
|
|
||||||
|
|
||||||
local s = gamedata.shot
|
local s = gamedata.shot
|
||||||
if s and s.screen then
|
if s and s.screen then
|
||||||
gamedata.ammo = gamedata.ammo - 1
|
gamedata.ammo = 0
|
||||||
local g = s:geometry()
|
local g = s:geometry()
|
||||||
if g.y < gamedata.field.y + 15 then
|
if g.y < gamedata.field.y + 15 then
|
||||||
s.screen = nil
|
s.screen = nil
|
||||||
gamedata.ammo = gamedata.ammo + 1
|
gamedata.ammo = 1
|
||||||
else
|
else
|
||||||
g.y = g.y - 6
|
g.y = g.y - 6
|
||||||
s:geometry(g)
|
s:geometry(g)
|
||||||
|
@ -243,6 +240,7 @@ function enemies.handle ()
|
||||||
local s = gamedata.shot
|
local s = gamedata.shot
|
||||||
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
|
||||||
|
gamedata.ammo = 1
|
||||||
e.screen = nil
|
e.screen = nil
|
||||||
s.screen = nil
|
s.screen = nil
|
||||||
|
|
||||||
|
@ -484,7 +482,7 @@ function run(args)
|
||||||
|
|
||||||
gamedata.score = 0
|
gamedata.score = 0
|
||||||
gamedata.name = ""
|
gamedata.name = ""
|
||||||
gamedata.ammo = gamedata.ammo_max
|
gamedata.ammo = 1
|
||||||
gamedata.btheme = beautiful.get()
|
gamedata.btheme = beautiful.get()
|
||||||
|
|
||||||
gamedata.cachedir = awful.util.getdir("cache")
|
gamedata.cachedir = awful.util.getdir("cache")
|
||||||
|
|
Loading…
Reference in New Issue