Update game to display scores
This commit is contained in:
parent
01c4522b86
commit
a7612be80a
|
@ -1,10 +1,11 @@
|
|||
[gd_scene load_steps=9 format=3 uid="uid://d2had6j0ul7hn"]
|
||||
[gd_scene load_steps=10 format=3 uid="uid://d2had6j0ul7hn"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://b5plspvrerf8c" path="res://assets/background/rocks_2.png" id="1_kihwf"]
|
||||
[ext_resource type="Script" path="res://game/game.gd" id="1_mh8bq"]
|
||||
[ext_resource type="PackedScene" uid="uid://dnu582ov5o310" path="res://plane/plane.tscn" id="2_xl0om"]
|
||||
[ext_resource type="PackedScene" uid="uid://bed61tdnf2vq7" path="res://pipes/pipes.tscn" id="3_njdgd"]
|
||||
[ext_resource type="PackedScene" uid="uid://bjx4v08mh6uhy" path="res://game_over/game_over.tscn" id="5_pro41"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpkbp3vf7sy4b" path="res://hud/hud.tscn" id="6_8typh"]
|
||||
[ext_resource type="AudioStream" uid="uid://cyxd4egjwfkbr" path="res://assets/audio/engine.mp3" id="6_amryi"]
|
||||
[ext_resource type="AudioStream" uid="uid://bmg81go7777oe" path="res://assets/audio/game_over.wav" id="7_45rto"]
|
||||
|
||||
|
@ -46,6 +47,8 @@ autostart = true
|
|||
[node name="GameOver" parent="CanvasLayer" instance=ExtResource("5_pro41")]
|
||||
visible = false
|
||||
|
||||
[node name="Hud" parent="CanvasLayer" instance=ExtResource("6_8typh")]
|
||||
|
||||
[node name="EngineSound" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource("6_amryi")
|
||||
autoplay = true
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
extends Control
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
GameManager.on_score_updated.connect(on_score_updated)
|
||||
|
||||
|
||||
func on_score_updated() -> void:
|
||||
$MarginContainer/ScoreLabel.text = str(GameManager.get_score())
|
|
@ -0,0 +1,28 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://dpkbp3vf7sy4b"]
|
||||
|
||||
[ext_resource type="LabelSettings" uid="uid://upfup1vx2iul" path="res://assets/LG_48_Red.tres" id="1_b6jk0"]
|
||||
[ext_resource type="Script" path="res://hud/hud.gd" id="1_hugxe"]
|
||||
|
||||
[node name="Hud" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_hugxe")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 10
|
||||
anchor_right = 1.0
|
||||
offset_bottom = 61.0
|
||||
grow_horizontal = 2
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_top = 12
|
||||
|
||||
[node name="ScoreLabel" type="Label" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
text = "0"
|
||||
label_settings = ExtResource("1_b6jk0")
|
||||
vertical_alignment = 1
|
|
@ -3,7 +3,7 @@ extends Control
|
|||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
$MarginContainer/HBoxContainer/HighScoreLabel.text = str(GameManager.get_high_score())
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
|
|
|
@ -24,7 +24,7 @@ func set_score(value: int) -> void:
|
|||
if _score > _high_score:
|
||||
_high_score = _score
|
||||
on_score_updated.emit()
|
||||
print("sc:%s hs:%s" % [_score, _high_score])
|
||||
#print("sc:%s hs:%s" % [_score, _high_score])
|
||||
|
||||
|
||||
func increment_score() -> void:
|
||||
|
|
Loading…
Reference in New Issue