Compare commits
No commits in common. "389eaed2850719e60046d54a5fcd934a0310664d" and "d0e849bf3d91fb750c1c3ed33dea92758da5336c" have entirely different histories.
389eaed285
...
d0e849bf3d
|
@ -18,5 +18,3 @@ require "data/scripts/objects"
|
||||||
require "data/scripts/debug"
|
require "data/scripts/debug"
|
||||||
require "data/scripts/keybind"
|
require "data/scripts/keybind"
|
||||||
require "data/scripts/pause"
|
require "data/scripts/pause"
|
||||||
-- game loop
|
|
||||||
require "data/scripts/game"
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ Camera = {
|
||||||
height = 0
|
height = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function Camera:positionCenterAt(x,y,cx,cy)
|
function Camera:CenterAt(x,y,cx,cy)
|
||||||
self.pos.x = x-self.width/game.scale/2
|
self.pos.x = x-self.width/game.scale/2
|
||||||
self.pos.y = y-self.height/game.scale/2
|
self.pos.y = y-self.height/game.scale/2
|
||||||
if not (cx == nil or cy == nil) then
|
if not (cx == nil or cy == nil) then
|
||||||
|
@ -19,7 +19,7 @@ function Camera:positionCenterAt(x,y,cx,cy)
|
||||||
self.pos.y = math.floor(self.pos.y)
|
self.pos.y = math.floor(self.pos.y)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Camera:positionAt(x,y)
|
function Camera:ScreenAt(x,y)
|
||||||
self.pos.x = math.floor(x/self.width)*self.width
|
self.pos.x = math.floor(x/self.width)*self.width
|
||||||
self.pos.y = math.floor(y/self.height)*self.height
|
self.pos.y = math.floor(y/self.height)*self.height
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,93 +0,0 @@
|
||||||
function stepEditor()
|
|
||||||
AnimateTiles()
|
|
||||||
end
|
|
||||||
|
|
||||||
function stepGame()
|
|
||||||
-- GAME STEP
|
|
||||||
if not do_pause then
|
|
||||||
SetCollisionFlags(main_Player)
|
|
||||||
for _, enty in pairs(LoadedEntities) do
|
|
||||||
enty:Smart()
|
|
||||||
enty:DoPhysics()
|
|
||||||
end
|
|
||||||
AnimateTiles()
|
|
||||||
Camera:positionCenterAt(main_Player.pos.x, main_Player.pos.y)
|
|
||||||
--camera:positionAt(main_Player.pos.x, main_Player.pos.y,game.width,game.height)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function drawEditor()
|
|
||||||
if game.width ~= love.graphics.getWidth() or game.height ~= love.graphics.getHeight() then
|
|
||||||
Camera.height = game.height
|
|
||||||
Camera.width = game.width
|
|
||||||
Canvas.Darkness:release()
|
|
||||||
Canvas.Darkness = CreateDarkness()
|
|
||||||
love.graphics.setCanvas(Canvas.Darkness)
|
|
||||||
SetDarkness()
|
|
||||||
love.graphics.setCanvas()
|
|
||||||
end
|
|
||||||
|
|
||||||
gameworldDraw()
|
|
||||||
end
|
|
||||||
|
|
||||||
function drawGame()
|
|
||||||
|
|
||||||
gameworldDraw()
|
|
||||||
gameworldLighting()
|
|
||||||
|
|
||||||
-- HUD
|
|
||||||
textScale = 0.5
|
|
||||||
|
|
||||||
--debug
|
|
||||||
if debug then DebugUI() end
|
|
||||||
if debug_collision then
|
|
||||||
DebugColisions()
|
|
||||||
DebugEntities()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- reset color
|
|
||||||
if do_pause then PauseUI() end
|
|
||||||
end
|
|
||||||
|
|
||||||
function gameworldDraw()
|
|
||||||
-- resize proof
|
|
||||||
if game_resize then
|
|
||||||
Camera.height = game.height
|
|
||||||
Camera.width = game.width
|
|
||||||
end
|
|
||||||
|
|
||||||
local pcr, pcg, pcb, pca = love.graphics.getColor()
|
|
||||||
|
|
||||||
love.graphics.scale(game.scale,game.scale)
|
|
||||||
love.graphics.setColor(1,1,1,1)
|
|
||||||
LevelDisplayBackground()
|
|
||||||
|
|
||||||
for _, enty in pairs(LoadedEntities) do
|
|
||||||
enty:HandleAnimation()
|
|
||||||
end
|
|
||||||
LevelDisplayForeground()
|
|
||||||
|
|
||||||
love.graphics.setColor(pcr, pcg, pcb, pca)
|
|
||||||
end
|
|
||||||
|
|
||||||
function gameworldLighting()
|
|
||||||
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.setCanvas()
|
|
||||||
love.graphics.scale(1,1)
|
|
||||||
DrawDarkness()
|
|
||||||
end
|
|
82
main.lua
82
main.lua
|
@ -65,9 +65,21 @@ function love.update(dt)
|
||||||
|
|
||||||
|
|
||||||
if editor_mode then
|
if editor_mode then
|
||||||
stepEditor()
|
|
||||||
|
|
||||||
|
AnimateTiles()
|
||||||
else
|
else
|
||||||
stepGame()
|
-- GAME STEP
|
||||||
|
if not do_pause then
|
||||||
|
SetCollisionFlags(main_Player)
|
||||||
|
for _, enty in pairs(LoadedEntities) do
|
||||||
|
enty:Smart()
|
||||||
|
enty:DoPhysics()
|
||||||
|
end
|
||||||
|
AnimateTiles()
|
||||||
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -84,6 +96,7 @@ function love.wheelmoved(_, y)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.keypressed(key)
|
function love.keypressed(key)
|
||||||
|
|
||||||
if key == "escape" then
|
if key == "escape" then
|
||||||
if do_pause then
|
if do_pause then
|
||||||
do_pause = false
|
do_pause = false
|
||||||
|
@ -126,17 +139,60 @@ function love.keypressed(key)
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.draw()
|
function love.draw()
|
||||||
if game.width ~= love.graphics.getWidth() or game.height ~= love.graphics.getHeight() then
|
|
||||||
game.width = love.graphics.getWidth()
|
-- saveproof to game resize
|
||||||
game.height = love.graphics.getHeight()
|
if game.width ~= love.graphics.getWidth() or game.height ~= love.graphics.getHeight() then
|
||||||
game_resize = true
|
game.width = love.graphics.getWidth()
|
||||||
else
|
game.height = love.graphics.getHeight()
|
||||||
game_resize = false
|
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)
|
||||||
|
LevelDisplayBackground()
|
||||||
|
for _, enty in pairs(LoadedEntities) do
|
||||||
|
enty:HandleAnimation()
|
||||||
|
end
|
||||||
|
LevelDisplayForeground()
|
||||||
|
|
||||||
|
-- Save color
|
||||||
|
local pcr, pcg, pcb, pca = love.graphics.getColor()
|
||||||
|
|
||||||
|
love.graphics.setCanvas(Canvas.Darkness)
|
||||||
|
SetDarkness()
|
||||||
|
DoLights()
|
||||||
|
DoBorder()
|
||||||
|
|
||||||
|
-- reset to screen
|
||||||
|
love.graphics.setColor(1,1,1,1)
|
||||||
|
love.graphics.setCanvas()
|
||||||
|
love.graphics.scale(1,1)
|
||||||
|
DrawDarkness()
|
||||||
|
-- HUD
|
||||||
|
-- Scale control
|
||||||
|
textScale = 0.5
|
||||||
|
|
||||||
|
--debug
|
||||||
|
if debug then DebugUI() end
|
||||||
|
if debug_collision then
|
||||||
|
love.graphics.setCanvas(Canvas.Darkness)
|
||||||
|
SetDarkness()
|
||||||
|
love.graphics.setCanvas()
|
||||||
|
--DrawDarkness()
|
||||||
|
DebugColisions()
|
||||||
|
DebugEntities()
|
||||||
end
|
end
|
||||||
|
|
||||||
if editor_mode then
|
-- reset color
|
||||||
drawEditor()
|
love.graphics.setColor(pcr,pcg,pcb,pca)
|
||||||
else
|
local pcr, pcg, pcb, pca = love.graphics.getColor()
|
||||||
drawGame()
|
if do_pause then PauseUI() end
|
||||||
end
|
love.graphics.setColor(pcr,pcg,pcb,pca)
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
(X) REHANDLE ANIMATIONS
|
(X) REHANDLE ANIMATIONS
|
||||||
(X) 3 COLOR PALETTE (GOLD)
|
(X) 3 COLOR PALETTE (GOLD)
|
||||||
(X) MASKS FUNCTIONALITY
|
(X) MASKS FUNCTIONALITY
|
||||||
(X) MAKE PHYSICS CONSISTENT
|
|
||||||
(X) MAKE HITBOXES
|
|
||||||
(X) PHYSICS BY FRAME
|
|
||||||
( ) MAKE ARROW CANVAS SO THAT
|
( ) MAKE ARROW CANVAS SO THAT
|
||||||
ARROWS WHEN STUCK CAN BE STORED
|
ARROWS WHEN STUCK CAN BE STORED
|
||||||
AS IMAGE AND NOT ENTITIES!!!
|
AS IMAGE AND NOT ENTITIES!!!
|
||||||
|
@ -13,3 +10,6 @@ AS IMAGE AND NOT ENTITIES!!!
|
||||||
(~) DO FAIRY
|
(~) DO FAIRY
|
||||||
( ) DO FLIES
|
( ) DO FLIES
|
||||||
( ) DO UI
|
( ) DO UI
|
||||||
|
> (X) MAKE PHYSICS CONSISTENT
|
||||||
|
> > (X) MAKE HITBOXES
|
||||||
|
> > (X) PHYSICS BY FRAME
|
||||||
|
|
Loading…
Reference in New Issue