diff --git a/a_pleasant_stroll.p8 b/a_pleasant_stroll.p8 index 1e98444..71af377 100644 --- a/a_pleasant_stroll.p8 +++ b/a_pleasant_stroll.p8 @@ -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 diff --git a/main.lua b/main.lua index 078e530..813ecad 100644 --- a/main.lua +++ b/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 diff --git a/menu.lua b/menu.lua new file mode 100644 index 0000000..f9f5864 --- /dev/null +++ b/menu.lua @@ -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 diff --git a/player.lua b/player.lua index f8291b0..6a1a02e 100644 --- a/player.lua +++ b/player.lua @@ -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