/traderous

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

« back to all changes in this revision

Viewing changes to rock.lua

  • Committer: Josh C
  • Date: 2013-05-14 17:13:43 UTC
  • Revision ID: josh@9ix.org-20130514171343-s251e971hc92mzb0
shoot things!

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
16
              the.app.view:add(self.collider)
19
 
              table.insert(the.rockColliders, self.collider)
 
17
              the.rockColliders:add(self.collider)
20
18
           end,
21
19
   onUpdate = function(self, dt)
22
20
                 self.collider.x = self.x + self.width / 2 * (1 - self.scale)
43
41
                   end
44
42
                end
45
43
}
 
44
 
 
45
RockCollider = Fill:extend {
 
46
   fill = {0,0,255},
 
47
   onUpdate = function(self, dt)
 
48
                 self.visible = DEBUG and the.console.visible
 
49
              end,
 
50
   onCollide = function(self, other)
 
51
                  if other:instanceOf(Bullet) then
 
52
                     the.app.view:remove(self.rock)
 
53
                     the.app.view:remove(self)
 
54
                     the.rockColliders:remove(self)
 
55
                     self.rock = nil -- break circular reference
 
56
 
 
57
                     the.app.view:remove(other)
 
58
                     the.bullets:remove(other)
 
59
                  end
 
60
               end
 
61
}
 
 
b'\\ No newline at end of file'