restructured folder
This commit is contained in:
89
code/gameworld.lua
Normal file
89
code/gameworld.lua
Normal file
@@ -0,0 +1,89 @@
|
||||
function GameworldDrawPrepare()
|
||||
if game_resize then
|
||||
Camera.height = game.height
|
||||
Camera.width = game.width
|
||||
end
|
||||
pcr, pcg, pcb, pca = love.graphics.getColor()
|
||||
love.graphics.scale(game.scale,game.scale)
|
||||
love.graphics.setColor(1,1,1,1)
|
||||
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 = TileData[LevelTiles[i][j].id].depth
|
||||
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(LoadedObjects.Entities) do
|
||||
enty:HandleAnimation()
|
||||
end
|
||||
end
|
||||
|
||||
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 = TileData[LevelTiles[i][j].id].depth
|
||||
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()
|
||||
love.graphics.setCanvas(Canvas.Darkness)
|
||||
SetDarkness()
|
||||
love.graphics.setCanvas()
|
||||
end
|
||||
|
||||
-- work on lighting canvas
|
||||
love.graphics.setCanvas(Canvas.Darkness)
|
||||
SetDarkness()
|
||||
DoLights()
|
||||
DoBorder()
|
||||
-- apply to game canvas
|
||||
love.graphics.setColor(1,1,1,1)
|
||||
love.graphics.scale(game.scale,game.scale)
|
||||
love.graphics.setCanvas()
|
||||
DrawDarkness()
|
||||
love.graphics.scale(1/game.scale,1/game.scale)
|
||||
end
|
||||
Reference in New Issue
Block a user