/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-13 21:23:20 UTC
  • Revision ID: josh@9ix.org-20130513212320-t1sgc5dcpjwmjp38
mirror (contains a bug where things in the corner aren't getting mirrored?

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Rock = WrapTile:extend {
2
 
   image = 'data/rock.png',
3
 
   onNew = function(self)
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)
20
 
           end,
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
 
                   -- 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
34
 
 
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
45
 
}