From 04b5e24c434bf210d0caa0d98b94dcd94d364d61 Mon Sep 17 00:00:00 2001 From: Gregor Best Date: Tue, 21 Oct 2008 21:17:07 +0200 Subject: [PATCH] invaders: clean code this commits makes all enemies of a certain type use the same image object to clean up the code a bit. --- lib/invaders.lua.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/invaders.lua.in b/lib/invaders.lua.in index 940227ea..8ba4fba5 100644 --- a/lib/invaders.lua.in +++ b/lib/invaders.lua.in @@ -53,6 +53,9 @@ gamedata.enemies.h = 10 gamedata.enemies.w = 20 gamedata.enemies.rows = 5 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 game = { } @@ -176,7 +179,8 @@ function enemies.new (t) y = gamedata.field.y }) e.screen = 1 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 return e end