editor progress, generic keybinds, player coyote value, cursed book entity, level changes, camera adjustments
This commit is contained in:
@@ -1,39 +1,54 @@
|
||||
function LevelLoadTiles()
|
||||
|
||||
LevelData = dofile("Mothback/data/levels/"..currLevel..".lua")
|
||||
|
||||
-- tiles data
|
||||
TileData = dofile("Mothback/data/tileset/library.lua")
|
||||
|
||||
--[[
|
||||
on level format:
|
||||
|
||||
id = tile identifier
|
||||
depth = order in the render
|
||||
force = rendering other tile instead of the one in this position
|
||||
overlay = render another tile id or, if multiple tiles {id, id, id,} or
|
||||
overlay = render another tile id or, if multiple tiles {id, id, id,}, choose at random
|
||||
overlay_depth = foreground/background overlay depth
|
||||
type = collision type
|
||||
]]
|
||||
|
||||
|
||||
-- Level data
|
||||
LevelData = dofile("Mothback/data/levels/"..currLevel..".lua")
|
||||
|
||||
-- tiles data
|
||||
TileData = dofile("Mothback/data/tileset/library.lua")
|
||||
|
||||
LevelTiles = LevelData.tiles
|
||||
LevelData.Width = LevelGetWidth()
|
||||
LevelData.Height = LevelGetHeight()
|
||||
LevelUpdateDimensions()
|
||||
LevelIndexTiles()
|
||||
TileCreateObjects()
|
||||
end
|
||||
|
||||
function LevelGetHeight()
|
||||
return #LevelTiles * tileProperties.height
|
||||
function LevelReloadTiles()
|
||||
LevelUpdateDimensions()
|
||||
TileCreateObjects()
|
||||
end
|
||||
|
||||
function LevelGetWidth()
|
||||
function LevelUpdateDimensions()
|
||||
LevelData.Width = LevelGetWidth()
|
||||
LevelData.Height = LevelGetHeight()
|
||||
end
|
||||
|
||||
function LevelGetTileHeight()
|
||||
return #LevelTiles
|
||||
end
|
||||
|
||||
function LevelGetTileWidth()
|
||||
local width = 0
|
||||
for i = 1, #LevelTiles do
|
||||
if width < #LevelTiles[i] then width = #LevelTiles[i] end
|
||||
end
|
||||
return width * tileProperties.width
|
||||
return width
|
||||
end
|
||||
|
||||
function LevelGetHeight()
|
||||
return LevelGetTileHeight() * tileProperties.height
|
||||
end
|
||||
|
||||
function LevelGetWidth()
|
||||
return LevelGetTileWidth() * tileProperties.width
|
||||
end
|
||||
|
||||
function LevelIndexTiles()
|
||||
@@ -53,8 +68,17 @@ function LevelIndexTiles()
|
||||
)
|
||||
end
|
||||
end
|
||||
TileDataInitialize()
|
||||
|
||||
-- initialize tile data
|
||||
-- instance level tiles according to the Properties
|
||||
for i = 1, #LevelTiles do
|
||||
for j = 1, #LevelTiles[i] do
|
||||
InstanceTile(i,j,LevelTiles[i][j])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function TileDataInitialize()
|
||||
for _, Properties in pairs(TileData) do
|
||||
if Properties.animation ~= nil then
|
||||
Properties.tileset = love.graphics.newImage("assets/terrain/"..Properties.animation..".png")
|
||||
@@ -85,33 +109,28 @@ function LevelIndexTiles()
|
||||
Properties.image_count = image_count
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- instance level tiles according to the Properties
|
||||
for i = 1, #LevelTiles do
|
||||
for j = 1, #LevelTiles[i] do
|
||||
local id = LevelTiles[i][j]
|
||||
LevelTiles[i][j] = {}
|
||||
local tile = LevelTiles[i][j]
|
||||
tile.id = id
|
||||
function InstanceTile(i,j,id)
|
||||
LevelTiles[i][j] = {}
|
||||
local tile = LevelTiles[i][j]
|
||||
tile.id = id
|
||||
|
||||
for _, Properties in pairs(TileData) do
|
||||
if Properties.id == tile.id then
|
||||
if type(Properties.overlay) == "table" then
|
||||
tile.display_overlay = Properties.overlay[math.random(#Properties.overlay)]
|
||||
else
|
||||
tile.display_overlay = Properties.overlay
|
||||
end
|
||||
for _, Properties in pairs(TileData) do
|
||||
if Properties.id == tile.id then
|
||||
if type(Properties.overlay) == "table" then
|
||||
tile.display_overlay = Properties.overlay[math.random(#Properties.overlay)]
|
||||
else
|
||||
tile.display_overlay = Properties.overlay
|
||||
end
|
||||
|
||||
if type(Properties.force) == "table" then
|
||||
tile.display = Properties.force[math.random(#Properties.force)]
|
||||
else
|
||||
tile.display = Properties.force
|
||||
end
|
||||
if type(Properties.force) == "table" then
|
||||
tile.display = Properties.force[math.random(#Properties.force)]
|
||||
else
|
||||
tile.display = Properties.force
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function TileGetType(tile)
|
||||
|
||||
Reference in New Issue
Block a user