/spacey

To get this branch, use:
bzr branch /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

2
2
   image = 'data/rock.png',
3
3
   onNew = function(self)
4
4
              --self.velocity = util.shortestVector(self, the.player):normalized() * 10
 
5
 
 
6
              --self.scale = 1
 
7
 
 
8
              self.collider = Fill:new{
 
9
                 fill = {0,0,255},
 
10
                 --x = self.x,
 
11
                 --y = self.y,
 
12
                 width = self.width * self.scale,
 
13
                 height = self.height * self.scale,
 
14
                 visible = false,
 
15
                 rock = self
 
16
              }
 
17
 
 
18
              the.app.view:add(self.collider)
 
19
              table.insert(the.rockColliders, self.collider)
5
20
           end,
6
 
   onEndFrame = function(self, dt)
 
21
   onUpdate = function(self, dt)
 
22
                 self.collider.x = self.x + self.width / 2 * (1 - self.scale)
 
23
                 self.collider.y = self.y + self.height / 2 * (1 - self.scale)
 
24
                 --self.collider.rotation = self.rotation -- ???
 
25
              end,
 
26
   onEndFrame = function(self)
7
27
                   -- onEndFrame to give a chance to go out of bounds then wrap
8
28
 
9
29
                   if DEBUG and the.console.visible then
11
31
                         self.text = Text:new()
12
32
                         the.view:add(self.text)
13
33
                      end
14
 
                      
 
34
 
15
35
                      local pVec = util.shortestVector(self, the.player)
16
36
                      self.text.text = pVec.x .. ', ' .. pVec.y
17
37
                      self.text.x, self.text.y = self.x, self.y
22
42
                      end
23
43
                   end
24
44
                end
25
 
}
 
 
'\\ No newline at end of file'
 
45
}