/traderous

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

« back to all changes in this revision

Viewing changes to wrap_tile.lua

  • Committer: Josh C
  • Date: 2013-05-20 16:51:19 UTC
  • Revision ID: josh@9ix.org-20130520165119-mkjh7d9408e6ig0u
extract updating score.  update score again when you calc high score - 
should mitigate a bug I saw happen when thor played that put final score 
+ high score out of sync

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