/traderous

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