consistent naming; moving functions from level.lua to gameworld.lua

This commit is contained in:
lustlion
2022-01-22 23:10:21 +01:00
parent f4b44dc7bc
commit 90ed1f6460
13 changed files with 381 additions and 202 deletions

View File

@@ -1,28 +1,72 @@
function GameworldDraw()
-- resize proof
function GameworldDrawPrepare()
if game_resize then
Camera.height = game.height
Camera.width = game.width
end
local pcr, pcg, pcb, pca = love.graphics.getColor()
pcr, pcg, pcb, pca = love.graphics.getColor()
love.graphics.scale(game.scale,game.scale)
love.graphics.setColor(1,1,1,1)
LevelDisplayBackground()
end
function GameworldDrawEnd()
love.graphics.setColor(pcr, pcg, pcb, pca)
pcr, pcg, pcb, pca = nil, nil, nil, nil
end
function GameworldDrawBackground()
-- obscure a bit
love.graphics.setColor(0.7,0.7,0.7)
for i = 1, #LevelTiles do
for j = 1, #LevelTiles[i] do
if LevelTiles[i][j].id ~= 0 then
local depth = TileGetDepth(LevelTiles[i][j])
DrawTile(
LevelTiles[i][j],
tileProperties.scale * j * tileProperties.width + tileProperties.scale * (levelProperties.offset.x - tileProperties.width) - Camera.pos.x,
tileProperties.scale * i * tileProperties.height + tileProperties.scale * (levelProperties.offset.y - tileProperties.height) - Camera.pos.y,
"background"
)
end
end
end
end
function GameworldDrawParticles()
love.graphics.setColor(0.7,0.7,0.7)
for _, particle in pairs(LoadedParticles) do
particle:HandleAnimation()
end
end
function GameworldDrawEntities()
love.graphics.setColor(1,1,1)
for _, enty in pairs(LoadedEntities) do
enty:HandleAnimation()
end
LevelDisplayForeground()
love.graphics.setColor(pcr, pcg, pcb, pca)
end
function GameworldLighting()
function GameworldDrawForeground()
love.graphics.setColor(1,1,1)
for i = 1, #LevelTiles do
for j = 1, #LevelTiles[i] do
if LevelTiles[i][j].id ~= 0 then
local depth = TileGetDepth(LevelTiles[i][j])
DrawTile(
LevelTiles[i][j],
tileProperties.scale * j * tileProperties.width + tileProperties.scale * (levelProperties.offset.x - tileProperties.width) - Camera.pos.x,
tileProperties.scale * i * tileProperties.height + tileProperties.scale * (levelProperties.offset.y - tileProperties.height) - Camera.pos.y,
"foreground"
)
end
end
end
end
function GameworldDrawLighting()
if game_resize then
Canvas.Darkness:release()
Canvas.Darkness = CreateDarkness()