diff --git a/.vscode/settings.json b/.vscode/settings.json index f7a0a26..e80f895 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "godotTools.editorPath.godot4": "c:\\Program Files\\Godot_v4.3-dev5_mono_win64\\Godot_v4.3-dev5_mono_win64.exe" + "godotTools.editorPath.godot4": "c:\\Program Files\\Godot_v4.3-dev6_win64\\Godot_v4.3-dev6_win64.exe", + "cmake.configureOnOpen": true } diff --git a/project.godot b/project.godot index c1ab26c..7698b47 100644 --- a/project.godot +++ b/project.godot @@ -18,6 +18,10 @@ config/features=PackedStringArray("4.3", "Forward Plus") Music="*res://scenes/music.tscn" +[dotnet] + +project/assembly_name="Princess Dragon Slayer" + [file_customization] folder_colors={ diff --git a/scenes/game.tscn b/scenes/game.tscn index 30eac0b..19a81f9 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=3 uid="uid://bftnbe6bs7unm"] +[gd_scene load_steps=12 format=3 uid="uid://bftnbe6bs7unm"] [ext_resource type="PackedScene" uid="uid://r1ex2hm0w68w" path="res://scenes/player.tscn" id="1_bet5j"] [ext_resource type="Texture2D" uid="uid://buys6ooyytlxw" path="res://assets/sprites/world_tileset.png" id="1_xr8eg"] @@ -6,6 +6,8 @@ [ext_resource type="Script" path="res://scripts/ground.gd" id="3_xffrs"] [ext_resource type="Script" path="res://scripts/game_manager.gd" id="5_6hne7"] [ext_resource type="PackedScene" uid="uid://cgg02cx7s7xqo" path="res://scenes/platform.tscn" id="6_tsa0d"] +[ext_resource type="Script" path="res://scripts/ui.gd" id="7_pu2yw"] +[ext_resource type="FontFile" uid="uid://j3litmo78ydo" path="res://assets/fonts/PixelOperator8.ttf" id="8_2x5s2"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_q7uas"] texture = ExtResource("1_xr8eg") @@ -200,6 +202,26 @@ zoom = Vector2(3, 3) limit_smoothed = true position_smoothing_enabled = true +[node name="UI" type="Control" parent="Player/Camera2D"] +layout_mode = 3 +anchors_preset = 0 +offset_left = -183.0 +offset_top = -99.0 +offset_right = -143.0 +offset_bottom = -59.0 +script = ExtResource("7_pu2yw") + +[node name="ScoreLabel" type="Label" parent="Player/Camera2D/UI"] +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 23.0 +theme_override_colors/font_color = Color(0, 0, 0, 1) +theme_override_fonts/font = ExtResource("8_2x5s2") +theme_override_font_sizes/font_size = 12 +text = "Score: 0" +horizontal_alignment = 1 +vertical_alignment = 1 + [node name="Ground" type="Area2D" parent="."] position = Vector2(-176, 175) collision_mask = 2 @@ -243,4 +265,5 @@ position = Vector2(72, -57) [node name="Platform3" parent="Platforms" instance=ExtResource("6_tsa0d")] position = Vector2(72, -88) +[connection signal="score_changed" from="GameManager" to="Player/Camera2D/UI" method="_on_game_manager_score_changed"] [connection signal="body_entered" from="Ground" to="Ground" method="_on_body_entered"] diff --git a/scripts/game_manager.gd b/scripts/game_manager.gd index a37fa75..45b02d9 100644 --- a/scripts/game_manager.gd +++ b/scripts/game_manager.gd @@ -1,6 +1,16 @@ extends Node -var score = 0 +signal score_changed(new_score: int) + +var score := 0: + set(value): + score = value + score_changed.emit(score) + get: + return score + +#func _ready() -> void: + #score_changed.emit(score) func collect_coin(): score += 1 diff --git a/scripts/ui.gd b/scripts/ui.gd new file mode 100644 index 0000000..e2b5f20 --- /dev/null +++ b/scripts/ui.gd @@ -0,0 +1,6 @@ +extends Control + +@onready var score_label: Label = $ScoreLabel + +func _on_game_manager_score_changed(new_score) -> void: + score_label.text = "Score: " + str(new_score)