Compare commits

...

2 commits

5 changed files with 105 additions and 27 deletions

View file

@ -0,0 +1,49 @@
[gd_scene load_steps=5 format=3 uid="uid://n2culjgg5aji"]
[ext_resource type="Theme" uid="uid://cohbys634cf18" path="res://menu/main_menu/MainMenuTheme.tres" id="1_tm23e"]
[ext_resource type="PackedScene" uid="uid://dii1q3f5dj72y" path="res://objects/CRT.tscn" id="2_d3r0j"]
[ext_resource type="Script" path="res://scripts/level_completed_control.gd" id="3_38v2l"]
[ext_resource type="FontFile" uid="uid://d3pbvdemdbxes" path="res://CommodoreSixtyFour.ttf" id="4_8fqei"]
[node name="LevelComplete" type="MarginContainer"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_tm23e")
[node name="CanvasLayer" parent="." instance=ExtResource("2_d3r0j")]
[node name="ColorRect" type="ColorRect" parent="."]
layout_mode = 2
color = Color(0, 0, 0, 1)
[node name="Control" type="Control" parent="."]
layout_mode = 2
script = ExtResource("3_38v2l")
[node name="VBoxContainer" type="VBoxContainer" parent="Control"]
layout_mode = 0
offset_right = 40.0
offset_bottom = 40.0
[node name="Label" type="Label" parent="Control/VBoxContainer"]
layout_mode = 2
[node name="BackToMenu" type="HBoxContainer" parent="Control/VBoxContainer"]
visible = false
layout_mode = 2
[node name="Label" type="Label" parent="Control/VBoxContainer/BackToMenu"]
custom_minimum_size = Vector2(8, 0)
layout_mode = 2
theme_override_fonts/font = ExtResource("4_8fqei")
text = ">"
[node name="back" type="Button" parent="Control/VBoxContainer/BackToMenu"]
layout_mode = 2
text = "back to level menu"
flat = true
[connection signal="pressed" from="Control/VBoxContainer/BackToMenu/back" to="Control" method="_return_to_main_menu"]

View file

@ -38,7 +38,8 @@ player_left={
} }
player_jump={ player_jump={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
] ]
} }
click={ click={

View file

@ -9,32 +9,62 @@ YOU NOW HAVE ACCESS TO THE NEXT SECTION
var current_text = "" var current_text = ""
var char_index = 0 var char_index = 0
var typing_speed = 0.05 # Normale Tippgeschwindigkeit var typing_speed = 0.05
var fast_typing_speed = 0.01 # Schnellere Tippgeschwindigkeit var fast_typing_speed = 0.0001
var is_fast_typing = false # Statusvariable für schnelleres Tippen
# Zum Überprüfen eines Doppelklicks
var last_click_time = 0.0 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(): func _ready():
_initialize_menu()
_start_typing() _start_typing()
func _process(_delta: float) -> void: func _initialize_menu():
# Überprüfe, ob eine Taste oder Maustaste gedrückt gehalten wird button = $VBoxContainer/BackToMenu
if Input.is_action_pressed("ui_accept") or Input.is_action_pressed("ui_accept"): _update_button_visibility()
if get_time_since_last_click() <= double_click_time: _blink_current_button()
_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 _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: func _start_typing() -> void:
current_text = "" current_text = ""
char_index = 0 char_index = 0
is_typing = true
_update_text() _update_text()
func _update_text() -> void: func _update_text() -> void:
@ -45,6 +75,7 @@ func _update_text() -> void:
await get_tree().create_timer(typing_speed).timeout await get_tree().create_timer(typing_speed).timeout
_update_text() _update_text()
else: else:
is_typing = false
_show_menu_options() _show_menu_options()
func _show_menu_options() -> void: func _show_menu_options() -> void:

View file

@ -117,7 +117,7 @@ func get_time_since_last_click() -> float:
return time_since_last_click return time_since_last_click
func _on_start_button_pressed() -> void: func _on_start_button_pressed() -> void:
get_tree().change_scene_to_file("res://menu/level_menu/level_select.tscn") get_tree().change_scene_to_file("res://levels/level_1.tscn")
func _on_level_select_pressed(): func _on_level_select_pressed():
get_tree().change_scene_to_file("res://menu/level_menu/level_select.tscn") get_tree().change_scene_to_file("res://menu/level_menu/level_select.tscn")

View file

@ -24,7 +24,6 @@ var pause_menu_node = null
func _ready(): func _ready():
current_scene = get_tree().current_scene current_scene = get_tree().current_scene
# Referenz auf das übergeordnete Pausenmenü
pause_menu_node = get_parent() pause_menu_node = get_parent()
for hbox in $VBoxContainer/Buttons.get_children(): for hbox in $VBoxContainer/Buttons.get_children():
@ -54,17 +53,15 @@ func _unhandled_input(event: InputEvent) -> void:
typing_speed = fast_typing_speed typing_speed = fast_typing_speed
elif event is InputEventKey and not event.is_pressed(): elif event is InputEventKey and not event.is_pressed():
typing_speed = 0.05 typing_speed = 0.05
else: #else:
if event.is_action_pressed("pause"): #if event.is_action_pressed("pause"):
toggle_pause_menu() #toggle_pause_menu()
# Navigation mit den Pfeiltasten
if event.is_action_pressed("ui_down"): if event.is_action_pressed("ui_down"):
navigate_menu(1) navigate_menu(1)
elif event.is_action_pressed("ui_up"): elif event.is_action_pressed("ui_up"):
navigate_menu(-1) navigate_menu(-1)
# Bestätigen mit der Leertaste oder Enter
if event.is_action_pressed("ui_accept"): if event.is_action_pressed("ui_accept"):
buttons[current_button_index].get_child(1).emit_signal("pressed") buttons[current_button_index].get_child(1).emit_signal("pressed")
@ -92,7 +89,7 @@ func _update_text() -> void:
func _show_menu_options() -> void: func _show_menu_options() -> void:
for hbox in $VBoxContainer/Buttons.get_children(): for hbox in $VBoxContainer/Buttons.get_children():
hbox.visible = true hbox.visible = true
grab_focus() # Menü erhält den Fokus, um Eingaben zu empfangen grab_focus()
func _show_full_text() -> void: func _show_full_text() -> void:
current_text = display_text current_text = display_text
@ -102,7 +99,7 @@ func _show_full_text() -> void:
_show_menu_options() _show_menu_options()
func get_time_since_last_click() -> float: func get_time_since_last_click() -> float:
var current_time = Time.get_ticks_msec() / 1000.0 # Zeit in Sekunden var current_time = Time.get_ticks_msec() / 1000.0
var time_since_last_click = current_time - last_click_time var time_since_last_click = current_time - last_click_time
last_click_time = current_time last_click_time = current_time
return time_since_last_click return time_since_last_click
@ -113,7 +110,7 @@ func toggle_pause_menu():
else: else:
pause_menu_node.visible = true pause_menu_node.visible = true
get_tree().paused = true get_tree().paused = true
grab_focus() # Menü erhält den Fokus, um Eingaben zu empfangen grab_focus()
func _on_continue_button_pressed(): func _on_continue_button_pressed():
pause_menu_node.visible = false pause_menu_node.visible = false