/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-14 16:39:54 UTC
  • Revision ID: josh@9ix.org-20130514163954-tpi9djio3pm6vswf
prepare a collision box for the rocks

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 
6
6
              --self.scale = 1
7
7
 
8
 
              self.collider = RockCollider:new{
 
8
              self.collider = Fill:new{
 
9
                 fill = {0,0,255},
9
10
                 --x = self.x,
10
11
                 --y = self.y,
11
12
                 width = self.width * self.scale,
12
13
                 height = self.height * self.scale,
 
14
                 visible = false,
13
15
                 rock = self
14
16
              }
15
17
 
16
18
              the.app.view:add(self.collider)
17
 
              the.rockColliders:add(self.collider)
 
19
              table.insert(the.rockColliders, self.collider)
18
20
           end,
19
21
   onUpdate = function(self, dt)
20
22
                 self.collider.x = self.x + self.width / 2 * (1 - self.scale)
41
43
                   end
42
44
                end
43
45
}
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'