/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-16 04:27:01 UTC
  • Revision ID: josh@9ix.org-20130616042701-andlbpq3uuf679fy
enemy thrust

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
 
   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)
25
 
                 self:setImage()
26
 
 
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
 
}
 
 
b'\\ No newline at end of file'