invaders: clean code

this commits makes all enemies of a certain type use the same image
object to clean up the code a bit.
This commit is contained in:
Gregor Best 2008-10-21 21:17:07 +02:00 committed by Julien Danjou
parent 7041a4680d
commit 04b5e24c43
1 changed files with 5 additions and 1 deletions

View File

@ -53,6 +53,9 @@ gamedata.enemies.h = 10
gamedata.enemies.w = 20 gamedata.enemies.w = 20
gamedata.enemies.rows = 5 gamedata.enemies.rows = 5
gamedata.enemies.count = gamedata.enemies.rows * 6 gamedata.enemies.count = gamedata.enemies.rows * 6
gamedata.enemies[1] = image("@AWESOME_ICON_PATH@/invaders/enemy_1.png")
gamedata.enemies[2] = image("@AWESOME_ICON_PATH@/invaders/enemy_2.png")
gamedata.enemies[3] = image("@AWESOME_ICON_PATH@/invaders/enemy_3.png")
local player = { } local player = { }
local game = { } local game = { }
@ -176,7 +179,8 @@ function enemies.new (t)
y = gamedata.field.y }) y = gamedata.field.y })
e.screen = 1 e.screen = 1
w = widget({ type = "imagebox", name = "enemy"..t }) w = widget({ type = "imagebox", name = "enemy"..t })
w.image = image("@AWESOME_ICON_PATH@/invaders/enemy_"..t..".png") w.image = gamedata.enemies[t]
e.widgets = w e.widgets = w
return e return e
end end