/traderous

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

« back to all changes in this revision

Viewing changes to enemy.lua

  • Committer: Josh C
  • Date: 2013-06-19 01:06:14 UTC
  • Revision ID: josh@9ix.org-20130619010614-j3rbcv1c0my2tw0f
enemy shields and death

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
   onNew = function (self)
10
10
              self.thrust = Tile:new{image = 'data/thrust.png'}
11
11
              --the.app.view:add(self.thrust)
 
12
              self.shield = Shield:new{ship = self}
12
13
           end,
13
14
   onStartFrame = function (self)
14
15
 
55
56
                         b = Bullet:new{
56
57
                            x = self.x + self.width / 2,
57
58
                            y = self.y + self.height / 2,
58
 
                            rotation = self.rotation
 
59
                            rotation = self.rotation,
 
60
                            source = self
59
61
                         }
60
62
                         self.lastFired = love.timer.getTime()
61
63
                     end
66
68
                 self.thrust.y = self.y
67
69
                 self.thrust.rotation = self.rotation
68
70
              end,
69
 
 
 
71
   onCollide = function (self, other)
 
72
                  if other:instanceOf(Bullet) and other.source ~= self then
 
73
                     if self.shield.strength == 0 then
 
74
                        -- die
 
75
                        the.app.view:add( Boom:new {
 
76
                                             x = self.x,
 
77
                                             y = self.y,
 
78
                                             velocity = { rotation = 5 }
 
79
                                          })
 
80
 
 
81
                        self:die()
 
82
                        self.thrust:die()
 
83
                        self.shield:die()
 
84
                        the.enemies:remove(self)
 
85
                        the.app.view:remove(self.thrust)
 
86
                        the.app.view:remove(self.shield)
 
87
                     else
 
88
                        self.shield:onHit()
 
89
                     end
 
90
 
 
91
                     other:die()
 
92
                     the.bullets:remove(other)
 
93
                  end
 
94
               end
70
95
}
 
 
b'\\ No newline at end of file'