/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-06-19 00:50:23 UTC
  • Revision ID: josh@9ix.org-20130619005023-necyd2i8kgqbp1s9
shield

Show diffs side-by-side

added added

removed removed

Lines of Context:
61
61
                           b = Bullet:new{
62
62
                              x = self.x + self.width / 2,
63
63
                              y = self.y + self.height / 2,
64
 
                              rotation = self.rotation,
65
 
                              source = self
 
64
                              rotation = self.rotation
66
65
                           }
67
66
                           self.lastFired = love.timer.getTime()
68
67
                     end
76
75
                   self:collide(the.rockColliders)
77
76
                end,
78
77
   onCollide = function(self, other)
79
 
                  if other:instanceOf(Bullet) and other.source ~= self then
 
78
                  if other:instanceOf(Bullet) then
80
79
                     if self.shield.strength == 0 then
81
80
                        -- die
82
81
                        the.app.view:add( Boom:new {
89
88
                        self.thrust:die()
90
89
                     else
91
90
                        self.shield:onHit()
 
91
                        other:die()
 
92
                        the.bullets:remove(other)
92
93
                     end
93
 
 
94
 
                     other:die()
95
 
                     the.bullets:remove(other)
96
94
                  end
97
95
 
98
96
                  if other:instanceOf(RockCollider) then
104
102
 
105
103
                     self:die()
106
104
                     self.thrust:die()
107
 
                  end
108
105
 
109
 
                  if not self.active then
110
106
                     the.over.visible = true
111
107
                     the.instructions.visible = true
 
108
                     the.app.view:updateScore()
 
109
 
 
110
                     local score = love.timer.getTime() - the.app.view.gameStart
 
111
                     if score > the.storage.data.highScore then
 
112
                        the.storage.data.highScore = score
 
113
                        the.storage:save()
 
114
 
 
115
                        the.highScore.text = string.format(
 
116
                           'High Score: %d:%02d', score / 60, score % 60
 
117
                        )
 
118
                     end
112
119
                  end
113
120
               end,
114
121
   buy = function(self, good, price)