2022-01-18 19:45:57 +00:00
|
|
|
function love.load()
|
2022-01-31 14:03:14 +00:00
|
|
|
--logging = true
|
|
|
|
if logging then print("love: "..collectgarbage("count").." kB") end
|
2022-01-18 20:12:13 +00:00
|
|
|
arrow = 0
|
2022-01-18 19:45:57 +00:00
|
|
|
|
2022-02-03 04:31:25 +00:00
|
|
|
menu_type = "no"
|
2022-01-18 19:45:57 +00:00
|
|
|
debug = false
|
|
|
|
debug_collision = false
|
|
|
|
editor_mode = false
|
|
|
|
|
|
|
|
textScale = 1
|
|
|
|
fps_count = 0
|
|
|
|
fps_second = 0
|
|
|
|
fps_draw = 0
|
|
|
|
fps_total = 0
|
|
|
|
|
|
|
|
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 = {}
|
2022-01-19 23:53:59 +00:00
|
|
|
LoadedParticles = {}
|
2022-01-18 19:45:57 +00:00
|
|
|
LevelLoadTiles()
|
|
|
|
|
2022-02-03 05:02:06 +00:00
|
|
|
language = "ENG"
|
2022-01-31 10:06:24 +00:00
|
|
|
LocaleLoad(language)
|
2022-01-31 10:03:58 +00:00
|
|
|
|
2022-01-18 19:45:57 +00:00
|
|
|
main_Player = Player:New(75,50)
|
|
|
|
|
2022-01-29 07:49:45 +00:00
|
|
|
--Kupo:New(100,150)
|
|
|
|
--Kupo:New(300,150)
|
2022-02-05 11:32:47 +00:00
|
|
|
Decoration:New(200,89,animation.decoration.candelabra,80)
|
|
|
|
Fairy:New(200,88)
|
2022-01-29 07:49:45 +00:00
|
|
|
--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-31 14:03:14 +00:00
|
|
|
-- Debug and log stuff
|
|
|
|
memoryUsage, dtcount = 0, 0
|
|
|
|
if logging then print("mothback: "..collectgarbage("count").." kB, Loading time: "..os.clock().." seconds") end
|
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
|
|
|
|
|
2022-01-31 14:03:14 +00:00
|
|
|
-- things per second
|
|
|
|
dtcount = dtcount + dt
|
|
|
|
if dtcount >= 1 then
|
|
|
|
if secs == nil then secs = 0 end
|
|
|
|
secs = secs + 1
|
|
|
|
dtcount = dtcount - 1
|
|
|
|
if debug or logging then
|
|
|
|
memoryUsage = math.floor(collectgarbage("count"))
|
|
|
|
end
|
|
|
|
if logging then print("Second "..secs..": "..memoryUsage.." kB") end
|
|
|
|
end
|
|
|
|
|
2022-01-19 12:28:09 +00:00
|
|
|
--keypressed
|
2022-01-19 13:55:15 +00:00
|
|
|
if Keybind:HasPressed(Keybind.menu.pause) then
|
2022-01-18 19:45:57 +00:00
|
|
|
if do_pause then
|
|
|
|
do_pause = false
|
|
|
|
else
|
2022-02-03 04:31:25 +00:00
|
|
|
menu_type = "pause"
|
|
|
|
MenuInit(menu_type)
|
2022-01-18 19:45:57 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-01-21 14:56:25 +00:00
|
|
|
--MenuStep
|
2022-02-03 04:31:25 +00:00
|
|
|
if menu_type ~= nil then MenuStep(menu_type) end
|
2022-01-21 14:56:25 +00:00
|
|
|
|
2022-01-19 12:28:09 +00:00
|
|
|
--editor
|
|
|
|
if editor_mode then
|
2022-01-19 15:13:13 +00:00
|
|
|
EditorStep()
|
2022-01-19 12:28:09 +00:00
|
|
|
else
|
2022-01-19 15:13:13 +00:00
|
|
|
GameStep()
|
2022-01-19 12:28:09 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function love.wheelmoved(_, y)
|
|
|
|
if editor_mode then
|
2022-01-19 20:57:45 +00:00
|
|
|
EditorScroll(y)
|
2022-01-19 12:28:09 +00:00
|
|
|
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
|
2022-01-19 15:13:13 +00:00
|
|
|
EditorDraw()
|
2022-01-18 19:45:57 +00:00
|
|
|
else
|
2022-01-19 15:13:13 +00:00
|
|
|
GameDraw()
|
2022-01-18 19:45:57 +00:00
|
|
|
end
|
2022-01-21 14:56:25 +00:00
|
|
|
|
2022-02-03 04:31:25 +00:00
|
|
|
if menu_type ~= nil then MenuDraw(menu_type) end
|
2022-01-21 14:56:25 +00:00
|
|
|
|
2022-01-31 06:38:15 +00:00
|
|
|
love.graphics.print(game.scale,10,40)
|
2022-01-18 19:45:57 +00:00
|
|
|
end
|