diff options
Diffstat (limited to 'src/main_menu.moon')
| -rw-r--r-- | src/main_menu.moon | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/main_menu.moon b/src/main_menu.moon new file mode 100644 index 0000000..fee6fb5 --- /dev/null +++ b/src/main_menu.moon @@ -0,0 +1,81 @@ + +main = require "main" +bp = require "broadphase" +color = require "color" +ui = require "ui" + +world = require "world" --delete when done +import Server from world +import World from world +mod = ... + +-- 4 parts? +nwidth = 6 +section_width = 32 +start_x = (-32)*(nwidth/2) +mod.node = am.group! +mod.node\append(am.sprite("data/main_bg.png")) +start_y = 0 +padding = 32 +buttonspecs = { + create_party: { + y_off: start_y, + text: "Create Troupe" + }, + join_party: { + y_off: start_y + 64 + padding, + text: "Join Troupe" + } +} + + +mod.load = () -> + print("creating main menu") + main.root("screen")\append(mod.node) + for name, button_tbl in pairs buttonspecs + button_extra = ui.create_big_button(mod.node,6,start_x,button_tbl.y_off) + button_extra.node\append(am.translate(start_x+((nwidth*section_width)/2),button_tbl.y_off - 32)^ am.text(button_tbl.text,color.fg)) + mod[name] = button_extra + touch_indicator = am.group! + touch_cursor = am.sprite("data/cursor.png",vec4(1,1,1,1),"left","top") + touch_loc = am.translate(0,0)^ touch_cursor + touch_indicator\append(touch_loc) + mod.node\append(am.translate(0,-150)^ am.scale(3)^ am.text("Fools Rush In")) + mod.node\action("click_interpreter",coroutine.create(()-> + while true + print("Main menu loop") + if #main.win\active_touches! > 0 + touch = main.win\touch_position(1) + touch_cursor.color = vec4(1,1,1,1) + touch_loc.x = touch.x + touch_loc.y = touch.y + col_but = bp.check(touch.x, touch.y+64) + if #col_but > 0 + touch_cursor.color = vec4(0.5,0.5,0.5,0.5) + if #col_but > 0 + print("Collided with button:",col_but) + print("mod.create prty was:",mod.create_party) + if col_but[1] == mod.create_party + print("Creating party") + create_party = require "create_party_menu" + table.insert(main.action_queue,{create_party.load, {}}) + mod.unload! + coroutine.yield! + elseif col_but[1] == mod.join_party + print("Joining party") + join_party = require "join_party_menu" + table.insert(main.action_queue,{join_party.load, {}}) + mod.unload! + coroutine.yield! + else + touch_cursor.color = vec4(0,0,0,0) + coroutine.yield! + )) + mod.node\append(touch_indicator) + +mod.unload = () -> + main.root("screen")\remove(mod.node) + bp.remove(mod.create_party) + bp.remove(mod.join_party) + +mod |
