ft: prey sprite update

This commit is contained in:
Djairo Hougee 2026-01-29 10:31:24 +01:00
parent 7207626315
commit 69776a6973
10 changed files with 34 additions and 22 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -26,14 +26,15 @@ func _ready() -> void:
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void: func _process(delta: float) -> void:
# smoothly rotate
if self.rotation != self.desired_rotation: # FIXME: causes the mirror sprites to flip out
self.rotation = lerp_angle(self.rotation, self.desired_rotation, clampf(4 * delta, 0, 1))
# Boundary mirroring # Boundary mirroring
_handle_wrapping() _handle_wrapping()
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
# rotate smoothly pass
if self.rotation != self.desired_rotation: # FIXME: causes the mirror sprites to flip out
self.rotation = lerp_angle(self.rotation, self.desired_rotation, 4 * delta)
func move(motion: Vector3) -> void: func move(motion: Vector3) -> void:
move_and_collide(Vector2(motion.x, motion.y)) # Moves along the given vector move_and_collide(Vector2(motion.x, motion.y)) # Moves along the given vector
@ -61,7 +62,7 @@ func become_injured() -> void:
mirrorSprite3.play("Injured") mirrorSprite3.play("Injured")
func _on_sight_body_entered(body: Node2D) -> void: func _on_sight_body_entered(body: Node2D) -> void:
if body.is_in_group("predators") or body.is_in_group("player"): if body.is_in_group("predators") or (body.is_in_group("player") and health < maxHealth):
fsm.transition_to_next_state(fsm.States.FLEEING, {"threat": body}) fsm.transition_to_next_state(fsm.States.FLEEING, {"threat": body})

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=14 format=3 uid="uid://c3iw2v3x6ngrb"] [gd_scene format=3 uid="uid://c3iw2v3x6ngrb"]
[ext_resource type="PackedScene" uid="uid://bvsdg1v3ksixy" path="res://shared/npc/prey2D.tscn" id="1_qvulj"] [ext_resource type="PackedScene" uid="uid://bvsdg1v3ksixy" path="res://shared/npc/prey2D.tscn" id="1_qvulj"]
[ext_resource type="Script" uid="uid://bgossk6xo31gi" path="res://molecular/prey/nucleotide_prey.gd" id="2_0227s"] [ext_resource type="Script" uid="uid://bgossk6xo31gi" path="res://molecular/prey/nucleotide_prey.gd" id="2_0227s"]
@ -49,44 +49,49 @@ animations = [{
"speed": 1.0 "speed": 1.0
}] }]
[node name="NucleotidePrey" groups=["prey"] instance=ExtResource("1_qvulj")] [node name="NucleotidePrey" unique_id=740525631 groups=["prey"] instance=ExtResource("1_qvulj")]
collision_layer = 2 collision_layer = 2
motion_mode = 1 motion_mode = 1
script = ExtResource("2_0227s") script = ExtResource("2_0227s")
maxHealth = 20 maxHealth = 20
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." index="0"] [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." index="0" unique_id=788182944]
rotation = 1.5707964
scale = Vector2(0.1, 0.1) scale = Vector2(0.1, 0.1)
sprite_frames = SubResource("SpriteFrames_66x8p") sprite_frames = SubResource("SpriteFrames_66x8p")
animation = &"Injured" animation = &"Healthy"
[node name="StateMachine" type="Node" parent="." index="2" node_paths=PackedStringArray("initial_state")] [node name="CollisionPolygon2D" parent="." index="1"]
position = Vector2(6.929083, 3.0664783)
rotation = 0.474154
[node name="StateMachine" type="Node" parent="." index="2" unique_id=445822474 node_paths=PackedStringArray("initial_state")]
script = ExtResource("9_xxtgy") script = ExtResource("9_xxtgy")
initial_state = NodePath("Idle") initial_state = NodePath("Idle")
metadata/_custom_type_script = "uid://ck7k8ht54snsy" metadata/_custom_type_script = "uid://ck7k8ht54snsy"
[node name="RandomMovement" type="Node" parent="StateMachine" index="0"] [node name="RandomMovement" type="Node" parent="StateMachine" index="0" unique_id=1422146232]
script = ExtResource("10_rgguv") script = ExtResource("10_rgguv")
[node name="Timer" type="Timer" parent="StateMachine/RandomMovement" index="0"] [node name="Timer" type="Timer" parent="StateMachine/RandomMovement" index="0" unique_id=593528934]
one_shot = true one_shot = true
[node name="Fleeing" type="Node" parent="StateMachine" index="1"] [node name="Fleeing" type="Node" parent="StateMachine" index="1" unique_id=1125485674]
script = ExtResource("12_xxtgy") script = ExtResource("12_xxtgy")
[node name="Idle" type="Node" parent="StateMachine" index="2"] [node name="Idle" type="Node" parent="StateMachine" index="2" unique_id=1424222731]
script = ExtResource("12_ubfhk") script = ExtResource("12_ubfhk")
metadata/_custom_type_script = "uid://co2xp7gauamql" metadata/_custom_type_script = "uid://co2xp7gauamql"
[node name="Timer" type="Timer" parent="StateMachine/Idle" index="0"] [node name="Timer" type="Timer" parent="StateMachine/Idle" index="0" unique_id=1050348256]
one_shot = true one_shot = true
[node name="Sight" type="Area2D" parent="." index="3"] [node name="Sight" type="Area2D" parent="." index="3" unique_id=1773478588]
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Sight" index="0"] [node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Sight" index="0" unique_id=338757598]
rotation = 1.5707964
polygon = PackedVector2Array(3.8686981, -6.2705374, 7.0000973, -0.08602524, 3.5555592, 5.6287766, -3.0986624, 5.589636, -6.1517763, 0.031402588, -2.942093, -6.0748243, -29.993027, -74.37026, -11.10141, -83.6233, 9.332382, -84.00884, 35.163773, -77.06906) polygon = PackedVector2Array(3.8686981, -6.2705374, 7.0000973, -0.08602524, 3.5555592, 5.6287766, -3.0986624, 5.589636, -6.1517763, 0.031402588, -2.942093, -6.0748243, -29.993027, -74.37026, -11.10141, -83.6233, 9.332382, -84.00884, 35.163773, -77.06906)
[connection signal="timeout" from="StateMachine/RandomMovement/Timer" to="StateMachine/RandomMovement" method="_on_timer_timeout"] [connection signal="timeout" from="StateMachine/RandomMovement/Timer" to="StateMachine/RandomMovement" method="_on_timer_timeout"]
[connection signal="timeout" from="StateMachine/Idle/Timer" to="StateMachine/Idle" method="_on_timer_timeout"] [connection signal="timeout" from="StateMachine/Idle/Timer" to="StateMachine/Idle" method="_on_timer_timeout"]
[connection signal="body_entered" from="Sight" to="." method="_on_sight_body_entered"] [connection signal="body_entered" from="Sight" to="." method="_on_sight_body_entered"]
[connection signal="body_exited" from="Sight" to="." method="_on_sight_body_exited"]

View File

@ -1,17 +1,19 @@
extends State extends State
@onready var timer = $Timer @onready var timer = $Timer
var dir = Vector3(1, 1, 0)
func enter(previous_state_path: String, data := {}) -> void: func enter(previous_state_path: String, data := {}) -> void:
timer.start((float)(randi() % 5)/5) timer.start((float)(randi() % 5)/5)
func physics_update(_delta: float) -> void: func physics_update(_delta: float) -> void:
owner.move(Vector3(randfn(0, 1), randfn(0, 1), 0)) owner.move(_delta * dir)
#owner.move(_delta * Vector3(randfn(0, 1), randfn(0, 1), 0))
func _on_timer_timeout() -> void: func _on_timer_timeout() -> void:
if (randi() % 4 != 0): if (randi() % 4 != 0):
finished.emit(owner.fsm.States.RANDOMMOVEMENT, {}) finished.emit(owner.fsm.States.IDLE, {})
#finished.emit(owner.fsm.States.RANDOMMOVEMENT, {})
else: else:
finished.emit(owner.fsm.States.IDLE, {}) finished.emit(owner.fsm.States.IDLE, {})

View File

@ -8,11 +8,15 @@
config_version=5 config_version=5
[animation]
compatibility/default_parent_skeleton_in_mesh_instance_3d=true
[application] [application]
config/name="EvolveDieRepeat" config/name="EvolveDieRepeat"
run/main_scene="uid://drgv154ei1vrl" run/main_scene="uid://drgv154ei1vrl"
config/features=PackedStringArray("4.5", "Forward Plus") config/features=PackedStringArray("4.6", "Forward Plus")
config/icon="res://icon.svg" config/icon="res://icon.svg"
[autoload] [autoload]