require "lib/GameState" QUIT_KEY = "q" SAVE_KEY = "s" LOAD_KEY = "l" HALF_SPEED = "lshift" MOVE_RIGHT = "right" MOVE_LEFT = "left" SAVE_FILE = "testing.lua" function love.keyreleased(key) -- save if key == SAVE_KEY then love.filesystem.write(SAVE_FILE, GameState.save(actors, "actors")) -- Load elseif key == LOAD_KEY then save_exists = love.filesystem.exists(SAVE_FILE) if save_exists then actors = GameState.load(SAVE_FILE) -- Tell the timer to ignore time passed between the save and the load actors.start = love.timer.getTime() - actors.end_timer end end end function half_speed(object_speed) if love.keyboard.isDown(HALF_SPEED) then return object_speed/2 else return object_speed end end function check_keys(object, screen, dt) 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(QUIT_KEY) then love.timer.sleep( 1 ) gamestate.draw = Gamestates.title_draw gamestate.update = Gamestates.title_update end if love.keyboard.isDown(MOVE_RIGHT) then newObject.x = newObject.x + half_speed(newObject.speed * dt) end if love.keyboard.isDown(MOVE_LEFT) then newObject.x = newObject.x - half_speed(newObject.speed * dt) end if screen_col_detect(newObject, screen) then return newObject else return object end end