1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
Shield = Tile:extend{
image = 'data/shield.png',
images = {
'data/shield3.png',
'data/shield2.png',
'data/shield1.png',
'data/shield.png'
},
strength = 5,
max = 5,
velocity = {rotation = 5},
cost = 100, -- cost to repair 1 shield strength
setImage = function (self)
if self.strength < 1 or self.strength == 5 then
self.visible = false
else
self.visible = true
self.image = self.images[self.strength]
end
-- special handling for strength = 0? set alpha to 0? fade?
end,
onHit = function (self)
self.strength = self.strength - 1
end,
onUpdate = function (self)
self:setImage()
self.x = self.ship.x - 16
self.y = self.ship.y - 16
if the.keys:justPressed('p') then
self:onHit()
end
end
}
|