fix sound and remove menu button

This commit is contained in:
Mylloon 2023-02-26 17:39:03 +01:00
parent ee4bf46a85
commit 8232a4382a
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
8 changed files with 123 additions and 123 deletions

View file

@ -4,7 +4,7 @@ onready var villain = $"../../../../Villain/AnimatedSprite"
onready var villain_animations = $"../../../../Villain" onready var villain_animations = $"../../../../Villain"
var etat = false var etat = false
var remplissage = 0; var remplissage = 0
const texture_pressed = preload("res://Assets/tres_button/hover-pressed.png") const texture_pressed = preload("res://Assets/tres_button/hover-pressed.png")
const texture_released = preload("res://Assets/tres_button/normal.png") const texture_released = preload("res://Assets/tres_button/normal.png")
@ -14,11 +14,11 @@ func _process(_delta) -> void:
if etat: if etat:
if villain.animation == villain_animations.animations[-1]: if villain.animation == villain_animations.animations[-1]:
assert(get_tree().change_scene("res://Scenes/gameover.tscn") == OK) assert(get_tree().change_scene("res://Scenes/gameover.tscn") == OK)
if(remplissage == 60*10): # fermer le dossier et enlever l'icone if remplissage == 60 * 10: # fermer le dossier et enlever l'icone
etat = false etat = false
self.get_parent().get_parent().visible = false; self.get_parent().get_parent().visible = false
else : else:
remplissage+=1; remplissage += 1
print(remplissage) print(remplissage)

14
Scenes/Scripts/Desktop.gd Normal file → Executable file
View file

@ -8,26 +8,28 @@ onready var alert = $"Alert"
var rng = RandomNumberGenerator.new() var rng = RandomNumberGenerator.new()
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready() -> void: func _ready() -> void:
rng.randomize() rng.randomize()
var nbDossier = rng.randi_range(0, 3) var nbDossier = rng.randi_range(0, 3)
for i in range(nbDossier): for i in range(nbDossier):
var dossier = get_child(2).duplicate() var dossier = get_child(2).duplicate()
dossier.position = Vector2(dossier.position.x, dossier.position.y+150*(i+1)) dossier.position = Vector2(dossier.position.x, dossier.position.y + 150 * (i + 1))
dossier.set_z_index(dossier.get_z_index()+10*(i+1)) dossier.set_z_index(dossier.get_z_index() + 10 * (i + 1))
add_child(dossier) add_child(dossier)
# 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) -> void: func _process(_delta) -> void:
if villain.animation == villain_animations.animations[-1]: if villain.animation == villain_animations.animations[-1]:
mainMusic.set_volume_db(-80) mainMusic.set_volume_db(-80)
eyeMusic.set_volume_db(0) eyeMusic.set_volume_db(0)
if(alert.is_playing()): if alert.is_playing():
alert.stop() alert.stop()
elif villain.animation == villain_animations.animations[1] : elif villain.animation == villain_animations.animations[1]:
if(!alert.is_playing()): if !alert.is_playing():
alert.play() alert.play()
else : else:
mainMusic.set_volume_db(0) mainMusic.set_volume_db(0)
eyeMusic.set_volume_db(-80) eyeMusic.set_volume_db(-80)

View file

@ -1,6 +1,7 @@
extends Node2D extends Node2D
onready var hover_sound = $"Hover" onready var hover_sound = $"Hover"
func _on_RestartButton_pressed() -> void: func _on_RestartButton_pressed() -> void:
assert(get_tree().change_scene("res://Scenes/menu.tscn") == OK) assert(get_tree().change_scene("res://Scenes/menu.tscn") == OK)

View file

@ -1,6 +1,7 @@
extends Control extends Control
onready var hover_sound = $"Hover" onready var hover_sound = $"Hover"
func _on_PlayButton_pressed() -> void: func _on_PlayButton_pressed() -> void:
assert(get_tree().change_scene("res://Scenes/DesktopScreen.tscn") == OK) assert(get_tree().change_scene("res://Scenes/DesktopScreen.tscn") == OK)
@ -13,10 +14,10 @@ func _on_Quit_Button_pressed() -> void:
get_tree().quit() get_tree().quit()
func _on_PlayButton_mouse_entered() -> void: func _on_PlayButton_mouse_entered() -> void:
hover_sound.play() hover_sound.play()
func _on_Quit_Button_mouse_entered() -> void: func _on_Quit_Button_mouse_entered() -> void:
hover_sound.play() hover_sound.play()

View file

