feat: add teleportation from leaving the map
This commit is contained in:
parent
d7b47933b3
commit
3b28c5b776
6 changed files with 33 additions and 4 deletions
|
@ -11,5 +11,11 @@ return {
|
|||
x = 0,
|
||||
y = 0,
|
||||
}
|
||||
},
|
||||
exitTo = {
|
||||
area = "test.plain",
|
||||
x = 21,
|
||||
y = 7,
|
||||
charDir = "down"
|
||||
}
|
||||
}
|
|
@ -552,8 +552,8 @@ return {
|
|||
["area"] = "test.grotto",
|
||||
["isSolid"] = true,
|
||||
["needButton"] = true,
|
||||
["x"] = 12,
|
||||
["y"] = 12
|
||||
["x"] = 13.5,
|
||||
["y"] = 29
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,8 +98,8 @@
|
|||
<property name="area" value="test.grotto"/>
|
||||
<property name="isSolid" type="bool" value="true"/>
|
||||
<property name="needButton" type="bool" value="true"/>
|
||||
<property name="x" type="int" value="12"/>
|
||||
<property name="y" type="int" value="12"/>
|
||||
<property name="x" type="float" value="13.5"/>
|
||||
<property name="y" type="int" value="29"/>
|
||||
</properties>
|
||||
</object>
|
||||
</objectgroup>
|
||||
|
|
|
@ -54,6 +54,7 @@ function Player:updateStart(dt)
|
|||
self:updateInteraction()
|
||||
self:updateCurrentCharset()
|
||||
self:updateCurrentMap()
|
||||
self:updateOutsideMap()
|
||||
end
|
||||
|
||||
-- PHYSICS FUNCTIONS
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
local PlayerMap = Object:extend()
|
||||
local defTransitions = require "core.modules.transitions"
|
||||
|
||||
function PlayerMap:initMap()
|
||||
self.previousMap = 0
|
||||
|
@ -14,4 +15,14 @@ function PlayerMap:updateCurrentMap()
|
|||
end
|
||||
end
|
||||
|
||||
function PlayerMap:updateOutsideMap()
|
||||
if ((self.x > self.world.map.w + 8) or (self.x < -8) or (self.y > self.world.map.h + 16) or (self.y < -8))
|
||||
and (self.world.map.data.exitTo ~= nil) then
|
||||
local arguments = self.world.map.data.exitTo
|
||||
core.screen:startTransition(defTransitions.default, defTransitions.default,
|
||||
function() self.world:teleport(arguments.area, arguments.x, arguments.y, arguments.charDir) end,
|
||||
0, 0)
|
||||
end
|
||||
end
|
||||
|
||||
return PlayerMap
|
|
@ -33,9 +33,20 @@ function TiledMultiMap:loadObjects()
|
|||
for i, wrapper in ipairs(self.wrappers) do
|
||||
wrapper:loadObjects()
|
||||
end
|
||||
self:loadWalls()
|
||||
self:loadPlayer()
|
||||
end
|
||||
|
||||
function TiledMultiMap:loadWalls()
|
||||
if (self.data.exitTo == nil) then
|
||||
self.world.obj.collisions["wall"](self.world, -16, -16, self.w, 16)
|
||||
self.world.obj.collisions["wall"](self.world, -16, -16, 16, self.h)
|
||||
self.world.obj.collisions["wall"](self.world, self.w, -16, 16, self.h)
|
||||
self.world.obj.collisions["wall"](self.world, -16, self.h, self.w, 16)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function TiledMultiMap:loadPlayer()
|
||||
self.world:addPlayer(self.playerx, self.playery, 0, 1)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue