Smart save/load system, lot of new shortcuts

master
KikooDX 3 years ago
parent ce76188407
commit cc36e64f7e
  1. 47
      keyboard.lua
  2. 4
      load.lua
  3. 2
      main.lua
  4. 20
      save.lua

@ -1,7 +1,41 @@
function update_keyboard()
--get keys inputs
--debug key
if love.keyboard.isDown("d") then debug.debug() end
--change screen
local buffer = k_q
k_q = love.keyboard.isScancodeDown("a")
if k_q and not buffer and screen_id%100 > 0 then
save()
screen_id = screen_id - 1
load()
end
local buffer = k_d
k_d = love.keyboard.isScancodeDown("d")
if k_d and not buffer and screen_id%100 < 99 then
save()
screen_id = screen_id + 1
load()
end
local buffer = k_z
k_z = love.keyboard.isScancodeDown("w")
if k_z and not buffer and screen_id < 9900 then
save()
screen_id = screen_id + 100
load()
end
local buffer = k_s
k_s = love.keyboard.isScancodeDown("s")
if k_s and not buffer and screen_id > 100 then
save()
screen_id = screen_id - 100
load()
end
local buffer = k_i
k_i = love.keyboard.isScancodeDown("i")
if k_i and not buffer then
save()
screen_id = 5050
load()
end
--swap selected object
local buffer = k_tab
k_tab = love.keyboard.isScancodeDown("tab")
@ -18,14 +52,15 @@ function update_keyboard()
love.event.quit()
end
--saving/export
local buffer = k_s
k_s = love.keyboard.isDown("s")
if k_s and not buffer then
print(save())
local buffer = k_c
k_c = love.keyboard.isDown("c")
if k_c and not buffer then
save()
end
local buffer = k_o
k_o = love.keyboard.isDown("o")
if k_o and not buffer then
load()
end
--scaling
local buffer = k_k

@ -1,8 +1,10 @@
--scaling settings
love.graphics.setDefaultFilter("nearest", "nearest")
selected_screen = "000000000000000000000000000000000000000000000000000000......................0000......................0000......................0000......................0000......................0000......................0000......................0000......................0000......................0000......................0000......................000000000000000000000000000000000000000000000000000000"
default_screen = "000000000000000000000000000000000000000000000000000000......................0000......................0000......................0000......................0000......................0000......................0000......................0000......................0000......................0000......................0000......................000000000000000000000000000000000000000000000000000000"
SCREEN_LEN = 390
screen_id = 5050
load()
path = "../platformer/"
--font

@ -1,9 +1,9 @@
function love.load()
require("save")
require("load")
require("update")
require("draw")
require("mouse")
require("keyboard")
require("tiles")
require("save")
end

@ -1,13 +1,19 @@
function save()
output = "\n-"
for i = 1, 28, 1 do output = "-"..output end
for i = 1, #selected_screen, 1 do
output = output..selected_screen:sub(i, i)
if i % 26 == 0 then output = output.."-\n-" end
if selected_screen ~= default_screen then
file = io.open("screens/"..screen_id..".scr", "w")
file:write(selected_screen)
file:close()
print("save "..screen_id)
end
for i = 1, 26, 1 do output = output.."-" end
return output
end
function load()
file = io.open("screens/"..screen_id..".scr", "r")
if file then
selected_screen = file:read()
file:close()
else
selected_screen = default_screen
end
print("load "..screen_id)
end

Loading…
Cancel
Save