diff options
| author | Alexander M Pickering <alex@cogarr.net> | 2024-01-29 16:20:10 -0600 |
|---|---|---|
| committer | Alexander M Pickering <alex@cogarr.net> | 2024-01-29 16:20:10 -0600 |
| commit | c2926c5ec74d7e37da395c8c32a7ff2b4cae7d06 (patch) | |
| tree | ac2bb208dab1274cdc5e9059ffe014ae19181a4c /src/create_party_menu.moon | |
| download | fools_rush_in-c2926c5ec74d7e37da395c8c32a7ff2b4cae7d06.tar.gz fools_rush_in-c2926c5ec74d7e37da395c8c32a7ff2b4cae7d06.tar.bz2 fools_rush_in-c2926c5ec74d7e37da395c8c32a7ff2b4cae7d06.zip | |
All the files
Diffstat (limited to 'src/create_party_menu.moon')
| -rw-r--r-- | src/create_party_menu.moon | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/src/create_party_menu.moon b/src/create_party_menu.moon new file mode 100644 index 0000000..b31c9d5 --- /dev/null +++ b/src/create_party_menu.moon @@ -0,0 +1,103 @@ +main = require "main" +world = require "world" +color = require "color" +ui = require "ui" +bp = require "broadphase" +action = require "action" +char = require "char" +player = require "player" +room = require "room" +import World from world +import Server from world +import LocalPlayer from player +import LobbyRoom from room + +mod = ... + +mod.node = am.group! +mod.node\append(am.translate(0,main.height/2)^ am.text("Creating lobby...", color.fg, "center","top")\tag("join_id")) +mod.loaded = false +mod.load = () -> + mod.loaded = true + print("Loading create party") + main.root("screen")\append(mod.node) + print("About to create server") + main["server"] = Server! + print("Created server") + mod.node("join_id").text = "Lobby id:" .. main.server.lobby_id + print("Set join id text") + main["world"] = World! + main.world\set_room(LobbyRoom!) + print("Created world") + main.world\join(main.server.lobby_id) + print("Joined my own lobby") + start_button = ui.create_any_button(mod.node,5,2,(-32*5)/2,0) + start_button.node("loc")\append(am.scale(1.5)^ am.translate(12,-10)^ am.text("GET SILLY", color.fg, "left", "top")) + char_selector = ui.create_char_selector2(mod.node) + char_right, char_left, char_text = char_selector[1], char_selector[2], char_selector[3] + mod.buttons = {char_left, char_right, start_button} --save to remove from the physworld later + classes = char.class_order + class_s = 1 + print("got char selector:",char_selector) + 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) + --Set everything transparent, give it color when we're connected + start_button.color = color.transparent + char_right.color = color.transparent + char_left.color = color.transparent + mod.node\action("click_interpreter",coroutine.create(()-> + while not main.world.client_open! + coroutine.yield! + char_left.color = color.white + char_right.color = color.white + char_text.text = "Tumbler" + main.world\set_local(LocalPlayer(am.eval_js("CLIENT.peer._id"),{},char.classes.Tumbler)) + main.world\load! + while true + 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 and main.win\touch_began(1) + if col_but[1] == start_button + print("Starting!") + action.start_game! + coroutine.yield! + if col_but[1] == char_left + print("char left") + class_s = class_s - 1 + start_button.color = color.white + if class_s == 0 + class_s = #classes + if col_but[1] == char_right + print("char right") + class_s = class_s + 1 + start_button.color = color.white + if class_s > #classes + class_s = 1 + if col_but[1] == char_left or col_but[1] == char_right + print("class_s",class_s) + print("classes:", classes) + char_text.text = classes[class_s] + action.request_class_change(classes[class_s]) + + else + touch_cursor.color = vec4(0,0,0,0) + coroutine.yield! + )) + mod.node\append(touch_indicator) + +mod.unload = () -> + print("Unloading create party") + main.root("screen")\remove(mod.node) + for _, button in pairs(mod.buttons) + bp.remove(button) + mod.loaded = false + +mod |
