1
0
Fork 0
mirror of https://github.com/Reuh/ubiquitousse.git synced 2025-10-27 17:19:31 +00:00

ldtk: rename Layer.offsetX/Y to Layer.x/y, add Level:drawBackground

This commit is contained in:
Étienne Fildadut 2021-12-27 13:26:15 +01:00
parent 86373c98de
commit f78499e891
12 changed files with 70 additions and 35 deletions

View file

@ -108,7 +108,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 13:15:05 </i> <i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -334,7 +334,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 13:15:05 </i> <i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -1626,7 +1626,7 @@ its sibling systems (i.e. completely stop the propagation of the event).</li>
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 13:15:05 </i> <i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -206,11 +206,11 @@ end
<td class="summary">The layer order: smaller order means it is on top.</td> <td class="summary">The layer order: smaller order means it is on top.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Layer.offsetX">Layer.offsetX</a></td> <td class="name" nowrap><a href="#Layer.x">Layer.x</a></td>
<td class="summary">X position of the layer relative to the level.</td> <td class="summary">X position of the layer relative to the level.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Layer.offsetY">Layer.offsetY</a></td> <td class="name" nowrap><a href="#Layer.y">Layer.y</a></td>
<td class="summary">Y position of the layer relative to the level.</td> <td class="summary">Y position of the layer relative to the level.</td>
</tr> </tr>
<tr> <tr>
@ -312,7 +312,11 @@ end
<table class="function_list"> <table class="function_list">
<tr> <tr>
<td class="name" nowrap><a href="#Level:draw">Level:draw ()</a></td> <td class="name" nowrap><a href="#Level:draw">Level:draw ()</a></td>
<td class="summary">Draw this level.</td> <td class="summary">Draw this level (background and layers).</td>
</tr>
<tr>
<td class="name" nowrap><a href="#Level:drawBackground">Level:drawBackground ()</a></td>
<td class="summary">Draw this level background.</td>
</tr> </tr>
<tr> <tr>
<td class="name" nowrap><a href="#Level:load">Level:load ([, callbacks])</a></td> <td class="name" nowrap><a href="#Level:load">Level:load ([, callbacks])</a></td>
@ -909,8 +913,8 @@ end
</dd> </dd>
<dt> <dt>
<a name = "Layer.offsetX"></a> <a name = "Layer.x"></a>
<strong>Layer.offsetX</strong> <strong>Layer.x</strong>
</dt> </dt>
<dd> <dd>
X position of the layer relative to the level. X position of the layer relative to the level.
@ -930,8 +934,8 @@ end
</dd> </dd>
<dt> <dt>
<a name = "Layer.offsetY"></a> <a name = "Layer.y"></a>
<strong>Layer.offsetY</strong> <strong>Layer.y</strong>
</dt> </dt>
<dd> <dd>
Y position of the layer relative to the level. Y position of the layer relative to the level.
@ -1458,7 +1462,7 @@ end
<strong>Level:draw ()</strong> <strong>Level:draw ()</strong>
</dt> </dt>
<dd> <dd>
Draw this level. Draw this level (background and layers).
Assumes we are currently in world coordinates (i.e. world top-left is at 0,0). Assumes we are currently in world coordinates (i.e. world top-left is at 0,0).
The level must be loaded. The level must be loaded.
Will draw the eventual backgrounds and all the layers in the level. Will draw the eventual backgrounds and all the layers in the level.
@ -1476,6 +1480,29 @@ end
</dd>
<dt>
<a name = "Level:drawBackground"></a>
<strong>Level:drawBackground ()</strong>
</dt>
<dd>
Draw this level background.
Assumes we are currently in level coordinates (i.e. level top-left is at 0,0).
The level must be loaded.
<h3>Requires:</h3>
<ul>
love
</ul>
</ul>
</ul>
</ul>
</dd> </dd>
<dt> <dt>
<a name = "Level:load"></a> <a name = "Level:load"></a>
@ -1754,7 +1781,7 @@ end
Level background. </p> Level background. </p>
<p> If there is a background image, <code>background.image</code> contains a table <code>{image=image, x=number, y=number, sx=number, sy=number}</code> <p> If there is a background image, <code>background.image</code> contains a table <code>{image=image, x=number, y=number, sx=number, sy=number}</code>
where <a href="../modules/ldtk.html#Tileset.image">image</a> is the LÖVE image (or image filepath if LÖVE not available) <a href="../modules/ldtk.html#Level.x">x</a> and <a href="../modules/ldtk.html#Tile.y">y</a> are the top-left position, where <a href="../modules/ldtk.html#Tileset.image">image</a> is the LÖVE image (or image filepath if LÖVE not available) <a href="../modules/ldtk.html#Entity.x">x</a> and <a href="../modules/ldtk.html#Entity.y">y</a> are the top-left position,
and <a href="../modules/ldtk.html#Entity.sx">sx</a> and <a href="../modules/ldtk.html#Entity.sy">sy</a> the horizontal and vertical scale factors. and <a href="../modules/ldtk.html#Entity.sx">sx</a> and <a href="../modules/ldtk.html#Entity.sy">sy</a> the horizontal and vertical scale factors.
</ul> </ul>
@ -1829,7 +1856,7 @@ end
<li>Enum are converted into a Lua string giving the currently selected enum value.</li> <li>Enum are converted into a Lua string giving the currently selected enum value.</li>
<li>Filepath are converted into a Lua string giving the file path.</li> <li>Filepath are converted into a Lua string giving the file path.</li>
<li>Arrays are converted into a Lua table with the elements in it as a list.</li> <li>Arrays are converted into a Lua table with the elements in it as a list.</li>
<li>Points are converted into a Lua table with the fields <a href="../modules/ldtk.html#Level.x">x</a> and <a href="../modules/ldtk.html#Tile.y">y</a>: <code>{ x=number, y=number }</code>.</li> <li>Points are converted into a Lua table with the fields <a href="../modules/ldtk.html#Entity.x">x</a> and <a href="../modules/ldtk.html#Entity.y">y</a>: <code>{ x=number, y=number }</code>.</li>
<li>Colors are converted into a Lua table with the red, green and blue components in [0-1] as a list: <code>{r,g,b}</code>.</li> <li>Colors are converted into a Lua table with the red, green and blue components in [0-1] as a list: <code>{r,g,b}</code>.</li>
</ul> </ul>
@ -1855,7 +1882,7 @@ end
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 13:15:05 </i> <i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -702,7 +702,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 13:15:05 </i> <i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -414,7 +414,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 13:15:05 </i> <i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -1153,7 +1153,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 13:15:05 </i> <i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -362,7 +362,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 13:15:05 </i> <i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -784,7 +784,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 13:15:05 </i> <i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -64,7 +64,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 13:15:05 </i> <i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -71,7 +71,7 @@
</div> <!-- id="main" --> </div> <!-- id="main" -->
<div id="about"> <div id="about">
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i> <i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
<i style="float:right;">Last updated 2021-12-27 13:15:05 </i> <i style="float:right;">Last updated 2021-12-27 13:22:21 </i>
</div> <!-- id="about" --> </div> <!-- id="about" -->
</div> <!-- id="container" --> </div> <!-- id="container" -->
</body> </body>

