/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-11 00:15:54 UTC
  • Revision ID: josh@9ix.org-20130611001554-tkzp73ke16buhnuy
bring indicators a little closer from edge

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
 
   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
 
}
 
 
b'\\ No newline at end of file'