Merge branch 'main' of 192.168.8.1:tough_crowd

This commit is contained in:
Mikhail Aristov 2024-01-28 09:46:20 +01:00
commit af50d4fc88
5 changed files with 68 additions and 8 deletions

View File

@ -15,9 +15,11 @@ var ducking_texture: Texture2D = load("res://sprites/tim_ducking.svg")
func _ready(): func _ready():
Signals.hit_tim.connect(ouch) Signals.hit_tim.connect(ouch)
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta): func _process(delta):
if $AnimationPlayer.is_playing():
return
if Input.is_action_pressed("move_right"): if Input.is_action_pressed("move_right"):
tim_sprite.flip_h = true tim_sprite.flip_h = true
global_position += Vector2.RIGHT * delta * move_speed global_position += Vector2.RIGHT * delta * move_speed
@ -30,9 +32,17 @@ func _process(delta):
if global_position.x < boundary.get_most_left_position(): if global_position.x < boundary.get_most_left_position():
global_position = Vector2(boundary.get_most_left_position(), global_position.y) 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): func _on_joke_button_button_pressed(joke: Joke):
$AnimationPlayer.play("talking") $AnimationPlayer.play("talking")
_disable_buttons()
stamina -= joke.required_stamina stamina -= joke.required_stamina
for body in transmitter_area.get_overlapping_bodies(): for body in transmitter_area.get_overlapping_bodies():
@ -42,10 +52,6 @@ func _on_joke_button_button_pressed(joke: Joke):
person.on_joke(joke) person.on_joke(joke)
if stamina <= 0:
_on_stamina_empty()
func _on_stamina_empty(): func _on_stamina_empty():
get_node("../DisplayGUI").visible = false get_node("../DisplayGUI").visible = false
@ -62,8 +68,13 @@ func _on_stamina_empty():
score_overlay.visible = true score_overlay.visible = true
pass pass
func ouch(): func ouch():
$Sprite2D.texture = ducking_texture $Sprite2D.texture = ducking_texture
await get_tree().create_timer(1).timeout await get_tree().create_timer(1).timeout
$Sprite2D.texture = default_texture $Sprite2D.texture = default_texture
func _on_animation_player_animation_finished(anim_name):
if stamina <= 0:
_on_stamina_empty()
else:
_enable_buttons()

View File

@ -1,7 +1,7 @@
[gd_scene load_steps=8 format=3 uid="uid://dv2y18ye8j7o0"] [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="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://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://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"] [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"] [node name="MainMenuScene" type="Node2D"]
script = ExtResource("1_1foie") script = ExtResource("1_1foie")
game_scene = ExtResource("2_nl5i6") game_scene = ExtResource("2_o0xek")
settings_scene = ExtResource("3_dgs4d") settings_scene = ExtResource("3_dgs4d")
[node name="UI" type="CanvasLayer" parent="."] [node name="UI" type="CanvasLayer" parent="."]

View File

@ -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 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 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="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"]

14
godot/scenes/tutorial.gd Normal file
View File

@ -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)

View File

@ -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"]