Add teleport border behavior
This commit is contained in:
parent
025acf5978
commit
a3bf3c5927
31
main.lua
31
main.lua
|
@ -115,14 +115,6 @@ function mainmenu_update(dt)
|
||||||
elseif (num == 3) then
|
elseif (num == 3) then
|
||||||
dirs['up'] = 1
|
dirs['up'] = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
-- teleport off-screen monkeys
|
|
||||||
for i=0,player.last do
|
|
||||||
local x,y = player.monks[i].body:getPosition()
|
|
||||||
if (y > 2000) then
|
|
||||||
player.monks[i].body:setPosition(200,0)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -519,7 +511,9 @@ function Map:initialize(filepath)
|
||||||
self.platforms = {}
|
self.platforms = {}
|
||||||
self.tables = {}
|
self.tables = {}
|
||||||
self.objects = {}
|
self.objects = {}
|
||||||
self.outOfBounds = "teleport"
|
self.outOfBounds = "die"
|
||||||
|
self.spawn = {['x'] = 100, ['y'] = 100}
|
||||||
|
self.respawn = {['x'] = 100, ['y'] = 100}
|
||||||
local maptable = dofile(filepath)
|
local maptable = dofile(filepath)
|
||||||
|
|
||||||
self.width,self.height = maptable.width,maptable.height
|
self.width,self.height = maptable.width,maptable.height
|
||||||
|
@ -567,14 +561,18 @@ function Map:initialize(filepath)
|
||||||
or object.properties["count"] == nil) then
|
or object.properties["count"] == nil) then
|
||||||
monkCount = object.properties["count"]
|
monkCount = object.properties["count"]
|
||||||
end
|
end
|
||||||
monkX,monkY = object.x,object.y
|
self.spawn['x'],self.spawn['y'] = object.x,object.y
|
||||||
|
|
||||||
|
elseif (object.shape == "point" and object.type == "respawn") then
|
||||||
|
self.respawn['x'],self.respawn['y'] = object.x,object.y
|
||||||
|
self.outOfBounds = "teleport"
|
||||||
|
|
||||||
elseif (object.shape == "point" and object.type == "banana") then
|
elseif (object.shape == "point" and object.type == "banana") then
|
||||||
self.objects[object.id] = Banana:new(object.x, object.y)
|
self.objects[object.id] = Banana:new(object.x, object.y)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
player = Monk:new(monkX, monkY, monkCount)
|
player = Monk:new(self.spawn['x'], self.spawn['y'], monkCount)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -582,15 +580,16 @@ function Map:update(dt)
|
||||||
local heightMax = self.height * self.tileHeight + 100
|
local heightMax = self.height * self.tileHeight + 100
|
||||||
local widthMax = self.width * self.tileWidth + 200
|
local widthMax = self.width * self.tileWidth + 200
|
||||||
|
|
||||||
for i=player.current,player.last do
|
for i=0,player.last do
|
||||||
local x,y = player.monks[i].body:getPosition()
|
local x,y = player.monks[i].body:getPosition()
|
||||||
|
|
||||||
if (math.abs(x) > widthMax or y > heightMax
|
if ((math.abs(x) > widthMax or y > heightMax)
|
||||||
and self.outOfBounds == "die") then
|
and self.outOfBounds == "die") then
|
||||||
player:freeze()
|
player:freeze(i)
|
||||||
elseif (math.abs(x) > widthMax or y > heightMax
|
elseif ((math.abs(x) > widthMax or y > heightMax)
|
||||||
and self.outOfBounds == "teleport") then
|
and self.outOfBounds == "teleport") then
|
||||||
player.monks[i].body:setPosition(200,0)
|
player.monks[i].body:setPosition(
|
||||||
|
self.respawn['x'], self.respawn['y'])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
119
maps/menu.lua
119
maps/menu.lua
|
@ -9,7 +9,7 @@ return {
|
||||||
tilewidth = 16,
|
tilewidth = 16,
|
||||||
tileheight = 16,
|
tileheight = 16,
|
||||||
nextlayerid = 4,
|
nextlayerid = 4,
|
||||||
nextobjectid = 20,
|
nextobjectid = 33,
|
||||||
properties = {},
|
properties = {},
|
||||||
tilesets = {},
|
tilesets = {},
|
||||||
layers = {
|
layers = {
|
||||||
|
@ -62,6 +62,63 @@ return {
|
||||||
rotation = 0,
|
rotation = 0,
|
||||||
visible = true,
|
visible = true,
|
||||||
properties = {}
|
properties = {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id = 27,
|
||||||
|
name = "",
|
||||||
|
type = "",
|
||||||
|
shape = "polygon",
|
||||||
|
x = 800,
|
||||||
|
y = 530.242,
|
||||||
|
width = 0,
|
||||||
|
height = 0,
|
||||||
|
rotation = 0,
|
||||||
|
visible = true,
|
||||||
|
polygon = {
|
||||||
|
{ x = 0, y = 0 },
|
||||||
|
{ x = -360.606, y = 269.697 },
|
||||||
|
{ x = -6.06061, y = 266.667 }
|
||||||
|
},
|
||||||
|
properties = {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id = 28,
|
||||||
|
name = "",
|
||||||
|
type = "",
|
||||||
|
shape = "rectangle",
|
||||||
|
x = 46.6665,
|
||||||
|
y = 791.333,
|
||||||
|
width = 66.6667,
|
||||||
|
height = 14.6667,
|
||||||
|
rotation = 0,
|
||||||
|
visible = true,
|
||||||
|
properties = {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id = 29,
|
||||||
|
name = "",
|
||||||
|
type = "",
|
||||||
|
shape = "rectangle",
|
||||||
|
x = 177.333,
|
||||||
|
y = 790,
|
||||||
|
width = 105.333,
|
||||||
|
height = 16,
|
||||||
|
rotation = 0,
|
||||||
|
visible = true,
|
||||||
|
properties = {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id = 30,
|
||||||
|
name = "",
|
||||||
|
type = "",
|
||||||
|
shape = "rectangle",
|
||||||
|
x = 346.667,
|
||||||
|
y = 788.667,
|
||||||
|
width = 54.6667,
|
||||||
|
height = 16,
|
||||||
|
rotation = 0,
|
||||||
|
visible = true,
|
||||||
|
properties = {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -77,12 +134,12 @@ return {
|
||||||
properties = {},
|
properties = {},
|
||||||
objects = {
|
objects = {
|
||||||
{
|
{
|
||||||
id = 9,
|
id = 31,
|
||||||
name = "",
|
name = "",
|
||||||
type = "spawn",
|
type = "spawn",
|
||||||
shape = "point",
|
shape = "point",
|
||||||
x = 378.031,
|
x = 321.333,
|
||||||
y = 420.905,
|
y = 484,
|
||||||
width = 0,
|
width = 0,
|
||||||
height = 0,
|
height = 0,
|
||||||
rotation = 0,
|
rotation = 0,
|
||||||
|
@ -92,60 +149,16 @@ return {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id = 16,
|
id = 32,
|
||||||
name = "",
|
name = "",
|
||||||
type = "",
|
type = "respawn",
|
||||||
shape = "polygon",
|
shape = "point",
|
||||||
x = 800,
|
x = 330.667,
|
||||||
y = 524.242,
|
y = 2.66667,
|
||||||
width = 0,
|
width = 0,
|
||||||
height = 0,
|
height = 0,
|
||||||
rotation = 0,
|
rotation = 0,
|
||||||
visible = true,
|
visible = true,
|
||||||
polygon = {
|
|
||||||
{ x = 0, y = 0 },
|
|
||||||
{ x = -360.606, y = 269.697 },
|
|
||||||
{ x = -6.06061, y = 266.667 }
|
|
||||||
},
|
|
||||||
properties = {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id = 17,
|
|
||||||
name = "",
|
|
||||||
type = "",
|
|
||||||
shape = "rectangle",
|
|
||||||
x = 46.6667,
|
|
||||||
y = 785.333,
|
|
||||||
width = 66.6667,
|
|
||||||
height = 14.6667,
|
|
||||||
rotation = 0,
|
|
||||||
visible = true,
|
|
||||||
properties = {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id = 18,
|
|
||||||
name = "",
|
|
||||||
type = "",
|
|
||||||
shape = "rectangle",
|
|
||||||
x = 177.333,
|
|
||||||
y = 784,
|
|
||||||
width = 105.333,
|
|
||||||
height = 16,
|
|
||||||
rotation = 0,
|
|
||||||
visible = true,
|
|
||||||
properties = {}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id = 19,
|
|
||||||
name = "",
|
|
||||||
type = "",
|
|
||||||
shape = "rectangle",
|
|
||||||
x = 346.667,
|
|
||||||
y = 782.667,
|
|
||||||
width = 54.6667,
|
|
||||||
height = 16,
|
|
||||||
rotation = 0,
|
|
||||||
visible = true,
|
|
||||||
properties = {}
|
properties = {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="50" height="50" tilewidth="16" tileheight="16" infinite="0" nextlayerid="4" nextobjectid="20">
|
<map version="1.4" tiledversion="1.4.3" orientation="orthogonal" renderorder="right-down" width="50" height="50" tilewidth="16" tileheight="16" infinite="0" nextlayerid="4" nextobjectid="33">
|
||||||
<editorsettings>
|
<editorsettings>
|
||||||
<export target="menu.lua" format="lua"/>
|
<export target="menu.lua" format="lua"/>
|
||||||
</editorsettings>
|
</editorsettings>
|
||||||
|
@ -7,19 +7,22 @@
|
||||||
<object id="2" x="38.932" y="306.814" width="14.6488" height="242.519"/>
|
<object id="2" x="38.932" y="306.814" width="14.6488" height="242.519"/>
|
||||||
<object id="4" x="55.2085" y="537.94" width="524.102" height="11.3935"/>
|
<object id="4" x="55.2085" y="537.94" width="524.102" height="11.3935"/>
|
||||||
<object id="6" x="581.752" y="306" width="14.6488" height="242.52"/>
|
<object id="6" x="581.752" y="306" width="14.6488" height="242.52"/>
|
||||||
|
<object id="27" x="800" y="530.242">
|
||||||
|
<polygon points="0,0 -360.606,269.697 -6.06061,266.667"/>
|
||||||
|
</object>
|
||||||
|
<object id="28" x="46.6665" y="791.333" width="66.6667" height="14.6667"/>
|
||||||
|
<object id="29" x="177.333" y="790" width="105.333" height="16"/>
|
||||||
|
<object id="30" x="346.667" y="788.667" width="54.6667" height="16"/>
|
||||||
</objectgroup>
|
</objectgroup>
|
||||||
<objectgroup id="3" name="Object Layer 2">
|
<objectgroup id="3" name="Object Layer 2">
|
||||||
<object id="9" type="spawn" x="378.031" y="420.905">
|
<object id="31" type="spawn" x="321.333" y="484">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="count" type="int" value="10"/>
|
<property name="count" type="int" value="10"/>
|
||||||
</properties>
|
</properties>
|
||||||
<point/>
|
<point/>
|
||||||
</object>
|
</object>
|
||||||
<object id="16" x="800" y="524.242">
|
<object id="32" type="respawn" x="330.667" y="2.66667">
|
||||||
<polygon points="0,0 -360.606,269.697 -6.06061,266.667"/>
|
<point/>
|
||||||
</object>
|
</object>
|
||||||
<object id="17" x="46.6667" y="785.333" width="66.6667" height="14.6667"/>
|
|
||||||
<object id="18" x="177.333" y="784" width="105.333" height="16"/>
|
|
||||||
<object id="19" x="346.667" y="782.667" width="54.6667" height="16"/>
|
|
||||||
</objectgroup>
|
</objectgroup>
|
||||||
</map>
|
</map>
|
||||||
|
|
Ŝarĝante…
Reference in New Issue