From 373ee3ed82ff30551f34dd86550bd6389e35f0d6 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 8 Apr 2021 15:15:37 +0200 Subject: [PATCH] ajout comptage mort et niveau --- assets/images/gameOver.png | 4 ++-- project.godot | 4 ++++ scenes/GameOver.tscn | 42 +++++++++++++++++++++++++++++++++++++- scripts/Balle.gd | 1 + scripts/GameOver.gd | 2 ++ scripts/PortailDeFin.gd | 2 +- scripts/global.gd | 5 +++++ scripts/menuPrincipal.gd | 2 ++ 8 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 scripts/global.gd diff --git a/assets/images/gameOver.png b/assets/images/gameOver.png index c8bc9c6..954b876 100644 --- a/assets/images/gameOver.png +++ b/assets/images/gameOver.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2aa51882715e2b0b180acff115570adb279c9533e329dfcd341ac07e7a78f9ea -size 9633 +oid sha256:a8d4fa56bc2b0fcccf3c48cd8b7dc19baa5cad83886c6fbb8f94b82eb3c39309 +size 29437 diff --git a/project.godot b/project.godot index 44f33ff..82b4a08 100644 --- a/project.godot +++ b/project.godot @@ -21,6 +21,10 @@ run/main_scene="res://scenes/Menu.tscn" config/icon="res://assets/images/sortie.png" config/windows_native_icon="res://assets/images/icon.ico" +[autoload] + +global="*res://scripts/global.gd" + [display] window/stretch/mode="2d" diff --git a/scenes/GameOver.tscn b/scenes/GameOver.tscn index c047dd4..f47a320 100644 --- a/scenes/GameOver.tscn +++ b/scenes/GameOver.tscn @@ -1,9 +1,23 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=8 format=2] [ext_resource path="res://assets/images/gameOver.png" type="Texture" id=1] [ext_resource path="res://scripts/GameOver.gd" type="Script" id=2] [ext_resource path="res://assets/sounds/mort.wav" type="AudioStream" id=3] +[sub_resource type="DynamicFontData" id=1] +font_path = "res://assets/fonts/tyrafont.ttf" + +[sub_resource type="DynamicFont" id=2] +size = 45 +font_data = SubResource( 1 ) + +[sub_resource type="DynamicFontData" id=3] +font_path = "res://assets/fonts/tyrafont.ttf" + +[sub_resource type="DynamicFont" id=4] +size = 45 +font_data = SubResource( 3 ) + [node name="GameOver" type="Control"] anchor_right = 1.0 anchor_bottom = 1.0 @@ -20,3 +34,29 @@ centered = false stream = ExtResource( 3 ) volume_db = -30.0 autoplay = true + +[node name="labelNiveauMax" type="Label" parent="."] +margin_left = 578.0 +margin_top = 415.0 +margin_right = 657.0 +margin_bottom = 470.0 +custom_fonts/font = SubResource( 2 ) +custom_colors/font_color = Color( 0.172549, 0.588235, 0.529412, 1 ) +align = 1 +valign = 1 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="labelEnnemisTues" type="Label" parent="."] +margin_left = 640.0 +margin_top = 514.0 +margin_right = 795.0 +margin_bottom = 586.0 +custom_fonts/font = SubResource( 4 ) +custom_colors/font_color = Color( 0.172549, 0.588235, 0.529412, 1 ) +align = 1 +valign = 1 +__meta__ = { +"_edit_use_anchors_": false +} diff --git a/scripts/Balle.gd b/scripts/Balle.gd index 7a50496..7c5b2de 100644 --- a/scripts/Balle.gd +++ b/scripts/Balle.gd @@ -18,4 +18,5 @@ func _on_Area2D_body_entered(body): var son = sonMortEnnemi.instance() # création object son son.position = get_global_position() # récupération de la position get_tree().get_root().call_deferred("add_child", son) # ajout du son + global.ennemisTues += 1 body.queue_free() diff --git a/scripts/GameOver.gd b/scripts/GameOver.gd index 2344f91..3692774 100644 --- a/scripts/GameOver.gd +++ b/scripts/GameOver.gd @@ -1,6 +1,8 @@ extends Control func _ready(): + get_node("labelNiveauMax").set_text(str(global.monde)) + get_node("labelEnnemisTues").set_text(str(global.ennemisTues)) var timer = Timer.new() timer.connect("timeout", self, "_on_timer_timeout") timer.set_wait_time(2) # 2 secondes diff --git a/scripts/PortailDeFin.gd b/scripts/PortailDeFin.gd index 9d75025..32ef6d2 100644 --- a/scripts/PortailDeFin.gd +++ b/scripts/PortailDeFin.gd @@ -3,7 +3,7 @@ extends Area2D var aleatoire = RandomNumberGenerator.new() # initialisation aléatoire func _ready(): - pass + global.monde += 1 func _on_Portail_de_fin_body_entered(body): if "Joueur" in body.name: # si la personne qui entre est un joueur diff --git a/scripts/global.gd b/scripts/global.gd new file mode 100644 index 0000000..5625cad --- /dev/null +++ b/scripts/global.gd @@ -0,0 +1,5 @@ +extends Node + +var monde + +var ennemisTues diff --git a/scripts/menuPrincipal.gd b/scripts/menuPrincipal.gd index 5fa2fc6..8597d05 100644 --- a/scripts/menuPrincipal.gd +++ b/scripts/menuPrincipal.gd @@ -4,6 +4,8 @@ var aleatoire = RandomNumberGenerator.new() # initialisation aléatoire func _ready(): # focus par défaut le bouton JOUER $MarginContainer/VBoxContainer/VBoxContainer/Jouer.grab_focus() + global.monde = 0 + global.ennemisTues = 0 func _physics_process(_delta): # gestion de la souris if $MarginContainer/VBoxContainer/VBoxContainer/Jouer.is_hovered() == true: