/spacey

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

« back to all changes in this revision

Viewing changes to rock.lua

  • Committer: Josh C
  • Date: 2013-05-24 03:14:13 UTC
  • Revision ID: josh@9ix.org-20130524031413-b7104z7wa1zpavzd
thrust indicator

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
              --self.scale = 1
7
7
 
8
 
              self.collider = Fill:new{
9
 
                 fill = {0,0,255},
 
8
              self.collider = RockCollider:new{
10
9
                 --x = self.x,
11
10
                 --y = self.y,
12
11
                 width = self.width * self.scale,
13
12
                 height = self.height * self.scale,
14
 
                 visible = false,
15
13
                 rock = self
16
14
              }
17
15
 
18
 
              the.app.view:add(self.collider)
19
 
              table.insert(the.rockColliders, self.collider)
 
16
              the.rockColliders:add(self.collider)
20
17
           end,
21
18
   onUpdate = function(self, dt)
22
19
                 self.collider.x = self.x + self.width / 2 * (1 - self.scale)
43
40
                   end
44
41
                end
45
42
}
 
43
 
 
44
RockCollider = Fill:extend {
 
45
   fill = {0,0,255},
 
46
   onUpdate = function(self, dt)
 
47
                 self.visible = DEBUG and the.console.visible
 
48
              end,
 
49
   onCollide = function(self, other)
 
50
                  if other:instanceOf(Bullet) then
 
51
                     local b = Boom:new {
 
52
                        x = self.x,
 
53
                        y = self.y,
 
54
                        velocity = {
 
55
                           rotation = util.signOf(self.rock.rotation) * 5
 
56
                        }
 
57
                     }
 
58
                     the.app.view:add(b)
 
59
 
 
60
                     the.rocks:remove(self.rock)
 
61
                     the.rockColliders:remove(self)
 
62
                     self.rock = nil -- break circular reference
 
63
 
 
64
                     the.bullets:remove(other)
 
65
                     other:die()
 
66
                  end
 
67
               end
 
68
}
 
 
b'\\ No newline at end of file'