1
WrapTile = Tile:extend {
3
if self.x < the.app.width / 2 then
4
self.x = the.bg.width - the.app.width / 2
5
elseif self.x > the.bg.width - the.app.width / 2 then
6
self.x = the.app.width / 2
9
if self.y < the.app.height / 2 then
10
self.y = the.bg.height - the.app.height / 2
11
elseif self.y > the.bg.height - the.app.height / 2 then
12
self.y = the.app.height / 2
15
reflect = function(self)
16
local mirrorX, mirrorY = self.x, self.y
18
if self.x > the.bg.width - the.app.width then
19
mirrorX = self.x - the.bg.width + the.app.width
20
elseif self.x < the.app.width then
21
mirrorX = self.x + the.bg.width - the.app.width
24
if self.y > the.bg.height - the.app.height then
25
mirrorY = self.y - the.bg.height + the.app.height
26
elseif self.y < the.app.height then
27
mirrorY = self.y + the.bg.height - the.app.height
30
if self.x ~= mirrorX then
31
if not self.xMirror then
32
--print('creating mirror: X='..xMirrorX..' Y='..xMirrorY)
34
self.xMirror = Tile:new{ image = self.image }
35
the.app.view:add(self.xMirror)
38
self.xMirror.x = mirrorX
39
self.xMirror.y = self.y
40
self.xMirror.rotation = self.rotation
41
self.xMirror.scale = self.scale
42
elseif self.xMirror then
43
the.app.view:remove(self.xMirror)
48
if self.y ~= mirrorY then
49
if not self.yMirror then
50
--print('creating mirror: X='..yMirrorX..' Y='..yMirrorY)
52
self.yMirror = Tile:new{ image = self.image }
53
the.app.view:add(self.yMirror)
56
self.yMirror.x = self.x
57
self.yMirror.y = mirrorY
58
self.yMirror.rotation = self.rotation
59
self.yMirror.scale = self.scale
60
elseif self.yMirror then
61
the.app.view:remove(self.yMirror)
66
if self.x ~= mirrorX and self.y ~= mirrorY then
67
if not self.xyMirror then
68
--print('creating mirror: X='..xyMirrorX..' Y='..xyMirrorY)
70
self.xyMirror = Tile:new{ image = self.image }
71
the.app.view:add(self.xyMirror)
74
self.xyMirror.x = mirrorX
75
self.xyMirror.y = mirrorY
76
self.xyMirror.rotation = self.rotation
77
self.xyMirror.scale = self.scale
78
elseif self.xyMirror then
79
the.app.view:remove(self.xyMirror)
84
onRemove = function(self)
86
the.app.view:remove(self.xMirror)
90
the.app.view:remove(self.yMirror)
94
the.app.view:remove(self.xyMirror)
97
update = function (self, elapsed)
98
Tile.update(self, elapsed)
103
-- TODO: make sure mirrors are cleaned up when we are
104
-- killed / removed from view
b'\\ No newline at end of file'