Add more explicit control around save/load. This still seems to only work sporadically though.

This commit is contained in:
Anna Rose 2019-12-11 15:27:50 -05:00
parent 06879ee1ad
commit 77f3d49ba9
5 changed files with 28 additions and 4 deletions

View File

@ -5,6 +5,7 @@ __lua__
#include sound.lua
#include world.lua
#include player.lua
#include savegame.lua
#include main.lua
__gfx__
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008800000000000000000000000000000

View File

@ -1,3 +1,8 @@
### 'permanent' color palette modifications
---
11 -> 139
### sprites
---
### map tiles

View File

@ -1,10 +1,15 @@
function _init()
cartdata("annabunches_a_pleasant_stroll_e25d3e5c")
pal(11, 139, 1)
-- module inits
init_savegame""
init_sound""
init_world""
init_player""
init_debug""
load_game""
end

View File

@ -14,7 +14,7 @@
-- draw_player() # call in _draw(). Draws the player sprite.
function init_player()
player_x, player_y = dget(0), dget(1)
player_x, player_y = 0, 0
facing_v = 1
facing_h = 0
@ -76,8 +76,6 @@ function handle_input()
-- note that facing always changes, even if we can't move to the new location
if legal_move(new_x, new_y) then
player_x, player_y = new_x, new_y
dset(0, player_x)
dset(1, player_y)
end
end

15
savegame.lua Normal file
View File

@ -0,0 +1,15 @@
-- functions to save and restore cartdata
function init_savegame()
cartdata"annabunches_a_pleasant_stroll_e25d3e5c"
end
function load_game()
player_x = dget(0)
player_y = dget(1)
end
function save_game()
dset(0, player_x)
dset(1, player_y)
end