- adjusted lights so they are called to do something, instead of it being handled on game world - lights has only coordinate arguments + a table with all other optional ones. - renamed a lot of lights components to radius instaed of range, as it was agreed before elsewhere
99 lines
2.5 KiB
Lua
99 lines
2.5 KiB
Lua
function startGameworldDraw()
|
|
if game_resize then
|
|
Camera.height = game.height
|
|
Camera.width = game.width
|
|
Canvas.Darkness:recreate()
|
|
end
|
|
pcr, pcg, pcb, pca = love.graphics.getColor()
|
|
love.graphics.setScale(game.scale,game.scale)
|
|
love.graphics.setColor(1,1,1,1)
|
|
end
|
|
|
|
function endGameworldDraw()
|
|
love.graphics.setColor(pcr, pcg, pcb, pca)
|
|
pcr, pcg, pcb, pca = nil, nil, nil, nil
|
|
end
|
|
|
|
function drawGameworldBackground()
|
|
-- 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 = TileData[LevelTiles[i][j].id].depth
|
|
drawTile(
|
|
LevelTiles[i][j],
|
|
tile_properties.scale * j * tile_properties.width + tile_properties.scale * (level_properties.offset.x - tile_properties.width) - Camera.pos.x,
|
|
tile_properties.scale * i * tile_properties.height + tile_properties.scale * (level_properties.offset.y - tile_properties.height) - Camera.pos.y,
|
|
"background"
|
|
)
|
|
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function drawGameworldParticles()
|
|
love.graphics.setColor(0.7,0.7,0.7)
|
|
for _, particle in pairs(LoadedObjects.Particles) do
|
|
particle:handleAnimation()
|
|
end
|
|
end
|
|
|
|
function drawGameworldEntitiesBackground()
|
|
for _, enty in pairs(LoadedObjects.Entities) do
|
|
enty:drawBackground()
|
|
end
|
|
end
|
|
|
|
function drawGameworldEntities()
|
|
love.graphics.setColor(0.7,0.7,0.7)
|
|
for _, enty in pairs(LoadedObjects.Entities) do
|
|
enty:handleAnimation()
|
|
end
|
|
end
|
|
|
|
function drawGameworldForeground()
|
|
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 = TileData[LevelTiles[i][j].id].depth
|
|
drawTile(
|
|
LevelTiles[i][j],
|
|
tile_properties.scale * j * tile_properties.width + tile_properties.scale * (level_properties.offset.x - tile_properties.width) - Camera.pos.x,
|
|
tile_properties.scale * i * tile_properties.height + tile_properties.scale * (level_properties.offset.y - tile_properties.height) - Camera.pos.y,
|
|
"foreground"
|
|
)
|
|
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function drawGameworldDarkness()
|
|
Canvas.Darkness:reset()
|
|
Canvas.Darkness:startDrawing()
|
|
love.graphics.setBlendMode("replace")
|
|
love.graphics.setColor(0,0,0,0)
|
|
for _, light in pairs(LoadedObjects.Lights) do
|
|
light:drawClear()
|
|
end
|
|
Canvas.Darkness:endDrawing()
|
|
Canvas.Darkness:draw()
|
|
end
|
|
|
|
function drawGameworldLights()
|
|
for _, light in pairs(LoadedObjects.Lights) do
|
|
light:drawShine()
|
|
end
|
|
end
|
|
|
|
function updateGameWorldLights()
|
|
for _, light in pairs(LoadedObjects.Lights) do
|
|
light:flicker()
|
|
end
|
|
end
|