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 }