/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 17:32:46 UTC
  • Revision ID: josh@9ix.org-20130514173246-rjq8assj79qbd6fn
explosions

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
                     local b = Boom:new {
 
53
                        x = self.x,
 
54
                        y = self.y,
 
55
                        velocity = {
 
56
                           rotation = util.signOf(self.rock.rotation) * 5
 
57
                        }
 
58
                     }
 
59
                     the.app.view:add(b)
 
60
 
 
61
                     the.app.view:remove(self.rock)
 
62
                     the.app.view:remove(self)
 
63
                     the.rockColliders:remove(self)
 
64
                     self.rock = nil -- break circular reference
 
65
 
 
66
                     the.app.view:remove(other)
 
67
                     the.bullets:remove(other)
 
68
                  end
 
69
               end
 
70
}
 
 
b'\\ No newline at end of file'