score label vfx; increase building collider size

This commit is contained in:
Michael Campbell 2026-04-13 21:55:45 -04:00
parent 69faf54dc3
commit 962c4cb469
6 changed files with 60 additions and 18 deletions

View file

@ -23,9 +23,10 @@ func _process(delta: float) -> void:
shake_duration = move_toward(shake_duration, 0., delta)
func _show_score_label() -> void:
func _show_score_label(score: int) -> void:
%ScoreLabel.position.x += randf_range(-2, 2)
%ScoreLabel.position.y += randf_range(-2, 2)
%ScoreLabel.text = "+%d" % score
%ScoreLabel.show()
create_tween().tween_property(%ScoreLabel, "position:y", %ScoreLabel.position.y + 2., 1.)
await get_tree().create_timer(.5, false).timeout
@ -39,14 +40,15 @@ func _show_score_label() -> void:
func hit(_proj: Node3D, damage: float) -> bool:
health -= damage
if health <= 0.:
SignalBus.building_destroyed.emit(self)
var score := randi_range(10, 20)
SignalBus.building_destroyed.emit(self, score)
collision_layer = 1 # World collision only
%Shaker.hide()
%DestroyedMesh.show()
%GPUParticles3D.preprocess = randf()
_show_score_label()
_show_score_label(score)
else:
shake_duration += 0.5

View file

@ -12,7 +12,7 @@
[ext_resource type="Script" uid="uid://d1xiar6hicypm" path="res://buildings/building_behavior.gd" id="10_umrlk"]
[sub_resource type="BoxShape3D" id="BoxShape3D_5j34s"]
size = Vector3(4.989258, 5, 5.453125)
size = Vector3(5.9665527, 5, 5.453125)
[sub_resource type="Gradient" id="Gradient_2yopf"]
offsets = PackedFloat32Array(0.06315789, 0.6421053, 1)

File diff suppressed because one or more lines are too long

View file

@ -64,13 +64,6 @@ mesh = SubResource("SphereMesh_4flbx")
[node name="PlayerHUD" type="CanvasLayer" parent="." unique_id=1676328708]
script = ExtResource("2_g6k8r")
[node name="ScoreLabel" type="Label" parent="PlayerHUD" unique_id=1108751125]
offset_right = 40.0
offset_bottom = 23.0
theme_override_font_sizes/font_size = 48
text = "Score: %s"
script = ExtResource("2_onrkg")
[node name="HealthLabel" type="Label" parent="PlayerHUD" unique_id=1653322479]
unique_name_in_owner = true
visible = false
@ -119,6 +112,30 @@ theme_override_font_sizes/font_size = 32
text = "BasicGun"
horizontal_alignment = 2
[node name="Score" type="Control" parent="PlayerHUD" unique_id=1241180984]
layout_mode = 3
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
grow_horizontal = 2
script = ExtResource("2_onrkg")
metadata/_edit_use_anchors_ = true
[node name="ScoreText" type="Label" parent="PlayerHUD/Score" unique_id=1108751125]
custom_minimum_size = Vector2(1152, 0)
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
anchor_right = 0.5
offset_left = -576.0
offset_right = 576.0
offset_bottom = 132.0
grow_horizontal = 2
theme_override_constants/outline_size = 31
theme_override_font_sizes/font_size = 96
text = "14"
horizontal_alignment = 1
[node name="Guns" type="Node3D" parent="." unique_id=2018109083]
[node name="Sharpshooter" type="Node3D" parent="Guns" unique_id=1677055720]

View file

@ -1,12 +1,35 @@
extends Label
extends Control
const DESIRED_SCALE := Vector2.ONE * .5
@onready var label: Label = get_child(0)
var tween: Tween
var _display_score := 0
var score := 0:
set(v):
var delta = abs(v - score)
score = v
text = "Score: %d" % v
if label != null:
if tween != null: tween.stop()
tween = create_tween()
tween.tween_method((func(n):
_display_score = n
label.text = str(n)
), _display_score, score, .25)
scale += Vector2.ONE * pow(delta, 1.25) / 400
func exp_lerp(a: Variant, b: Variant, decay: float, dt: float) -> Variant:
return lerp(a, b, 1 - exp(-decay * dt))
func _ready() -> void:
scale = DESIRED_SCALE
score = score
SignalBus.building_destroyed.connect(func(_building):
score += 10
SignalBus.building_destroyed.connect(func(_building, increment):
score += increment
)
func _process(delta: float) -> void:
pass
scale = exp_lerp(scale, DESIRED_SCALE, 05, delta)

View file

@ -1,3 +1,3 @@
extends Node
signal building_destroyed(building: Building)
signal building_destroyed(building: Building, score: int)