/spacey

To get this branch, use:
bzr branch http://9ix.org/bzr/spacey

« back to all changes in this revision

Viewing changes to wrap_tile.lua

  • Committer: Josh C
  • Date: 2013-05-14 00:15:01 UTC
  • Revision ID: josh@9ix.org-20130514001501-z14e702ncp21s0yr
try to not spawn rocks where you can see them.  not working if screen 
crosses game boundaries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
               if self.x ~= mirrorX then
31
31
                  if not self.xMirror then
32
 
                     --print('creating mirror: X='..mirrorX..' Y='..mirrorY)
 
32
                     --print('creating mirror: X='..xMirrorX..' Y='..xMirrorY)
33
33
 
34
34
                     self.xMirror = Mirror:new{ of = self, image = self.image }
35
 
                     the.mirrors:add(self.xMirror)
 
35
                     the.app.view:add(self.xMirror)
36
36
                  end
37
37
 
38
38
                  self.xMirror.x = mirrorX
40
40
                  self.xMirror.rotation = self.rotation
41
41
                  self.xMirror.scale = self.scale
42
42
               elseif self.xMirror then
43
 
                  if self.type == 'bullet' then
44
 
                     --print('pruning bullet')
45
 
                  end
46
 
                  the.mirrors:remove(self.xMirror)
47
 
                  self.xMirror.of = nil -- break circular reference
 
43
                  the.app.view:remove(self.xMirror)
48
44
                  self.xMirror = nil
49
45
                  -- die?
50
46
               end
51
47
 
52
48
               if self.y ~= mirrorY then
53
49
                  if not self.yMirror then
54
 
                     --print('creating mirror: X='..mirrorX..' Y='..mirrorY)
 
50
                     --print('creating mirror: X='..yMirrorX..' Y='..yMirrorY)
55
51
 
56
52
                     self.yMirror = Mirror:new{ of = self, image = self.image }
57
 
                     the.mirrors:add(self.yMirror)
 
53
                     the.app.view:add(self.yMirror)
58
54
                  end
59
55
 
60
56
                  self.yMirror.x = self.x
62
58
                  self.yMirror.rotation = self.rotation
63
59
                  self.yMirror.scale = self.scale
64
60
               elseif self.yMirror then
65
 
                  if self.type == 'bullet' then
66
 
                     --print('pruning bullet')
67
 
                  end
68
 
                  the.mirrors:remove(self.yMirror)
69
 
                  self.yMirror.of = nil -- break circular reference
 
61
                  the.app.view:remove(self.yMirror)
70
62
                  self.yMirror = nil
71
63
                  -- die?
72
64
               end
73
65
 
74
66
               if self.x ~= mirrorX and self.y ~= mirrorY then
75
67
                  if not self.xyMirror then
76
 
                     --print('creating mirror: X='..mirrorX..' Y='..mirrorY)
 
68
                     --print('creating mirror: X='..xyMirrorX..' Y='..xyMirrorY)
77
69
 
78
70
                     self.xyMirror = Mirror:new{ of = self, image = self.image }
79
 
                     the.mirrors:add(self.xyMirror)
 
71
                     the.app.view:add(self.xyMirror)
80
72
                  end
81
73
 
82
74
                  self.xyMirror.x = mirrorX
84
76
                  self.xyMirror.rotation = self.rotation
85
77
                  self.xyMirror.scale = self.scale
86
78
               elseif self.xyMirror then
87
 
                  if self.type == 'bullet' then
88
 
                     --print('pruning bullet')
89
 
                  end
90
 
                  the.mirrors:remove(self.xyMirror)
91
 
                  self.xyMirror.of = nil -- break circular reference
 
79
                  the.app.view:remove(self.xyMirror)
92
80
                  self.xyMirror = nil
93
81
                  -- die?
94
82
               end
95
83
            end,
96
84
   onRemove = function(self)
97
85
                 if self.xMirror then
98
 
                    if self.type == 'bullet' then
99
 
                       --print('removing bullet, so removing mirror')
100
 
                    end
101
 
                    the.mirrors:remove(self.xMirror)
102
 
                    self.xMirror.of = nil -- break circular reference
103
 
                    self.xMirror = nil
 
86
                    the.app.view:remove(self.xMirror)
104
87
                 end
105
88
 
106
89
                 if self.yMirror then
107
 
                    if self.type == 'bullet' then
108
 
                       --print('removing bullet, so removing mirror')
109
 
                    end
110
 
                    the.mirrors:remove(self.yMirror)
111
 
                    self.yMirror.of = nil -- break circular reference
112
 
                    self.yMirror = nil
 
90
                    the.app.view:remove(self.yMirror)
113
91
                 end
114
92
 
115
93
                 if self.xyMirror then
116
 
                    if self.type == 'bullet' then
117
 
                       --print('removing bullet, so removing mirror')
118
 
                    end
119
 
                    the.mirrors:remove(self.xyMirror)
120
 
                    self.xyMirror.of = nil -- break circular reference
121
 
                    self.xyMirror = nil
 
94
                    the.app.view:remove(self.xyMirror)
122
95
                 end
123
96
              end,
124
97
   update = function (self, elapsed)
125
98
               Tile.update(self, elapsed)
126
99
 
127
100
               self:wrap()
128
 
               if self.active then
129
 
                  self:reflect()
130
 
               end
 
101
               self:reflect()
 
102
 
 
103
               -- TODO: make sure mirrors are cleaned up when we are
 
104
               -- killed / removed from view
131
105
            end
132
106
}
 
 
b'\\ No newline at end of file'