changed menu navigation
This commit is contained in:
parent
9b890c6bd2
commit
033718351e
7 changed files with 248 additions and 33 deletions
66
gmtk_2024/scripts/level_completed_control.gd
Normal file
66
gmtk_2024/scripts/level_completed_control.gd
Normal file
|
@ -0,0 +1,66 @@
|
|||
extends Control
|
||||
|
||||
var credits_text = """
|
||||
CONGRATULATIONS
|
||||
THIS SECTOR IS NOW INFECTED
|
||||
YOU NOW HAVE ACCESS TO THE NEXT SECTION
|
||||
|
||||
"""
|
||||
|
||||
var current_text = ""
|
||||
var char_index = 0
|
||||
var typing_speed = 0.05 # Normale Tippgeschwindigkeit
|
||||
var fast_typing_speed = 0.01 # Schnellere Tippgeschwindigkeit
|
||||
var is_fast_typing = false # Statusvariable für schnelleres Tippen
|
||||
|
||||
# Zum Überprüfen eines Doppelklicks
|
||||
var last_click_time = 0.0
|
||||
var double_click_time = 0.3 # Zeitfenster für Doppelklick in Sekunden
|
||||
|
||||
func _ready():
|
||||
_start_typing()
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
# Überprüfe, ob eine Taste oder Maustaste gedrückt gehalten wird
|
||||
if Input.is_action_pressed("ui_accept") or Input.is_action_pressed("ui_accept"):
|
||||
if get_time_since_last_click() <= double_click_time:
|
||||
_show_full_text()
|
||||
else:
|
||||
is_fast_typing = true
|
||||
else:
|
||||
is_fast_typing = false
|
||||
|
||||
typing_speed = fast_typing_speed if is_fast_typing else 0.05
|
||||
|
||||
func _start_typing() -> void:
|
||||
current_text = ""
|
||||
char_index = 0
|
||||
_update_text()
|
||||
|
||||
func _update_text() -> void:
|
||||
if char_index < credits_text.length():
|
||||
current_text += credits_text[char_index]
|
||||
$VBoxContainer/Label.text = current_text
|
||||
char_index += 1
|
||||
await get_tree().create_timer(typing_speed).timeout
|
||||
_update_text()
|
||||
else:
|
||||
_show_menu_options()
|
||||
|
||||
func _show_menu_options() -> void:
|
||||
$VBoxContainer/BackToMenu.visible = true
|
||||
|
||||
func _return_to_main_menu() -> void:
|
||||
get_tree().change_scene_to_file("res://menu/level_menu/level_select.tscn")
|
||||
|
||||
func _show_full_text() -> void:
|
||||
current_text = credits_text
|
||||
$VBoxContainer/Label.text = current_text
|
||||
char_index = credits_text.length()
|
||||
_show_menu_options()
|
||||
|
||||
func get_time_since_last_click() -> float:
|
||||
var current_time = Time.get_ticks_msec() / 1000.0 # Zeit in Sekunden
|
||||
var time_since_last_click = current_time - last_click_time
|
||||
last_click_time = current_time
|
||||
return time_since_last_click
|
|
@ -1,6 +1,7 @@
|
|||
extends Control
|
||||
|
||||
func _ready():
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
setup_level_box()
|
||||
connect_level_selected_to_level_box()
|
||||
|
||||
|
|
|
@ -1,38 +1,72 @@
|
|||
extends Control
|
||||
|
||||
var credits_text = """
|
||||
SECTOR COMPLETED
|
||||
CREDITS:
|
||||
-----------
|
||||
Programming: Jannis, Fabio
|
||||
Pixel Art : Leon
|
||||
Music: TBN
|
||||
|
||||
"""
|
||||
|
||||
var current_text = ""
|
||||
var char_index = 0
|
||||
var typing_speed = 0.05 # Normale Tippgeschwindigkeit
|
||||
var fast_typing_speed = 0.01 # Schnellere Tippgeschwindigkeit
|
||||
var is_fast_typing = false # Statusvariable für schnelleres Tippen
|
||||
|
||||
# Zum Überprüfen eines Doppelklicks
|
||||
var typing_speed = 0.05
|
||||
var fast_typing_speed = 0.0001
|
||||
var last_click_time = 0.0
|
||||
var double_click_time = 0.3 # Zeitfenster für Doppelklick in Sekunden
|
||||
var double_click_time = 0.3
|
||||
var is_typing = true
|
||||
var current_button_index = 0
|
||||
var button
|
||||
|
||||
func _ready():
|
||||
_initialize_menu()
|
||||
_start_typing()
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
# Überprüfe, ob eine Taste oder Maustaste gedrückt gehalten wird
|
||||
if Input.is_action_pressed("ui_accept") or Input.is_action_pressed("ui_accept"):
|
||||
if get_time_since_last_click() <= double_click_time:
|
||||
_show_full_text()
|
||||
else:
|
||||
is_fast_typing = true
|
||||
else:
|
||||
is_fast_typing = false
|
||||
func _initialize_menu():
|
||||
button = $VBoxContainer/BackToMenu
|
||||
_update_button_visibility()
|
||||
_blink_current_button()
|
||||
|
||||
typing_speed = fast_typing_speed if is_fast_typing else 0.05
|
||||
func _update_button_visibility():
|
||||
var hbox_container = button
|
||||
var label_node = hbox_container.get_child(0)
|
||||
if label_node != null:
|
||||
label_node.visible
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if not is_typing:
|
||||
if Input.is_action_pressed("ui_accept"):
|
||||
typing_speed = fast_typing_speed
|
||||
|
||||
func _blink_current_button() -> void:
|
||||
while true:
|
||||
var hbox_container = button
|
||||
var label_node = hbox_container.get_child(0)
|
||||
if label_node != null:
|
||||
label_node.visible = true
|
||||
await get_tree().create_timer(0.5).timeout
|
||||
if label_node != null:
|
||||
label_node.visible = false
|
||||
await get_tree().create_timer(0.5).timeout
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if is_typing:
|
||||
if event is InputEventKey and event.is_pressed():
|
||||
if get_time_since_last_click() <= double_click_time:
|
||||
_show_full_text()
|
||||
else:
|
||||
typing_speed = fast_typing_speed
|
||||
elif event is InputEventKey and not event.is_pressed():
|
||||
typing_speed = 0.05
|
||||
else:
|
||||
if event.is_action_pressed("ui_accept"):
|
||||
button.get_child(1).emit_signal("pressed")
|
||||
|
||||
func _start_typing() -> void:
|
||||
current_text = ""
|
||||
char_index = 0
|
||||
is_typing = true
|
||||
_update_text()
|
||||
|
||||
func _update_text() -> void:
|
||||
|
@ -43,18 +77,20 @@ func _update_text() -> void:
|
|||
await get_tree().create_timer(typing_speed).timeout
|
||||
_update_text()
|
||||
else:
|
||||
is_typing = false
|
||||
_show_menu_options()
|
||||
|
||||
func _show_menu_options() -> void:
|
||||
$VBoxContainer/BackToMenu.visible = true
|
||||
|
||||
func _return_to_main_menu() -> void:
|
||||
get_tree().change_scene_to_file("res://menu/level_menu/level_select.tscn")
|
||||
get_tree().change_scene_to_file("res://menu/main_menu/MainMenu.tscn")
|
||||
|
||||
func _show_full_text() -> void:
|
||||
current_text = credits_text
|
||||
$VBoxContainer/Label.text = current_text
|
||||
char_index = credits_text.length()
|
||||
is_typing = false
|
||||
_show_menu_options()
|
||||
|
||||
func get_time_since_last_click() -> float:
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
extends Control
|
||||
|
||||
var display_text = """
|
||||
SYSTEM INITIALIZATION...
|
||||
STARTING Infiltrate.exe ...
|
||||
---------------------------------------
|
||||
PLACEHOLDER GAME NAME BOOT SEQUENCE
|
||||
COPYRIGHT PLACEHOLDER
|
||||
MADE FOR GMTK GAME JAM 2024
|
||||
|
||||
>> WARNING:
|
||||
>> RECOMMENDED ACTION:
|
||||
>> SECURITY PROTOCOLS: ACTIVE
|
||||
>> SCANNING FOR THREATS...
|
||||
|
||||
>> WARNING: UNAUTHORIZED ACCESS DETECTED
|
||||
>> INITIALIZING COUNTERMEASURES...
|
||||
|
||||
SYSTEM READY.
|
||||
PRESS START TO GET ACCESS.
|
||||
|
||||
"""
|
||||
|
@ -21,26 +21,71 @@ var typing_speed = 0.05
|
|||
var fast_typing_speed = 0.0001
|
||||
var last_click_time = 0.0
|
||||
var double_click_time = 0.3
|
||||
var is_typing = true
|
||||
var current_button_index = 0
|
||||
var buttons = []
|
||||
|
||||
func _ready():
|
||||
for hbox in $VBoxContainer/Buttons.get_children():
|
||||
hbox.visible = false
|
||||
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
|
||||
_initialize_menu()
|
||||
_start_typing()
|
||||
|
||||
func _initialize_menu():
|
||||
buttons = $VBoxContainer/Buttons.get_children()
|
||||
_update_button_visibility()
|
||||
_blink_current_button()
|
||||
|
||||
func _update_button_visibility():
|
||||
for i in range(len(buttons)):
|
||||
var hbox_container = buttons[i]
|
||||
var label_node = hbox_container.get_child(0)
|
||||
if label_node != null:
|
||||
label_node.visible = (i == current_button_index)
|
||||
|
||||
func _blink_current_button() -> void:
|
||||
while true:
|
||||
var hbox_container = buttons[current_button_index]
|
||||
var label_node = hbox_container.get_child(0)
|
||||
if label_node != null:
|
||||
label_node.visible = true
|
||||
await get_tree().create_timer(0.5).timeout
|
||||
if label_node != null:
|
||||
label_node.visible = false
|
||||
await get_tree().create_timer(0.5).timeout
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("ui_accept") or event is InputEventMouseButton:
|
||||
if get_time_since_last_click() <= double_click_time:
|
||||
_show_full_text()
|
||||
else:
|
||||
typing_speed = fast_typing_speed
|
||||
if is_typing:
|
||||
if event is InputEventKey and event.is_pressed():
|
||||
if get_time_since_last_click() <= double_click_time:
|
||||
_show_full_text()
|
||||
else:
|
||||
typing_speed = fast_typing_speed
|
||||
elif event is InputEventKey and not event.is_pressed():
|
||||
typing_speed = 0.05
|
||||
else:
|
||||
if event.is_action_pressed("ui_down") or event.is_action_pressed("down"):
|
||||
current_button_index = (current_button_index + 1) % buttons.size()
|
||||
_update_button_visibility()
|
||||
elif event.is_action_pressed("ui_up") or event.is_action_pressed("up"):
|
||||
current_button_index = (current_button_index - 1 + buttons.size()) % buttons.size()
|
||||
_update_button_visibility()
|
||||
elif event.is_action_pressed("ui_accept"):
|
||||
buttons[current_button_index].get_child(1).emit_signal("pressed")
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
typing_speed = 0.05 # Zurück zur normalen Geschwindigkeit
|
||||
if not is_typing:
|
||||
if Input.is_action_pressed("ui_accept"):
|
||||
typing_speed = fast_typing_speed
|
||||
|
||||
func _start_typing() -> void:
|
||||
current_text = ""
|
||||
char_index = 0
|
||||
is_typing = true
|
||||
_update_text()
|
||||
|
||||
func _update_text() -> void:
|
||||
|
@ -51,6 +96,7 @@ func _update_text() -> void:
|
|||
await get_tree().create_timer(typing_speed).timeout
|
||||
_update_text()
|
||||
else:
|
||||
is_typing = false
|
||||
_show_menu_options()
|
||||
|
||||
func _show_menu_options() -> void:
|
||||
|
@ -61,6 +107,7 @@ func _show_full_text() -> void:
|
|||
current_text = display_text
|
||||
$VBoxContainer/VBoxContainer2/Label.text = current_text
|
||||
char_index = display_text.length()
|
||||
is_typing = false
|
||||
_show_menu_options()
|
||||
|
||||
func get_time_since_last_click() -> float:
|
||||
|
@ -76,6 +123,6 @@ func _on_credits_button_pressed() -> void:
|
|||
get_tree().change_scene_to_file("res://menu/main_menu/CreditsScene.tscn")
|
||||
|
||||
func _on_quit_button_pressed() -> void:
|
||||
$VBoxContainer/VBoxContainer2/Label.text += "\nLogging out!"
|
||||
$VBoxContainer/VBoxContainer2/Label.text += "Logging out!"
|
||||
await get_tree().create_timer(0.5).timeout
|
||||
get_tree().quit()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue