Start implementing a menu system, fix game save/load.
This commit is contained in:
parent
109283a383
commit
ea8b0360bc
|
@ -3,6 +3,7 @@ version 18
|
|||
__lua__
|
||||
#include debug.lua
|
||||
#include sound.lua
|
||||
#include menu.lua
|
||||
#include world.lua
|
||||
#include player.lua
|
||||
#include savegame.lua
|
||||
|
|
19
main.lua
19
main.lua
|
@ -1,25 +1,34 @@
|
|||
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
|
||||
init_savegame""
|
||||
init_menu""
|
||||
init_sound""
|
||||
init_world""
|
||||
init_player""
|
||||
init_debug""
|
||||
|
||||
load_game""
|
||||
|
||||
end
|
||||
|
||||
|
||||
function _update()
|
||||
handle_input""
|
||||
if menu_mode then
|
||||
menu_input""
|
||||
else
|
||||
player_input""
|
||||
end
|
||||
end
|
||||
|
||||
function _draw()
|
||||
cls""
|
||||
draw_world(player_x, player_y)
|
||||
draw_player""
|
||||
if (menu_mode) then
|
||||
draw_menu""
|
||||
else
|
||||
draw_world(player_x, player_y)
|
||||
draw_player""
|
||||
end
|
||||
debug_print""
|
||||
end
|
||||
|
|
14
menu.lua
Normal file
14
menu.lua
Normal 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
|
|
@ -39,14 +39,18 @@ function init_player()
|
|||
}
|
||||
end
|
||||
|
||||
|
||||
function handle_input()
|
||||
-- NB: references menu_mode from main.lua
|
||||
function player_input()
|
||||
local new_x, new_y = player_x, player_y
|
||||
|
||||
if btnp"4" then
|
||||
interact()
|
||||
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" then
|
||||
new_x -= 1 -- move left
|
||||
|
|
Loading…
Reference in New Issue
Block a user