/spacey

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

« back to all changes in this revision

Viewing changes to bullet.lua

  • Committer: Josh C
  • Date: 2013-05-04 20:45:17 UTC
  • Revision ID: josh@9ix.org-20130504204517-1rfp92svud12kg42
zoetrope 1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
Bullet = WrapTile:extend {
3
 
   image = 'data/laser.png',
4
 
   onNew = function(self)
5
 
              --self.velocity = vector.new(1000, 0) -- veclocity 800
6
 
              --self.velocity:rotate_inplace(self.rotation)
7
 
 
8
 
              self.velocity = vector.new(
9
 
                 love.mouse.getX() - the.app.width / 2,
10
 
                 love.mouse.getY() - the.app.height / 2
11
 
              )
12
 
              self.velocity:normalize_inplace()
13
 
              self.velocity = self.velocity * 1000
14
 
 
15
 
              self.rotation = math.atan2(self.velocity.y, self.velocity.x)
16
 
 
17
 
              self.createdAt = love.timer.getTime()
18
 
 
19
 
              the.bullets:add(self)
20
 
           end,
21
 
   onUpdate = function(self, dt)
22
 
                 if love.timer.getTime() - self.createdAt > 0.7 then
23
 
                    -- TODO: reuse these (see factory idea above)
24
 
                    self:die()
25
 
                    the.app.view:remove(self)
26
 
                    the.bullets:remove(self)
27
 
                 end
28
 
              end
29
 
}
 
 
b'\\ No newline at end of file'