More menu work. Begin implementing an inventory system.

This commit is contained in:
Anna Rose 2019-12-15 01:01:19 -05:00
parent c86589ec6a
commit fdaefc4e72
2 changed files with 59 additions and 1 deletions

View File

@ -2,12 +2,52 @@ function init_menu()
-- add pause menu items first
menuitem(1, "save game", save_game)
menuitem(2, "erase save data", clear_save)
menu_cursor = 0
menu_map = {
[0] = nil,
[1] = nil,
[2] = save_game
}
end
function menu_input()
menu_mode = false -- todo: implement an actual menu
if btnp(5) then
menu_mode = false
end
-- todo: implement an actual menu control
end
function draw_menu()
menu_draw_inventory()
menu_draw_options()
end
function menu_draw_inventory()
rectfill(0,0,64,64,1)
rect(0,0,64,64,5)
local inv_cursor = 0
for k,v in pairs(inventory) do
if v > 0 then
spr(k, 8, 8+inv_cursor*8)
print(v, 18, 8+inv_cursor*8, 15)
end
end
end
function menu_draw_options()
rectfill(80, 0, 127, 64, 1)
rect(80, 0, 127, 64, 5)
cursor(96, 8)
color(15)
print("eat")
print("build")
print("save")
-- cursor
print("->", 84, 8+menu_cursor*6)
end

View File

@ -19,6 +19,24 @@ function init_player()
facing_v = 1
facing_h = 0
-- constants for item IDs. Doubles as sprite indices.
item_mushroom = 64
item_cactus_meat = 65
item_wood = 66
item_cactus_flower = 80
item_berries = 81
item_cactus_meal = 66
-- inventory is a map of item ids to counts
inventory = {
item_mushroom = 0,
item_cactus_meat = 0,
item_wood = 0,
item_cactus_flower = 0,
item_berries = 0,
item_cactus_meal = 0
}
-- this is a constant for looking up player sprites by facing
player_lookup = {
[0] = {