From 9a2097a207a2a3ef2f7b7ffe4995efe4bae20d7c Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 19 Feb 2024 05:41:04 +0100 Subject: [PATCH] Add player name and color for golf ball --- scenes/golf_ball.gd | 18 ++++++++++++++++++ scenes/golf_ball.tscn | 17 ++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/scenes/golf_ball.gd b/scenes/golf_ball.gd index e4ac07b..573315e 100644 --- a/scenes/golf_ball.gd +++ b/scenes/golf_ball.gd @@ -25,6 +25,24 @@ var in_hole: bool = false @onready var putt_controller: PuttController = $"PuttController" @onready var hole_controller: HoleController = $"HoleController" @onready var hole_sound: AudioStreamPlayer2D = $"HoleSound" +@onready var player_label: Label = $"PlayerLabel" + + +## The name of the player represented by this scene. +var player_name: String = "Player": + get: + return player_name + set(value): + player_name = value + player_label.text = value + +## The color of the player represented by this scene. +var player_color: Color = Color.WHITE: + get: + return player_color + set(value): + player_color = value + modulate = value func _on_putt(putt_vector: Vector2): diff --git a/scenes/golf_ball.tscn b/scenes/golf_ball.tscn index f56cfc0..e2a811f 100644 --- a/scenes/golf_ball.tscn +++ b/scenes/golf_ball.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=3 uid="uid://ca06elq8io5wu"] +[gd_scene load_steps=11 format=3 uid="uid://ca06elq8io5wu"] [ext_resource type="Script" path="res://scenes/golf_ball.gd" id="1_1uswk"] [ext_resource type="Texture2D" uid="uid://bxyy3bwt7a5l2" path="res://sprites/circle.svg" id="2_mqlag"] @@ -6,6 +6,7 @@ [ext_resource type="PackedScene" uid="uid://cj15ash4r3i4v" path="res://scenes/collision_sound.tscn" id="4_6m2yp"] [ext_resource type="PackedScene" uid="uid://bf0a04t4b1wil" path="res://scenes/hole_controller.tscn" id="5_tdklt"] [ext_resource type="AudioStream" uid="uid://crfybmbv6dbs4" path="res://sounds/hole.wav" id="6_08dpq"] +[ext_resource type="Theme" uid="uid://mau3moiintkp" path="res://themes/nanogolf_theme.tres" id="7_2tupu"] [sub_resource type="Curve" id="Curve_v81ms"] min_value = -20.0 @@ -49,4 +50,18 @@ debug_color = Color(0, 0.701961, 0.141176, 0.419608) [node name="HoleSound" type="AudioStreamPlayer2D" parent="."] stream = ExtResource("6_08dpq") +[node name="PlayerLabel" type="Label" parent="."] +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_left = 8.0 +offset_top = -11.5 +offset_right = 48.0 +offset_bottom = 11.5 +grow_vertical = 2 +theme = ExtResource("7_2tupu") +theme_override_font_sizes/font_size = 13 +text = "Player" +vertical_alignment = 1 + [connection signal="putt" from="PuttController" to="." method="_on_putt"]