Mothback/main.lua

117 lines
2.0 KiB
Lua
Raw Normal View History

2022-01-18 19:45:57 +00:00
function love.load()
2022-01-18 20:12:13 +00:00
arrow = 0
2022-01-18 19:45:57 +00:00
do_pause = false
debug = false
debug_collision = false
editor_mode = false
textScale = 1
fps_count = 0
fps_second = 0
fps_draw = 0
fps_total = 0
UIElement = {}
2022-01-18 19:45:57 +00:00
love.graphics.setColor(1,1,1)
love.keyboard.setKeyRepeat(true)
love.graphics.setDefaultFilter("nearest") -- good pixel
game = {
scale = 2,
width = love.graphics.getWidth(),
height = love.graphics.getHeight(),
paused = false
}
require "data/scripts"
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 = {}
LoadedParticles = {}
2022-01-18 19:45:57 +00:00
LevelLoadTiles()
main_Player = Player:New(75,50)
--Kupo:New(100,150)
--Kupo:New(300,150)
--Decoration:New(200,89,animation.decoration.candelabra,80)
--Fairy:New(200,88)
--CursedBook:New(180,68)
2022-01-18 19:45:57 +00:00
2022-01-18 20:12:13 +00:00
gravity = 0.2
2022-01-18 19:45:57 +00:00
end
function love.update(dt)
-- fps counter
if fps_second >= 1 then
fps_second = fps_second - 1
fps_draw = fps_count
fps_count = 0
fps_total = fps_total + 1
end
fps_second = fps_second + dt
fps_count = fps_count + 1
current_dt = dt
--keypressed
if Keybind:HasPressed(Keybind.menu.pause) then
2022-01-18 19:45:57 +00:00
if do_pause then
do_pause = false
else
menuPage = "pauseMenu"
MenuInit(menuPage)
2022-01-18 19:45:57 +00:00
end
end
--MenuStep
if menuPage ~= nil then MenuStep(menuPage) end
--editor
if editor_mode then
EditorStep()
else
GameStep()
end
end
function love.wheelmoved(_, y)
if editor_mode then
EditorScroll(y)
end
2022-01-18 19:45:57 +00:00
end
function love.draw()
if game.width ~= love.graphics.getWidth() or game.height ~= love.graphics.getHeight() then
game.width = love.graphics.getWidth()
game.height = love.graphics.getHeight()
game_resize = true
else
game_resize = false
end
if editor_mode then
EditorDraw()
2022-01-18 19:45:57 +00:00
else
GameDraw()
2022-01-18 19:45:57 +00:00
end
if menuPage ~= nil then MenuDraw(menuPage) end
2022-01-18 20:12:13 +00:00
love.graphics.print(arrow,10,40)
2022-01-18 19:45:57 +00:00
end