/spacey

To get this branch, use:
bzr branch http://9ix.org/bzr/spacey
26 by Josh C
rocks!
1
Rock = WrapTile:extend {
27 by Josh C
try to not spawn rocks where you can see them. not working if screen
2
   image = 'data/rock.png',
3
   onNew = function(self)
4
              --self.velocity = util.shortestVector(self, the.player):normalized() * 10
28 by Josh C
prepare a collision box for the rocks
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)
27 by Josh C
try to not spawn rocks where you can see them. not working if screen
20
           end,
28 by Josh C
prepare a collision box for the rocks
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)
27 by Josh C
try to not spawn rocks where you can see them. not working if screen
27
                   -- onEndFrame to give a chance to go out of bounds then wrap
28
29
                   if DEBUG and the.console.visible then
30
                      if not self.text then
31
                         self.text = Text:new()
32
                         the.view:add(self.text)
33
                      end
28 by Josh C
prepare a collision box for the rocks
34
27 by Josh C
try to not spawn rocks where you can see them. not working if screen
35
                      local pVec = util.shortestVector(self, the.player)
36
                      self.text.text = pVec.x .. ', ' .. pVec.y
37
                      self.text.x, self.text.y = self.x, self.y
38
                      self.text.visible = true
39
                   else
40
                      if self.text then
41
                         self.text.visible = false
42
                      end
43
                   end
44
                end
28 by Josh C
prepare a collision box for the rocks
45
}