1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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
|