@ -17,22 +17,20 @@ scale = Vector2( 0.5, 0.5 )
z_index = -2 z_index = -2
texture = ExtResource( 6 ) texture = ExtResource( 6 )
[node name="MenuButton" type="MenuButton" parent="."] [node name="VBoxContainer" type="VBoxContainer" parent="."]
margin_left = 480.0 margin_left = 432.0
margin_top = 232.0 margin_top = 272.0
margin_right = 584.0 margin_right = 568.0
margin_bottom = 392.0 margin_bottom = 504.0
script = ExtResource( 1 )
[node name="VBoxContainer" type="VBoxContainer" parent="MenuButton"]
margin_left = -48.0
margin_top = 40.0
margin_right = 88.0
margin_bottom = 272.0
custom_constants/separation = 26 custom_constants/separation = 26
alignment = 1 alignment = 1
script = ExtResource( 1 )
[node name="PlayButton" type="Button" parent="MenuButton/VBoxContainer"] [node name="Hover" type="AudioStreamPlayer" parent="VBoxContainer"]
stream = ExtResource( 8 )
volume_db = -7.0
[node name="PlayButton" type="Button" parent="VBoxContainer"]
margin_top = 34.0 margin_top = 34.0
margin_right = 136.0 margin_right = 136.0
margin_bottom = 71.0 margin_bottom = 71.0
@ -44,7 +42,7 @@ custom_styles/pressed = ExtResource( 4 )
custom_styles/normal = ExtResource( 3 ) custom_styles/normal = ExtResource( 3 )
text = "PLAY" text = "PLAY"
[node name="Help_Button" type="Button" parent="MenuButton/VBoxContainer"] [node name="Help_Button" type="Button" parent="VBoxContainer"]
margin_top = 97.0 margin_top = 97.0
margin_right = 136.0 margin_right = 136.0
margin_bottom = 134.0 margin_bottom = 134.0
@ -56,7 +54,7 @@ custom_styles/pressed = ExtResource( 4 )
custom_styles/normal = ExtResource( 3 ) custom_styles/normal = ExtResource( 3 )
text = "HELP" text = "HELP"
[node name="Quit_Button" type="Button" parent="MenuButton/VBoxContainer"] [node name="Quit_Button" type="Button" parent="VBoxContainer"]
margin_top = 160.0 margin_top = 160.0
margin_right = 136.0 margin_right = 136.0
margin_bottom = 197.0 margin_bottom = 197.0
@ -68,16 +66,14 @@ custom_styles/pressed = ExtResource( 4 )
custom_styles/normal = ExtResource( 3 ) custom_styles/normal = ExtResource( 3 )
text = "QUIT" text = "QUIT"
[node name="Hover" type="AudioStreamPlayer" parent="MenuButton"]
stream = ExtResource( 8 )
[node name="MenuMusic" type="AudioStreamPlayer" parent="."] [node name="MenuMusic" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 7 ) stream = ExtResource( 7 )
volume_db = 8.0
autoplay = true autoplay = true
[connection signal="mouse_entered" from="MenuButton/VBoxContainer/PlayButton" to="MenuButton" method="_on_PlayButton_mouse_entered"] [connection signal="mouse_entered" from="VBoxContainer/PlayButton" to="VBoxContainer" method="_on_PlayButton_mouse_entered"]
[connection signal="pressed" from="MenuButton/VBoxContainer/PlayButton" to="MenuButton" method="_on_PlayButton_pressed"] [connection signal="pressed" from="VBoxContainer/PlayButton" to="VBoxContainer" method="_on_PlayButton_pressed"]
[connection signal="mouse_entered" from="MenuButton/VBoxContainer/Help_Button" to="MenuButton" method="_on_Help_Button_mouse_entered"] [connection signal="mouse_entered" from="VBoxContainer/Help_Button" to="VBoxContainer" method="_on_Help_Button_mouse_entered"]
[connection signal="pressed" from="MenuButton/VBoxContainer/Help_Button" to="MenuButton" method="_on_Help_Button_pressed"] [connection signal="pressed" from="VBoxContainer/Help_Button" to="VBoxContainer" method="_on_Help_Button_pressed"]
[connection signal="mouse_entered" from="MenuButton/VBoxContainer/Quit_Button" to="MenuButton" method="_on_Quit_Button_mouse_entered"] [connection signal="mouse_entered" from="VBoxContainer/Quit_Button" to="VBoxContainer" method="_on_Quit_Button_mouse_entered"]
[connection signal="pressed" from="MenuButton/VBoxContainer/Quit_Button" to="MenuButton" method="_on_Quit_Button_pressed"] [connection signal="pressed" from="VBoxContainer/Quit_Button" to="VBoxContainer" method="_on_Quit_Button_pressed"]