fuzzyworld

godot-shooter / commit

Added a character theme, which uses the same common font, but has a smaller font size.

50483a82eec8a6816f69b68f38784bbc171df679 · Pavel Safronov · 2023-11-02 13:59:23 -0700 · parents adab6dc8f402

Added a character theme, which uses the same common font, but has a smaller font size.
 CharacterTheme.tres | 11 +++++++++++
 Enemy.tscn          |  4 +++-
 Player.tscn         | 10 ++++++----
 World.gd            |  2 +-
 4 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/CharacterTheme.tres b/CharacterTheme.tres
new file mode 100644
index 0000000..c8671d0
--- /dev/null
+++ b/CharacterTheme.tres
@@ -0,0 +1,11 @@
+[gd_resource type="Theme" load_steps=3 format=2]
+
+[ext_resource path="res://assets/Unique.ttf" type="DynamicFontData" id=1]
+
+[sub_resource type="DynamicFont" id=1]
+size = 24
+use_mipmaps = true
+font_data = ExtResource( 1 )
+
+[resource]
+default_font = SubResource( 1 )
diff --git a/Enemy.tscn b/Enemy.tscn
index 7644cd0..42592fb 100644
--- a/Enemy.tscn
+++ b/Enemy.tscn
@@ -1,8 +1,9 @@
-[gd_scene load_steps=6 format=2]
+[gd_scene load_steps=7 format=2]
 
 [ext_resource path="res://assets/kenney_simple-space/PNG/Default/enemy_A.png" type="Texture" id=1]
 [ext_resource path="res://Enemy.gd" type="Script" id=2]
 [ext_resource path="res://assets/kenney_simple-space/PNG/Default/icon_plusLarge.png" type="Texture" id=3]
+[ext_resource path="res://CharacterTheme.tres" type="Theme" id=4]
 
 [sub_resource type="Animation" id=1]
 length = 3.0
@@ -64,6 +65,7 @@ margin_left = -25.0
 margin_top = 37.0
 margin_right = 25.0
 margin_bottom = 51.0
+theme = ExtResource( 4 )
 text = "HEALTH"
 
 [node name="Target" type="Sprite" parent="Graphics/Alive"]
diff --git a/Player.tscn b/Player.tscn
index 037117f..e99caba 100644
--- a/Player.tscn
+++ b/Player.tscn
@@ -1,9 +1,10 @@
-[gd_scene load_steps=5 format=2]
+[gd_scene load_steps=6 format=2]
 
 [ext_resource path="res://assets/kenney_simple-space/PNG/Default/ship_C.png" type="Texture" id=1]
 [ext_resource path="res://Explosion.tscn" type="PackedScene" id=2]
 [ext_resource path="res://Player.gd" type="Script" id=3]
 [ext_resource path="res://Bullet.tscn" type="PackedScene" id=4]
+[ext_resource path="res://CharacterTheme.tres" type="Theme" id=5]
 
 [node name="Player" type="KinematicBody2D"]
 rotation = -0.000165944
@@ -23,9 +24,10 @@ texture = ExtResource( 1 )
 
 [node name="HealthLabel" type="Label" parent="Graphics/Alive/Control"]
 margin_left = -25.0046
-margin_top = 27.9958
-margin_right = 24.9954
-margin_bottom = 41.9958
+margin_top = 27.9959
+margin_right = 40.9954
+margin_bottom = 51.9958
+theme = ExtResource( 5 )
 text = "HEALTH"
 align = 1
 uppercase = true
diff --git a/World.gd b/World.gd
index 98ef26d..d0da9d7 100644
--- a/World.gd
+++ b/World.gd
@@ -70,7 +70,7 @@ func _on_ShootTimer_timeout() -> void:
 		return
 	var enemies = get_tree().get_nodes_in_group("enemies")
 	if enemies.size() > 0:
-		Utils.log("enemies length", enemies.size())
+#		Utils.log("enemies length", enemies.size())
 		enemies.sort_custom(self, "sort_enemies_ascending_distance")
 		for enemy in enemies:
 #			var diff_to_player: Vector2 = enemy.position - $Player.position