diff --git a/godot/scenes/Tim.gd b/godot/scenes/Tim.gd index 812ea9e..2c32338 100644 --- a/godot/scenes/Tim.gd +++ b/godot/scenes/Tim.gd @@ -15,9 +15,11 @@ var ducking_texture: Texture2D = load("res://sprites/tim_ducking.svg") func _ready(): Signals.hit_tim.connect(ouch) - # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): + if $AnimationPlayer.is_playing(): + return + if Input.is_action_pressed("move_right"): tim_sprite.flip_h = true global_position += Vector2.RIGHT * delta * move_speed @@ -30,9 +32,17 @@ func _process(delta): if global_position.x < boundary.get_most_left_position(): global_position = Vector2(boundary.get_most_left_position(), global_position.y) +func _disable_buttons(): + $"Joke Buttons".hide() + $"Joke Buttons".process_mode = Node.PROCESS_MODE_DISABLED + +func _enable_buttons(): + $"Joke Buttons".show() + $"Joke Buttons".process_mode = Node.PROCESS_MODE_INHERIT func _on_joke_button_button_pressed(joke: Joke): $AnimationPlayer.play("talking") + _disable_buttons() stamina -= joke.required_stamina for body in transmitter_area.get_overlapping_bodies(): @@ -42,10 +52,6 @@ func _on_joke_button_button_pressed(joke: Joke): person.on_joke(joke) - if stamina <= 0: - _on_stamina_empty() - - func _on_stamina_empty(): get_node("../DisplayGUI").visible = false @@ -62,8 +68,13 @@ func _on_stamina_empty(): score_overlay.visible = true pass - func ouch(): $Sprite2D.texture = ducking_texture await get_tree().create_timer(1).timeout $Sprite2D.texture = default_texture + +func _on_animation_player_animation_finished(anim_name): + if stamina <= 0: + _on_stamina_empty() + else: + _enable_buttons() diff --git a/godot/scenes/main_menu_scene.tscn b/godot/scenes/main_menu_scene.tscn index 304ddd0..0308347 100644 --- a/godot/scenes/main_menu_scene.tscn +++ b/godot/scenes/main_menu_scene.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=8 format=3 uid="uid://dv2y18ye8j7o0"] [ext_resource type="Script" path="res://scenes/main_menu_scene.gd" id="1_1foie"] -[ext_resource type="PackedScene" uid="uid://cik30de5gaaah" path="res://scenes/ingame_scene.tscn" id="2_nl5i6"] +[ext_resource type="PackedScene" uid="uid://dsbpdd7xdslx0" path="res://scenes/tutorial.tscn" id="2_o0xek"] [ext_resource type="PackedScene" uid="uid://g4qhvbvdm62w" path="res://scenes/game_settings_scene.tscn" id="3_dgs4d"] [ext_resource type="PackedScene" uid="uid://bkk87o2ooo6at" path="res://ui/overlays/fade_overlay.tscn" id="3_kf1us"] [ext_resource type="PackedScene" uid="uid://b4blrdjthcxnn" path="res://ui/components/game_logo.tscn" id="4_fnufg"] @@ -13,7 +13,7 @@ font_color = Color(1, 1, 1, 0.486275) [node name="MainMenuScene" type="Node2D"] script = ExtResource("1_1foie") -game_scene = ExtResource("2_nl5i6") +game_scene = ExtResource("2_o0xek") settings_scene = ExtResource("3_dgs4d") [node name="UI" type="CanvasLayer" parent="."] diff --git a/godot/scenes/stage.tscn b/godot/scenes/stage.tscn index b6fa8b2..655745f 100644 --- a/godot/scenes/stage.tscn +++ b/godot/scenes/stage.tscn @@ -163,3 +163,4 @@ script = ExtResource("7_5m0td") [connection signal="button_pressed" from="Tim/Joke Buttons/Joke Button 1" to="Tim" method="_on_joke_button_button_pressed"] [connection signal="button_pressed" from="Tim/Joke Buttons/Joke Button 2" to="Tim" method="_on_joke_button_button_pressed"] [connection signal="button_pressed" from="Tim/Joke Buttons/Joke Button 3" to="Tim" method="_on_joke_button_button_pressed"] +[connection signal="animation_finished" from="Tim/AnimationPlayer" to="Tim" method="_on_animation_player_animation_finished"] diff --git a/godot/scenes/tutorial.gd b/godot/scenes/tutorial.gd new file mode 100644 index 0000000..ad0ad55 --- /dev/null +++ b/godot/scenes/tutorial.gd @@ -0,0 +1,14 @@ +extends Node2D + +@export var next_scene: PackedScene + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + pass + +func _on_button_pressed(): + get_tree().change_scene_to_packed(next_scene) diff --git a/godot/scenes/tutorial.tscn b/godot/scenes/tutorial.tscn new file mode 100644 index 0000000..18acb54 --- /dev/null +++ b/godot/scenes/tutorial.tscn @@ -0,0 +1,34 @@ +[gd_scene load_steps=3 format=3 uid="uid://dsbpdd7xdslx0"] + +[ext_resource type="Script" path="res://scenes/tutorial.gd" id="1_i8rpu"] +[ext_resource type="PackedScene" uid="uid://cik30de5gaaah" path="res://scenes/ingame_scene.tscn" id="2_lch8g"] + +[node name="Tutorial" type="Node2D"] +script = ExtResource("1_i8rpu") +next_scene = ExtResource("2_lch8g") + +[node name="AspectRatioContainer" type="AspectRatioContainer" parent="."] +offset_right = 576.0 +offset_bottom = 325.0 +ratio = 1.6306 + +[node name="VSplitContainer" type="VSplitContainer" parent="AspectRatioContainer"] +layout_mode = 2 +split_offset = 270 +dragger_visibility = 2 + +[node name="RichTextLabel" type="RichTextLabel" parent="AspectRatioContainer/VSplitContainer"] +layout_mode = 2 +text = "Can YOU please the crowd? + +Throw out jokes but be aware that not every joke is for everyone. +Can you please everyone before you run out of breath?" + +[node name="CenterContainer" type="CenterContainer" parent="AspectRatioContainer/VSplitContainer"] +layout_mode = 2 + +[node name="Button" type="Button" parent="AspectRatioContainer/VSplitContainer/CenterContainer"] +layout_mode = 2 +text = "I'm ready for the show!" + +[connection signal="pressed" from="AspectRatioContainer/VSplitContainer/CenterContainer/Button" to="." method="_on_button_pressed"]