/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},
77 by Josh C
pay to fix shield
12
   cost = 100, -- cost to repair 1 shield strength
68 by Josh C
shield
13
   setImage = function (self)
14
                 if self.strength < 1 or self.strength == 5 then
15
                    self.visible = false
16
                 else
17
                    self.visible = true
18
                    self.image = self.images[self.strength]
19
                 end
20
                 -- special handling for strength = 0?  set alpha to 0?  fade?
21
              end,
22
   onHit = function (self)
23
              self.strength = self.strength - 1
24
           end,
25
   onUpdate = function (self)
73 by Josh C
higher planet floor, recharge shields when you land, stop moving when you land
26
                 self:setImage()
27
68 by Josh C
shield
28
                 self.x = self.ship.x - 16
29
                 self.y = self.ship.y - 16
30
31
                 if the.keys:justPressed('p') then
32
                    self:onHit()
33
                 end
34
              end
35
}