feat(ultrasound): add UltrasoundMachine component with continuous heartbeat animation
This commit is contained in:
34
scenes/objects/UltrasoundMachine.tscn
Normal file
34
scenes/objects/UltrasoundMachine.tscn
Normal file
@@ -0,0 +1,34 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://cozypaw_ultrasoundmachine"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/objects/ultrasound_machine.gd" id="1_ultrasound"]
|
||||
|
||||
[node name="UltrasoundMachine" type="Node2D"]
|
||||
script = ExtResource("1_ultrasound")
|
||||
|
||||
[node name="MachineBody" type="ColorRect" parent="."]
|
||||
color = Color(0.68, 0.70, 0.76, 1)
|
||||
size = Vector2(80, 160)
|
||||
position = Vector2(-40, -160)
|
||||
|
||||
[node name="ScreenFrame" type="ColorRect" parent="."]
|
||||
color = Color(0.30, 0.32, 0.36, 1)
|
||||
size = Vector2(68, 52)
|
||||
position = Vector2(-34, -152)
|
||||
|
||||
[node name="Screen" type="ColorRect" parent="."]
|
||||
color = Color(0.06, 0.08, 0.12, 1)
|
||||
size = Vector2(60, 44)
|
||||
position = Vector2(-30, -148)
|
||||
|
||||
[node name="HeartbeatDot" type="Node2D" parent="."]
|
||||
position = Vector2(0, -126)
|
||||
|
||||
[node name="HeartbeatShape" type="ColorRect" parent="HeartbeatDot"]
|
||||
color = Color(0.40, 0.95, 0.60, 1)
|
||||
size = Vector2(12, 12)
|
||||
position = Vector2(-6, -6)
|
||||
|
||||
[node name="Probe" type="ColorRect" parent="."]
|
||||
color = Color(0.55, 0.57, 0.62, 1)
|
||||
size = Vector2(14, 80)
|
||||
position = Vector2(-7, -30)
|
||||
23
scripts/objects/ultrasound_machine.gd
Normal file
23
scripts/objects/ultrasound_machine.gd
Normal file
@@ -0,0 +1,23 @@
|
||||
## UltrasoundMachine — displays a continuous heartbeat pulse on the screen.
|
||||
class_name UltrasoundMachine extends Node2D
|
||||
|
||||
const BEAT_RISE_DURATION: float = 0.12
|
||||
const BEAT_FALL_DURATION: float = 0.12
|
||||
const BEAT_INTERVAL: float = 0.60
|
||||
const BEAT_SCALE_PEAK: Vector2 = Vector2(1.5, 1.5)
|
||||
const BEAT_SCALE_REST: Vector2 = Vector2(1.0, 1.0)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_start_heartbeat_loop()
|
||||
|
||||
|
||||
func _start_heartbeat_loop() -> void:
|
||||
var dot: Node2D = get_node_or_null("HeartbeatDot") as Node2D
|
||||
if dot == null:
|
||||
return
|
||||
var tween: Tween = create_tween()
|
||||
tween.set_loops()
|
||||
tween.tween_property(dot, "scale", BEAT_SCALE_PEAK, BEAT_RISE_DURATION)
|
||||
tween.tween_property(dot, "scale", BEAT_SCALE_REST, BEAT_FALL_DURATION)
|
||||
tween.tween_interval(BEAT_INTERVAL)
|
||||
Reference in New Issue
Block a user