View file

@ -150,7 +150,7 @@ let layer_mt = {
draw = :() draw = :()
if @visible then if @visible then
lg.push() lg.push()
lg.translate(@offsetX, @offsetY) lg.translate(@x, @y)
if @spritebatch then if @spritebatch then
lg.setColor(1, 1, 1, @opacity) lg.setColor(1, 1, 1, @opacity)
lg.draw(@spritebatch) lg.draw(@spritebatch)
@ -211,10 +211,10 @@ let layer_mt = {
order = order, order = order,
--- X position of the layer relative to the level. --- X position of the layer relative to the level.
-- @ftype number -- @ftype number
offsetX = layer.__pxTotalOffsetX, x = layer.__pxTotalOffsetX,
--- Y position of the layer relative to the level. --- Y position of the layer relative to the level.
-- @ftype number -- @ftype number
offsetY = layer.__pxTotalOffsetY, y = layer.__pxTotalOffsetY,
--- Size of the grid on this layer. --- Size of the grid on this layer.
-- @ftype number -- @ftype number
gridSize = gridSize, gridSize = gridSize,
@ -441,7 +441,7 @@ layer_mt.__index = layer_mt
-- --
-- @type Level -- @type Level
let level_mt = { let level_mt = {
--- Draw this level. --- Draw this level (background and layers).
-- Assumes we are currently in world coordinates (i.e. world top-left is at 0,0). -- Assumes we are currently in world coordinates (i.e. world top-left is at 0,0).
-- The level must be loaded. -- The level must be loaded.
-- Will draw the eventual backgrounds and all the layers in the level. -- Will draw the eventual backgrounds and all the layers in the level.
@ -450,6 +450,19 @@ let level_mt = {
assert(@loaded == true, "level not loaded") assert(@loaded == true, "level not loaded")
lg.push() lg.push()
lg.translate(@x, @y) lg.translate(@x, @y)
@drawBackground()
-- layers
for _, l in ipairs(@layers) do
l:draw()
end
lg.pop()
end,
--- Draw this level background.
-- Assumes we are currently in level coordinates (i.e. level top-left is at 0,0).
-- The level must be loaded.
-- @require love
drawBackground = :()
assert(@loaded == true, "level not loaded")
-- background color -- background color
lg.setColor(@background.color) lg.setColor(@background.color)
lg.rectangle("fill", 0, 0, @width, @height) lg.rectangle("fill", 0, 0, @width, @height)
@ -459,11 +472,6 @@ let level_mt = {
if bgImage then if bgImage then
lg.draw(bgImage.image, bgImage.quad, bgImage.x, bgImage.y, 0, bgImage.sx, bgImage.sy) lg.draw(bgImage.image, bgImage.quad, bgImage.x, bgImage.y, 0, bgImage.sx, bgImage.sy)
end end
-- layers
for _, l in ipairs(@layers) do
l:draw()
end
lg.pop()
end, end,
--- Load the level. --- Load the level.
@ -589,7 +597,7 @@ level_mt.__index = level_mt
-- @type Project -- @type Project
let project_mt = { let project_mt = {
_init = (project, directory) _init = (project, directory)
assert(project.jsonVersion == "0.9.3", "map made for LDtk version %s":format(project.jsonVersion)) assert(project.jsonVersion == "0.9.3", "the map was made with LDtk version %s but the importer is made for 0.9.3":format(project.jsonVersion))
let t = { let t = {
--- List of `Level`s in this project. --- List of `Level`s in this project.
-- @ftype {Level,...} -- @ftype {Level,...}