/traderous

To get this branch, use:
bzr branch http://9ix.org/bzr/traderous

« back to all changes in this revision

Viewing changes to shield.lua

  • Committer: Josh C
  • Date: 2013-06-30 22:36:26 UTC
  • Revision ID: josh@9ix.org-20130630223626-pgya1z6raymhzj2v
5-7 planets, tweak some goods

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
   max = 5,
 
11
   velocity = {rotation = 5},
 
12
   cost = 100, -- cost to repair 1 shield strength
 
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)
 
26
                 self:setImage()
 
27
 
 
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
}
 
 
b'\\ No newline at end of file'