diff --git a/Characters/Scripts/Villain.gd b/Characters/Scripts/Villain.gd index d8c882a..866dedb 100755 --- a/Characters/Scripts/Villain.gd +++ b/Characters/Scripts/Villain.gd @@ -13,44 +13,44 @@ var next = false # Called when the node enters the scene tree for the first time. func _ready() -> void: - rng.randomize() + rng.randomize() - reset_timer() - me.play(animations[0]) + reset_timer() + me.play(animations[0]) func reset_timer() -> void: - timer = 0 - limit_random = rng.randi_range(2, 10) + timer = 0 + limit_random = rng.randi_range(2, 10) # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta) -> void: - timer += delta + timer += delta - var max_frame = me.frames.get_frame_count(me.animation) - 1 - var current_anim_idx = animations.find(me.animation) - if current_anim_idx >= animations.size() - 1: - # Last animation reached - check_next_animframe(max_frame, animations[0]) - else: - check_next_animframe(max_frame, animations[current_anim_idx + 1]) + var max_frame = me.frames.get_frame_count(me.animation) - 1 + var current_anim_idx = animations.find(me.animation) + if current_anim_idx >= animations.size() - 1: + # Last animation reached + check_next_animframe(max_frame, animations[0]) + else: + check_next_animframe(max_frame, animations[current_anim_idx + 1]) # Jump to next animation at the end of the current one func check_next_animframe(max_frame, next_animation) -> void: - if me.frame == 0 and next: - me.play(next_animation) - next = false - if next_animation == animations[0]: - # Reset random for first animation - reset_timer() - return - if max_frame == me.frame: - # Last frame of animation reached - next = true - return - if max_frame == -1 and timer >= limit_random: - # No frame in animation, use time - next = true - return + if me.frame == 0 and next: + me.play(next_animation) + next = false + if next_animation == animations[0]: + # Reset random for first animation + reset_timer() + return + if max_frame == me.frame: + # Last frame of animation reached + next = true + return + if max_frame == -1 and timer >= limit_random: + # No frame in animation, use time + next = true + return diff --git a/Elements/Scripts/Directory.gd b/Elements/Scripts/Directory.gd index f1ea68b..a854e1e 100755 --- a/Elements/Scripts/Directory.gd +++ b/Elements/Scripts/Directory.gd @@ -5,8 +5,8 @@ onready var sprite = $"../Sprite" func _on_Area2D_input_event(_viewport: Node, event: InputEvent, _shape_idx: int) -> void: - if event is InputEventMouseButton: - event = event as InputEventMouseButton - if event.pressed and event.button_index == BUTTON_LEFT: - screen.visible = true - sprite.modulate = Color(0.66, 0.51, 0.85) # shade + if event is InputEventMouseButton: + event = event as InputEventMouseButton + if event.pressed and event.button_index == BUTTON_LEFT: + screen.visible = true + sprite.modulate = Color(0.66, 0.51, 0.85) # shade diff --git a/Elements/Scripts/WindowHeader.gd b/Elements/Scripts/WindowHeader.gd index daac849..7486ede 100755 --- a/Elements/Scripts/WindowHeader.gd +++ b/Elements/Scripts/WindowHeader.gd @@ -8,34 +8,34 @@ onready var folder_icon = $"../../../Sprite" func drag_change_state(): - is_dragging = !is_dragging - grabbed_offset = window.get_position() - get_global_mouse_position() + is_dragging = !is_dragging + grabbed_offset = window.get_position() - get_global_mouse_position() func _process(_delta) -> void: - if is_dragging: - var new_pos = get_global_mouse_position() + grabbed_offset - if new_pos.x > 150: - window.set_position(new_pos) - else: - drag_change_state() + if is_dragging: + var new_pos = get_global_mouse_position() + grabbed_offset + if new_pos.x > 150: + window.set_position(new_pos) + else: + drag_change_state() func _on_Area2D_input_event(_viewport: Node, event: InputEvent, _shape_idx: int) -> void: - if event is InputEventMouseButton: - event = event as InputEventMouseButton - if event.pressed and event.button_index == BUTTON_LEFT: - drag_change_state() - #print("here haha") - elif event.button_index == BUTTON_LEFT and !event.pressed: - drag_change_state() - #print("here huhu") + if event is InputEventMouseButton: + event = event as InputEventMouseButton + if event.pressed and event.button_index == BUTTON_LEFT: + drag_change_state() + #print("here haha") + elif event.button_index == BUTTON_LEFT and !event.pressed: + drag_change_state() + #print("here huhu") func _on_Area2D2_input_event(_viewport: Node, event: InputEvent, _shape_idx: int) -> void: - if event is InputEventMouseButton: - event = event as InputEventMouseButton - if event.pressed and event.button_index == BUTTON_LEFT: - drag_change_state() - window.visible = false - folder_icon.modulate = Color(1, 1, 1) # reset shade + if event is InputEventMouseButton: + event = event as InputEventMouseButton + if event.pressed and event.button_index == BUTTON_LEFT: + drag_change_state() + window.visible = false + folder_icon.modulate = Color(1, 1, 1) # reset shade diff --git a/Scenes/Scripts/Button_Node2D.gd b/Scenes/Scripts/Button_Node2D.gd index 8893cf0..c316414 100755 --- a/Scenes/Scripts/Button_Node2D.gd +++ b/Scenes/Scripts/Button_Node2D.gd @@ -4,29 +4,29 @@ onready var villain = $"../../../../Villain/AnimatedSprite" onready var villain_animations = $"../../../../Villain" var etat = false -var remplissage = 0; +var remplissage = 0 const texture_pressed = preload("res://Assets/tres_button/hover-pressed.png") const texture_released = preload("res://Assets/tres_button/normal.png") # Called every frame. '_delta' is the elapsed time since the previous frame. func _process(_delta) -> void: - if etat: - if villain.animation == villain_animations.animations[-1]: - assert(get_tree().change_scene("res://Scenes/gameover.tscn") == OK) - if(remplissage == 60*10): # fermer le dossier et enlever l'icone - etat = false - self.get_parent().get_parent().visible = false; - else : - remplissage+=1; - print(remplissage) + if etat: + if villain.animation == villain_animations.animations[-1]: + assert(get_tree().change_scene("res://Scenes/gameover.tscn") == OK) + if remplissage == 60 * 10: # fermer le dossier et enlever l'icone + etat = false + self.get_parent().get_parent().visible = false + else: + remplissage += 1 + print(remplissage) func _on_Button_pressed() -> void: - etat = !etat - var new_stylebox_normal = self.get_stylebox("normal").duplicate() - if etat: - new_stylebox_normal.texture = texture_pressed - else: - new_stylebox_normal.texture = texture_released - self.add_stylebox_override("normal", new_stylebox_normal) + etat = !etat + var new_stylebox_normal = self.get_stylebox("normal").duplicate() + if etat: + new_stylebox_normal.texture = texture_pressed + else: + new_stylebox_normal.texture = texture_released + self.add_stylebox_override("normal", new_stylebox_normal) diff --git a/Scenes/Scripts/Desktop.gd b/Scenes/Scripts/Desktop.gd old mode 100644 new mode 100755 index 46c51b4..155ff0d --- a/Scenes/Scripts/Desktop.gd +++ b/Scenes/Scripts/Desktop.gd @@ -8,26 +8,28 @@ onready var alert = $"Alert" var rng = RandomNumberGenerator.new() + # Called when the node enters the scene tree for the first time. func _ready() -> void: - rng.randomize() - var nbDossier = rng.randi_range(0, 3) - for i in range(nbDossier): - var dossier = get_child(2).duplicate() - dossier.position = Vector2(dossier.position.x, dossier.position.y+150*(i+1)) - dossier.set_z_index(dossier.get_z_index()+10*(i+1)) - add_child(dossier) + rng.randomize() + var nbDossier = rng.randi_range(0, 3) + for i in range(nbDossier): + var dossier = get_child(2).duplicate() + dossier.position = Vector2(dossier.position.x, dossier.position.y + 150 * (i + 1)) + dossier.set_z_index(dossier.get_z_index() + 10 * (i + 1)) + add_child(dossier) + # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(_delta) -> void: - if villain.animation == villain_animations.animations[-1]: - mainMusic.set_volume_db(-80) - eyeMusic.set_volume_db(0) - if(alert.is_playing()): - alert.stop() - elif villain.animation == villain_animations.animations[1] : - if(!alert.is_playing()): - alert.play() - else : - mainMusic.set_volume_db(0) - eyeMusic.set_volume_db(-80) + if villain.animation == villain_animations.animations[-1]: + mainMusic.set_volume_db(-80) + eyeMusic.set_volume_db(0) + if alert.is_playing(): + alert.stop() + elif villain.animation == villain_animations.animations[1]: + if !alert.is_playing(): + alert.play() + else: + mainMusic.set_volume_db(0) + eyeMusic.set_volume_db(-80) diff --git a/Scenes/Scripts/GameOver.gd b/Scenes/Scripts/GameOver.gd index 14dd00c..7de4103 100755 --- a/Scenes/Scripts/GameOver.gd +++ b/Scenes/Scripts/GameOver.gd @@ -1,9 +1,10 @@ extends Node2D onready var hover_sound = $"Hover" + 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) func _on_RestartButton_mouse_entered() -> void: - hover_sound.play() + hover_sound.play() diff --git a/Scenes/Scripts/Screen_Menu.gd b/Scenes/Scripts/Screen_Menu.gd index 8795fa1..7858bf4 100755 --- a/Scenes/Scripts/Screen_Menu.gd +++ b/Scenes/Scripts/Screen_Menu.gd @@ -1,25 +1,26 @@ extends Control onready var hover_sound = $"Hover" + 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) func _on_Help_Button_pressed() -> void: - print("help me") + print("help me") func _on_Quit_Button_pressed() -> void: - get_tree().quit() - + get_tree().quit() func _on_PlayButton_mouse_entered() -> void: - hover_sound.play() + hover_sound.play() + func _on_Quit_Button_mouse_entered() -> void: - hover_sound.play() + hover_sound.play() func _on_Help_Button_mouse_entered() -> void: - hover_sound.play() + hover_sound.play() diff --git a/Scenes/menu.tscn b/Scenes/menu.tscn index 0a9fe62..eee3ad8 100755 --- a/Scenes/menu.tscn +++ b/Scenes/menu.tscn @@ -17,22 +17,20 @@ scale = Vector2( 0.5, 0.5 ) z_index = -2 texture = ExtResource( 6 ) -[node name="MenuButton" type="MenuButton" parent="."] -margin_left = 480.0 -margin_top = 232.0 -margin_right = 584.0 -margin_bottom = 392.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 +[node name="VBoxContainer" type="VBoxContainer" parent="."] +margin_left = 432.0 +margin_top = 272.0 +margin_right = 568.0 +margin_bottom = 504.0 custom_constants/separation = 26 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_right = 136.0 margin_bottom = 71.0 @@ -44,7 +42,7 @@ custom_styles/pressed = ExtResource( 4 ) custom_styles/normal = ExtResource( 3 ) text = "PLAY" -[node name="Help_Button" type="Button" parent="MenuButton/VBoxContainer"] +[node name="Help_Button" type="Button" parent="VBoxContainer"] margin_top = 97.0 margin_right = 136.0 margin_bottom = 134.0 @@ -56,7 +54,7 @@ custom_styles/pressed = ExtResource( 4 ) custom_styles/normal = ExtResource( 3 ) text = "HELP" -[node name="Quit_Button" type="Button" parent="MenuButton/VBoxContainer"] +[node name="Quit_Button" type="Button" parent="VBoxContainer"] margin_top = 160.0 margin_right = 136.0 margin_bottom = 197.0 @@ -68,16 +66,14 @@ custom_styles/pressed = ExtResource( 4 ) custom_styles/normal = ExtResource( 3 ) text = "QUIT" -[node name="Hover" type="AudioStreamPlayer" parent="MenuButton"] -stream = ExtResource( 8 ) - [node name="MenuMusic" type="AudioStreamPlayer" parent="."] stream = ExtResource( 7 ) +volume_db = 8.0 autoplay = true -[connection signal="mouse_entered" from="MenuButton/VBoxContainer/PlayButton" to="MenuButton" method="_on_PlayButton_mouse_entered"] -[connection signal="pressed" from="MenuButton/VBoxContainer/PlayButton" to="MenuButton" method="_on_PlayButton_pressed"] -[connection signal="mouse_entered" from="MenuButton/VBoxContainer/Help_Button" to="MenuButton" method="_on_Help_Button_mouse_entered"] -[connection signal="pressed" from="MenuButton/VBoxContainer/Help_Button" to="MenuButton" method="_on_Help_Button_pressed"] -[connection signal="mouse_entered" from="MenuButton/VBoxContainer/Quit_Button" to="MenuButton" method="_on_Quit_Button_mouse_entered"] -[connection signal="pressed" from="MenuButton/VBoxContainer/Quit_Button" to="MenuButton" method="_on_Quit_Button_pressed"] +[connection signal="mouse_entered" from="VBoxContainer/PlayButton" to="VBoxContainer" method="_on_PlayButton_mouse_entered"] +[connection signal="pressed" from="VBoxContainer/PlayButton" to="VBoxContainer" method="_on_PlayButton_pressed"] +[connection signal="mouse_entered" from="VBoxContainer/Help_Button" to="VBoxContainer" method="_on_Help_Button_mouse_entered"] +[connection signal="pressed" from="VBoxContainer/Help_Button" to="VBoxContainer" method="_on_Help_Button_pressed"] +[connection signal="mouse_entered" from="VBoxContainer/Quit_Button" to="VBoxContainer" method="_on_Quit_Button_mouse_entered"] +[connection signal="pressed" from="VBoxContainer/Quit_Button" to="VBoxContainer" method="_on_Quit_Button_pressed"]