ajout comptage mort et niveau

This commit is contained in:
Mylloon 2021-04-08 15:15:37 +02:00
parent 63880ba0ba
commit 373ee3ed82
8 changed files with 58 additions and 4 deletions

BIN
assets/images/gameOver.png (Stored with Git LFS)

Binary file not shown.

View file

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

View file

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

View file

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

View file

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

View file

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

5
scripts/global.gd Normal file
View file

@ -0,0 +1,5 @@
extends Node
var monde
var ennemisTues

View file

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