/spacey

To get this branch, use:
bzr branch http://9ix.org/bzr/spacey
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
-- TODO: these need to come out of a factory

Bullet = WrapTile:extend {
   image = 'data/laser.png',
   onNew = function(self)
              --self.velocity = vector.new(1000, 0) -- veclocity 800
              --self.velocity:rotate_inplace(self.rotation)

              self.velocity = vector.new(
                 love.mouse.getX() - the.app.width / 2,
                 love.mouse.getY() - the.app.height / 2
              )
              self.velocity:normalize_inplace()
              self.velocity = self.velocity * 1000

              self.rotation = math.atan2(self.velocity.y, self.velocity.x)

              self.createdAt = love.timer.getTime()

              the.bullets:add(self)
           end,
   onUpdate = function(self, dt)
                 if love.timer.getTime() - self.createdAt > 0.7 then
                    -- TODO: reuse these (see factory idea above)
                    the.bullets:remove(self)
                    self:die()
                 end
              end
}