/traderous

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

« back to all changes in this revision

Viewing changes to player.lua

  • Committer: Josh C
  • Date: 2013-10-21 18:31:55 UTC
  • Revision ID: josh@9ix.org-20131021183155-vl7pxaor2u3pw0t0
have enemies disengage when you land

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
                           }
70
70
                           self.lastFired = love.timer.getTime()
71
71
                     end
 
72
 
 
73
                     if the.keys:justPressed('x') then
 
74
                        --self:doHit()
 
75
                     end
72
76
                  end,
73
77
   onUpdate = function(self)
74
78
                 self.thrust.x = self.x - self.width
78
82
   onEndFrame = function(self)
79
83
                   self:collide(the.rockColliders)
80
84
                end,
 
85
   doHit = function(self)
 
86
              if self.shield.strength == 0 then
 
87
                 -- die
 
88
                 the.app.view:add( Boom:new {
 
89
                                      x = self.x,
 
90
                                      y = self.y,
 
91
                                      velocity = { rotation = 5 }
 
92
                                   })
 
93
 
 
94
                 self:die()
 
95
                 self.thrust:die()
 
96
              else
 
97
                 self.shield:onHit()
 
98
              end
 
99
 
 
100
              if not self.active then
 
101
                 the.interface:add(GameOver:new())
 
102
              end
 
103
           end,
81
104
   onCollide = function(self, other)
82
105
                  if other:instanceOf(Bullet) and other.source ~= self then
83
 
                     if self.shield.strength == 0 then
84
 
                        -- die
85
 
                        the.app.view:add( Boom:new {
86
 
                                             x = self.x,
87
 
                                             y = self.y,
88
 
                                             velocity = { rotation = 5 }
89
 
                                          })
90
 
 
91
 
                        self:die()
92
 
                        self.thrust:die()
93
 
                     else
94
 
                        self.shield:onHit()
95
 
                     end
 
106
                     self:doHit()
96
107
 
97
108
                     other:die()
98
109
                     the.bullets:remove(other)
108
119
                     self:die()
109
120
                     self.thrust:die()
110
121
                  end
111
 
 
112
 
                  if not self.active then
113
 
                     the.interface:add(GameOver:new())
114
 
                  end
115
122
               end,
116
123
   buy = function(self, good, price)
117
124
            if self.money >= price and self:availableSpace() > 0 then