love:mike moved function into it's own library; moved libs to lib folder
This commit is contained in:
52
love/mike/lib/keys.lua
Normal file
52
love/mike/lib/keys.lua
Normal file
@@ -0,0 +1,52 @@
|
||||
require "lib/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
|
||||
|
||||
Reference in New Issue
Block a user