New lighting!
This commit is contained in:
41
main.lua
41
main.lua
@@ -20,17 +20,20 @@ function love.load()
|
||||
Canvas = {
|
||||
Darkness = CreateDarkness()
|
||||
}
|
||||
love.graphics.setCanvas(Canvas.Darkness)
|
||||
SetDarkness()
|
||||
love.graphics.setCanvas()
|
||||
Camera.width = game.width
|
||||
Camera.height = game.height
|
||||
levelList = {"level1","2","3","ewae","tileset"}
|
||||
levelNum = 1
|
||||
currLevel = levelList[levelNum]
|
||||
LoadedEntities = {}
|
||||
LevelLoadTiles()
|
||||
main_Player = Player:New(0,20)
|
||||
LoadedEntities = {}
|
||||
table.insert(LoadedEntities,main_Player)
|
||||
table.insert(LoadedEntities,Kupo:New(450,100))
|
||||
table.insert(LoadedEntities,Kupo:New(250,150))
|
||||
table.insert(LoadedEntities,Kupo:New(700,150))
|
||||
table.insert(LoadedEntities,Kupo:New(800,150))
|
||||
main_Player.sprite = love.graphics.newImage("assets/characters/nancy/idle1.png")
|
||||
main_Player:LoadAnimation(animation.nancy.idle)
|
||||
end
|
||||
@@ -47,16 +50,6 @@ function love.update(dt)
|
||||
fps_count = fps_count + 1
|
||||
current_dt = dt
|
||||
|
||||
-- saveproof to game resize
|
||||
if game.width ~= love.graphics.getWidth() or game.height ~= love.graphics.getHeight() then
|
||||
game.width = love.graphics.getWidth()
|
||||
game.height = love.graphics.getHeight()
|
||||
Camera.height = game.height
|
||||
Camera.width = game.width
|
||||
Canvas.Darkness:release()
|
||||
Canvas.Darkness = CreateDarkness()
|
||||
end
|
||||
|
||||
-- GAME STEP
|
||||
if not do_pause then
|
||||
SetCollisionFlags(main_Player)
|
||||
@@ -65,7 +58,7 @@ function love.update(dt)
|
||||
enty:DoPhysics()
|
||||
end
|
||||
AnimateTiles()
|
||||
Camera:CenterAt(main_Player.pos.x, main_Player.pos.y,LevelInfo.Width,LevelInfo.Height)
|
||||
Camera:CenterAt(main_Player.pos.x, main_Player.pos.y)
|
||||
--camera:ScreenAt(main_Player.pos.x, main_Player.pos.y,game.width,game.height)
|
||||
end
|
||||
end
|
||||
@@ -110,6 +103,20 @@ function love.keypressed(key)
|
||||
end
|
||||
|
||||
function love.draw()
|
||||
|
||||
-- saveproof to game resize
|
||||
if game.width ~= love.graphics.getWidth() or game.height ~= love.graphics.getHeight() then
|
||||
game.width = love.graphics.getWidth()
|
||||
game.height = love.graphics.getHeight()
|
||||
Camera.height = game.height
|
||||
Camera.width = game.width
|
||||
Canvas.Darkness:release()
|
||||
Canvas.Darkness = CreateDarkness()
|
||||
love.graphics.setCanvas(Canvas.Darkness)
|
||||
SetDarkness()
|
||||
love.graphics.setCanvas()
|
||||
end
|
||||
|
||||
-- GAME WORLD
|
||||
love.graphics.scale(game.scale,game.scale)
|
||||
love.graphics.setColor(1,1,1,1)
|
||||
@@ -123,7 +130,7 @@ function love.draw()
|
||||
|
||||
-- Save color
|
||||
local pcr, pcg, pcb, pca = love.graphics.getColor()
|
||||
|
||||
|
||||
love.graphics.setCanvas(Canvas.Darkness)
|
||||
DoDarkness()
|
||||
DoLights()
|
||||
@@ -133,11 +140,11 @@ function love.draw()
|
||||
love.graphics.setColor(1,1,1,1)
|
||||
love.graphics.setCanvas()
|
||||
love.graphics.scale(1,1)
|
||||
DrawDarkness()
|
||||
DrawDarkness()
|
||||
-- HUD
|
||||
-- Scale control
|
||||
textScale = 0.5
|
||||
|
||||
|
||||
--debug
|
||||
if debug then DebugUI() end
|
||||
if debug_collision then DebugColisions() end
|
||||
|
||||
Reference in New Issue
Block a user