-
Notifications
You must be signed in to change notification settings - Fork 0
/
title.gd
128 lines (115 loc) · 3.13 KB
/
title.gd
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
extends Control
const PREMENU = 0
const MENU = 1
const NETWORK = 2
const CREDITS = 3
var status = PREMENU
var menu = [ "menu", "1player", "2players", "network", "credits" ]
var network = [ "network", "server", "client", "back" ]
var credits = [ "credits", "back" ]
var selector = 1
var selector_tank
var selector_anim
var global = null
func _ready():
set_process_input(true)
selector_tank = get_node("selector")
selector_anim = selector_tank.get_node("Sprite/anim")
global = get_node("/root/global")
global.reset()
thegreat_play()
func thegreat_play():
var letters = [ "t", "h", "e", "g", "r", "e2", "a", "t2" ]
for letter in letters:
get_node("thegreat/" + letter + "/anim").play("enter")
func action_menu(action):
var thismenu = menu
if status == NETWORK:
thismenu = network
elif status == CREDITS:
thismenu = credits
if action == "down":
if selector == thismenu.size()-1:
selector = 1
else:
selector += 1
elif (action == "up"):
if selector == 1:
selector = thismenu.size()-1
else:
selector -= 1
elif action == "select":
selector_anim.play("selected")
selector_anim.queue("enter")
selector = 1
else:
print("BUG: menu action not implemented")
var itempos = get_node(thismenu[0] + "/" + thismenu[selector]).get_pos()
selector_tank.set_pos(Vector2(itempos.x - 30, itempos.y))
func _input(ev):
if ev.is_pressed():
if ev.is_action("ui_cancel"):
get_scene().quit()
if status == PREMENU:
if ev.is_action("ui_accept"):
get_node("enter").hide()
get_node("menu").show()
selector_tank.show()
selector_anim.play("enter")
status = MENU
elif status == MENU:
if ev.is_action("ui_down"):
action_menu("down")
elif ev.is_action("ui_up"):
action_menu("up")
elif ev.is_action("ui_accept"):
#1 player selected
if selector == 1:
global.status = global.SELECT1P
global.goto_scene("res://select_color.xml")
#2 players selected
elif selector == 2:
global.status = global.SELECT2P
global.goto_scene("res://select_color.xml")
#network selected
elif selector == 3:
get_node("menu").hide()
get_node("network").show()
status = NETWORK
#credits selected
elif selector == 4:
get_node("menu").hide()
get_node("credits").show()
status = CREDITS
action_menu("select")
elif status == NETWORK:
if ev.is_action("ui_down"):
action_menu("down")
elif ev.is_action("ui_up"):
action_menu("up")
elif ev.is_action("ui_accept"):
#server selected
if selector == 1:
global.create_server()
global.status = global.SERVER
global.goto_scene("res://network.xml")
#client selected
elif selector == 2:
global.connect_to_server()
global.status = global.CLIENT
global.goto_scene("res://network.xml")
#back selected
elif selector == 3:
action_menu("select")
get_node("network").hide()
get_node("menu").show()
status = MENU
action_menu("select")
elif status == CREDITS:
if ev.is_action("ui_accept"):
get_node("credits").hide()
get_node("menu").show()
status = MENU
action_menu("select")
else:
print("BUG: tittle status not registered yet")