53 lines
1.1 KiB
Lua

require "Tserial"
function love.keyreleased(key)
if key == "q" then
love.event.quit()
-- save
elseif key == "s" then
love.filesystem.write(saveFile, Tserial.pack(player, false, true))
-- Load
elseif key == "l" then
save_exists = love.filesystem.exists(saveFile)
if save_exists then
player = Tserial.unpack( love.filesystem.read( saveFile ) )
end
end
end
function check_keys(object)
local newObject = {}
newObject.x = object.x
newObject.y = object.y
newObject.width = object.width
newObject.height = object.height
newObject.speed = object.speed
if love.keyboard.isDown("right") then
newObject.x = newObject.x + newObject.speed
end
if love.keyboard.isDown("left") then
newObject.x = newObject.x - newObject.speed
end
-- if love.keyboard.isDown("up") then
-- newObject.y = newObject.y - newObject.speed
-- end
-- if love.keyboard.isDown("down") then
-- newObject.y = newObject.y + newObject.speed
-- end
if col_detect(newObject, screen) then
return newObject
else
return object
end
end