coin score

master
DJh2o2 2024-05-16 14:00:49 +07:00
parent 525f75e39b
commit a783b11d68
5 changed files with 47 additions and 3 deletions

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

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

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

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

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