/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,
73 by Josh C
higher planet floor, recharge shields when you land, stop moving when you land
10
   max = 5,
68 by Josh C
shield
11
   velocity = {rotation = 5},
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
           end,
24
   onUpdate = function (self)
73 by Josh C
higher planet floor, recharge shields when you land, stop moving when you land
25
                 self:setImage()
26
68 by Josh C
shield
27
                 self.x = self.ship.x - 16
28
                 self.y = self.ship.y - 16
29
30
                 if the.keys:justPressed('p') then
31
                    self:onHit()
32
                 end
33
              end
34
}