Start implementing a menu system, fix game save/load.

This commit is contained in:
Anna Rose 2019-12-11 18:43:11 -05:00
parent 109283a383
commit ea8b0360bc
4 changed files with 35 additions and 7 deletions

View File

@ -3,6 +3,7 @@ version 18
__lua__ __lua__
#include debug.lua #include debug.lua
#include sound.lua #include sound.lua
#include menu.lua
#include world.lua #include world.lua
#include player.lua #include player.lua
#include savegame.lua #include savegame.lua

View File

@ -1,25 +1,34 @@
function _init() function _init()
pal(11, 139, 1) pal(11, 139, 1) -- tone down the bright green
menu_mode = false -- global used for menu control
-- module inits -- module inits
init_savegame"" init_savegame""
init_menu""
init_sound"" init_sound""
init_world"" init_world""
init_player"" init_player""
init_debug"" init_debug""
load_game"" load_game""
end end
function _update() function _update()
handle_input"" if menu_mode then
menu_input""
else
player_input""
end
end end
function _draw() function _draw()
cls"" cls""
if (menu_mode) then
draw_menu""
else
draw_world(player_x, player_y) draw_world(player_x, player_y)
draw_player"" draw_player""
end
debug_print"" debug_print""
end end

14
menu.lua Normal file
View File

@ -0,0 +1,14 @@
function init_menu()
-- add pause menu items first
menuitem(1, "save game", save_game)
menuitem(2, "erase save data", clear_save)
end
function menu_input()
-- todo: implement an actual menu
menu_mode = false
end
function draw_menu()
end

View File

@ -39,14 +39,18 @@ function init_player()
} }
end end
-- NB: references menu_mode from main.lua
function handle_input() function player_input()
local new_x, new_y = player_x, player_y local new_x, new_y = player_x, player_y
if btnp"4" then if btnp"4" then
interact() interact()
end end
if btnp"5" then
menu_mode = true -- pass control to menu
end
if btnp"0" or btnp"1" or btnp"2" or btnp"3" then if btnp"0" or btnp"1" or btnp"2" or btnp"3" then
if btnp"0" then if btnp"0" then
new_x -= 1 -- move left new_x -= 1 -- move left