adding sound to menu

This commit is contained in:
Fabio 2024-08-20 18:01:25 +02:00
parent 5a278ca062
commit d255435c93
8 changed files with 190 additions and 7 deletions

View file

@ -0,0 +1,107 @@
[gd_scene load_steps=6 format=3 uid="uid://1h2urto6y63r"]
[ext_resource type="FontFile" uid="uid://d3pbvdemdbxes" path="res://CommodoreSixtyFour.ttf" id="1_1tx2i"]
[ext_resource type="Theme" uid="uid://cohbys634cf18" path="res://menu/main_menu/MainMenuTheme.tres" id="1_kkajn"]
[ext_resource type="Script" path="res://scripts/menu_main_control.gd" id="2_g8c7b"]
[ext_resource type="PackedScene" uid="uid://dii1q3f5dj72y" path="res://objects/CRT.tscn" id="2_hal3l"]
[ext_resource type="AudioStream" uid="uid://lr64lmpjnll0" path="res://sound/Blip_Select28.wav" id="5_sd7aq"]
[node name="MainMenu" type="MarginContainer"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("1_kkajn")
[node name="CanvasLayer" parent="." instance=ExtResource("2_hal3l")]
[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("2_g8c7b")
[node name="VBoxContainer" type="VBoxContainer" parent="Control"]
layout_mode = 0
offset_right = 40.0
offset_bottom = 40.0
[node name="VBoxContainer2" type="VBoxContainer" parent="Control/VBoxContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="Control/VBoxContainer/VBoxContainer2"]
layout_mode = 2
[node name="Buttons" type="VBoxContainer" parent="Control/VBoxContainer"]
layout_mode = 2
[node name="HBoxContainer" type="HBoxContainer" parent="Control/VBoxContainer/Buttons"]
visible = false
layout_mode = 2
[node name="Label" type="Label" parent="Control/VBoxContainer/Buttons/HBoxContainer"]
custom_minimum_size = Vector2(8, 0)
layout_mode = 2
theme_override_fonts/font = ExtResource("1_1tx2i")
text = ">"
[node name="start" type="Button" parent="Control/VBoxContainer/Buttons/HBoxContainer"]
layout_mode = 2
text = "start"
flat = true
[node name="HBoxContainer2" type="HBoxContainer" parent="Control/VBoxContainer/Buttons"]
visible = false
layout_mode = 2
[node name="Label" type="Label" parent="Control/VBoxContainer/Buttons/HBoxContainer2"]
custom_minimum_size = Vector2(8, 0)
layout_mode = 2
theme_override_fonts/font = ExtResource("1_1tx2i")
text = ">"
[node name="level_select" type="Button" parent="Control/VBoxContainer/Buttons/HBoxContainer2"]
layout_mode = 2
text = "level selection"
flat = true
[node name="HBoxContainer3" type="HBoxContainer" parent="Control/VBoxContainer/Buttons"]
visible = false
layout_mode = 2
[node name="Label" type="Label" parent="Control/VBoxContainer/Buttons/HBoxContainer3"]
custom_minimum_size = Vector2(8, 0)
layout_mode = 2
theme_override_fonts/font = ExtResource("1_1tx2i")
text = ">"
[node name="credits" type="Button" parent="Control/VBoxContainer/Buttons/HBoxContainer3"]
layout_mode = 2
text = "credits"
flat = true
[node name="HBoxContainer4" type="HBoxContainer" parent="Control/VBoxContainer/Buttons"]
visible = false
layout_mode = 2
[node name="Label" type="Label" parent="Control/VBoxContainer/Buttons/HBoxContainer4"]
custom_minimum_size = Vector2(8, 0)
layout_mode = 2
theme_override_fonts/font = ExtResource("1_1tx2i")
text = ">"
[node name="quit" type="Button" parent="Control/VBoxContainer/Buttons/HBoxContainer4"]
layout_mode = 2
text = "quit"
flat = true
[node name="TypingSoundPlayer" type="AudioStreamPlayer2D" parent="Control"]
stream = ExtResource("5_sd7aq")
[connection signal="pressed" from="Control/VBoxContainer/Buttons/HBoxContainer/start" to="Control" method="_on_start_button_pressed"]
[connection signal="pressed" from="Control/VBoxContainer/Buttons/HBoxContainer2/level_select" to="Control" method="_on_level_select_pressed"]
[connection signal="pressed" from="Control/VBoxContainer/Buttons/HBoxContainer3/credits" to="Control" method="_on_credits_button_pressed"]
[connection signal="pressed" from="Control/VBoxContainer/Buttons/HBoxContainer4/quit" to="Control" method="_on_quit_button_pressed"]

View file

@ -1,9 +1,10 @@
[gd_scene load_steps=5 format=3 uid="uid://1h2urto6y63r"] [gd_scene load_steps=6 format=3 uid="uid://1h2urto6y63r"]
[ext_resource type="FontFile" uid="uid://d3pbvdemdbxes" path="res://CommodoreSixtyFour.ttf" id="1_1tx2i"] [ext_resource type="FontFile" uid="uid://d3pbvdemdbxes" path="res://CommodoreSixtyFour.ttf" id="1_1tx2i"]
[ext_resource type="Theme" uid="uid://cohbys634cf18" path="res://menu/main_menu/MainMenuTheme.tres" id="1_kkajn"] [ext_resource type="Theme" uid="uid://cohbys634cf18" path="res://menu/main_menu/MainMenuTheme.tres" id="1_kkajn"]
[ext_resource type="Script" path="res://scripts/menu_main_control.gd" id="2_g8c7b"] [ext_resource type="Script" path="res://scripts/menu_main_control.gd" id="2_g8c7b"]
[ext_resource type="PackedScene" uid="uid://dii1q3f5dj72y" path="res://objects/CRT.tscn" id="2_hal3l"] [ext_resource type="PackedScene" uid="uid://dii1q3f5dj72y" path="res://objects/CRT.tscn" id="2_hal3l"]
[ext_resource type="AudioStream" uid="uid://bgx6cs627hq7q" path="res://sound/digital_text_typing.wav" id="5_tkj4j"]
[node name="MainMenu" type="MarginContainer"] [node name="MainMenu" type="MarginContainer"]
anchors_preset = 15 anchors_preset = 15
@ -97,6 +98,9 @@ layout_mode = 2
text = "quit" text = "quit"
flat = true flat = true
[node name="TypingSoundPlayer" type="AudioStreamPlayer2D" parent="Control"]
stream = ExtResource("5_tkj4j")
[connection signal="pressed" from="Control/VBoxContainer/Buttons/HBoxContainer/start" to="Control" method="_on_start_button_pressed"] [connection signal="pressed" from="Control/VBoxContainer/Buttons/HBoxContainer/start" to="Control" method="_on_start_button_pressed"]
[connection signal="pressed" from="Control/VBoxContainer/Buttons/HBoxContainer2/level_select" to="Control" method="_on_level_select_pressed"] [connection signal="pressed" from="Control/VBoxContainer/Buttons/HBoxContainer2/level_select" to="Control" method="_on_level_select_pressed"]
[connection signal="pressed" from="Control/VBoxContainer/Buttons/HBoxContainer3/credits" to="Control" method="_on_credits_button_pressed"] [connection signal="pressed" from="Control/VBoxContainer/Buttons/HBoxContainer3/credits" to="Control" method="_on_credits_button_pressed"]

View file

@ -1,12 +1,66 @@
[gd_scene load_steps=7 format=3 uid="uid://snxpqx0ony7s"] [gd_scene load_steps=11 format=3 uid="uid://snxpqx0ony7s"]
[ext_resource type="Script" path="res://scripts/player_movement.gd" id="1_a6lhy"] [ext_resource type="Script" path="res://scripts/player_movement.gd" id="1_a6lhy"]
[ext_resource type="Texture2D" uid="uid://qcx482jc7pqr" path="res://textures/player.png" id="2_sscjv"] [ext_resource type="Texture2D" uid="uid://bnj38vubchr2w" path="res://textures/Virus-Player-Sheet.png" id="2_183nu"]
[ext_resource type="Texture2D" uid="uid://s7wqkcxerals" path="res://textures/Eye Lase.png" id="3_yg3ur"] [ext_resource type="Texture2D" uid="uid://bd7y5w6cfi5ly" path="res://textures/Eye Lase.png" id="3_yg3ur"]
[ext_resource type="AudioStream" uid="uid://donbyet486b4" path="res://sound/Jump5.wav" id="4_jit8y"] [ext_resource type="AudioStream" uid="uid://cc2cqe8owjaaa" path="res://sound/Jump5.wav" id="4_jit8y"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_31jvr"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_31jvr"]
[sub_resource type="Animation" id="Animation_ahrep"]
resource_name = "idle"
length = 0.4
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame_coords")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.0666667, 0.133333, 0.2, 0.266667, 0.333333),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
"update": 1,
"values": [Vector2i(0, 0), Vector2i(1, 0), Vector2i(2, 0), Vector2i(3, 0), Vector2i(4, 0), Vector2i(5, 0)]
}
[sub_resource type="Animation" id="Animation_g8ois"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame_coords")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [Vector2i(0, 0)]
}
[sub_resource type="Animation" id="Animation_1wyqk"]
resource_name = "moving"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame_coords")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [Vector2i(0, 0)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_hrlyn"]
_data = {
"RESET": SubResource("Animation_g8ois"),
"idle": SubResource("Animation_ahrep"),
"moving": SubResource("Animation_1wyqk")
}
[sub_resource type="CircleShape2D" id="CircleShape2D_vxfel"] [sub_resource type="CircleShape2D" id="CircleShape2D_vxfel"]
radius = 12.0 radius = 12.0
@ -23,7 +77,13 @@ jump_strength = 600
shape = SubResource("RectangleShape2D_31jvr") shape = SubResource("RectangleShape2D_31jvr")
[node name="Sprite2D" type="Sprite2D" parent="."] [node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("2_sscjv") texture = ExtResource("2_183nu")
hframes = 6
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_hrlyn")
}
[node name="Hurtbox" type="Area2D" parent="."] [node name="Hurtbox" type="Area2D" parent="."]
collision_layer = 0 collision_layer = 0

View file

@ -1,7 +1,7 @@
[gd_scene load_steps=8 format=3 uid="uid://c6g2f7tm7iasr"] [gd_scene load_steps=8 format=3 uid="uid://c6g2f7tm7iasr"]
[ext_resource type="Script" path="res://scripts/PressurePlate.gd" id="1_7ar3x"] [ext_resource type="Script" path="res://scripts/PressurePlate.gd" id="1_7ar3x"]
[ext_resource type="Texture2D" uid="uid://bpfvkxqajd1en" path="res://textures/PressurePlate.png" id="1_st48m"] [ext_resource type="Texture2D" uid="uid://cwf57p0osmc0w" path="res://textures/PressurePlate.png" id="1_st48m"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_c6ukx"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_c6ukx"]
size = Vector2(24, 2) size = Vector2(24, 2)

View file

@ -25,6 +25,8 @@ var is_typing = true
var current_button_index = 0 var current_button_index = 0
var buttons = [] var buttons = []
@onready var typing_sound_player = $TypingSoundPlayer
func _ready(): func _ready():
for hbox in $VBoxContainer/Buttons.get_children(): for hbox in $VBoxContainer/Buttons.get_children():
hbox.visible = false hbox.visible = false
@ -92,6 +94,10 @@ func _update_text() -> void:
if char_index < display_text.length(): if char_index < display_text.length():
current_text += display_text[char_index] current_text += display_text[char_index]
$VBoxContainer/VBoxContainer2/Label.text = current_text $VBoxContainer/VBoxContainer2/Label.text = current_text
if typing_sound_player and not typing_sound_player.is_playing():
typing_sound_player.play()
char_index += 1 char_index += 1
await get_tree().create_timer(typing_speed).timeout await get_tree().create_timer(typing_speed).timeout
_update_text() _update_text()
@ -99,6 +105,7 @@ func _update_text() -> void:
is_typing = false is_typing = false
_show_menu_options() _show_menu_options()
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

View file

@ -3,6 +3,8 @@ extends CharacterBody2D
@export var sfx : AudioStreamPlayer2D @export var sfx : AudioStreamPlayer2D
@export var sfx_large : AudioStreamPlayer2D @export var sfx_large : AudioStreamPlayer2D
@onready var animation = $AnimationPlayer
@export var speed = 340 @export var speed = 340
@export var gravity = 50 @export var gravity = 50
var jump_count = 1 var jump_count = 1
@ -58,10 +60,13 @@ func get_input(delta):
if left and right: if left and right:
input_direction = 0 input_direction = 0
elif left: elif left:
animation.play("RESET")
input_direction = -1 input_direction = -1
elif right: elif right:
animation.play("RESET")
input_direction = 1 input_direction = 1
else: else:
animation.play("idle")
input_direction = 0 input_direction = 0
velocity.x = input_direction * speed velocity.x = input_direction * speed

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB