/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-20 17:57:53 UTC
  • Revision ID: josh@9ix.org-20130520175753-yvanutc9jnm8lzbt
quit and restart

Show diffs side-by-side

added added

removed removed

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