Compare commits

..

No commits in common. "4e6c65d8ea159586b5a35713ebd3d65f64d0d492" and "b69e705ea3d1cff49d7be843be566c8e15b4552d" have entirely different histories.

4 changed files with 8 additions and 314 deletions

View file

@ -41,7 +41,7 @@
[ext_resource type="StyleBox" uid="uid://0jfr1uwuog0s" path="res://Assets/UI/Slider/v/background.tres" id="39_dl1e4"]
[ext_resource type="FontFile" uid="uid://dqdeftjkwxe64" path="res://Assets/Fonts/Dogica/dogicapixel.ttf" id="40_bmcvq"]
[sub_resource type="Image" id="Image_kwuuq"]
[sub_resource type="Image" id="Image_hhwo6"]
data = {
"data": PackedByteArray(255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 64, 255, 255, 255, 64, 255, 255, 255, 0),
"format": "RGBA8",
@ -51,7 +51,7 @@ data = {
}
[sub_resource type="ImageTexture" id="ImageTexture_g5bup"]
image = SubResource("Image_kwuuq")
image = SubResource("Image_hhwo6")
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_sj7h5"]

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=12 format=3 uid="uid://cpl4tllohhyel"]
[gd_scene load_steps=5 format=3 uid="uid://cpl4tllohhyel"]
[ext_resource type="Script" path="res://Scripts/EntitySystem/Bunny.gd" id="1_1kj2b"]
[ext_resource type="Texture2D" uid="uid://df2fluk0dlqar" path="res://Assets/Sprites/Bunny/bad_bunny_spritesheet.png" id="2_v8p70"]
@ -8,119 +8,10 @@
[sub_resource type="CircleShape2D" id="CircleShape2D_itvjj"]
radius = 14.0
[sub_resource type="Animation" id="Animation_6br4g"]
resource_name = "Idle"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [0]
}
[sub_resource type="Animation" id="Animation_olc18"]
resource_name = "MoveDown"
length = 0.5
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
"update": 1,
"values": [0, 1, 2, 3, 4]
}
[sub_resource type="Animation" id="Animation_l8j6b"]
resource_name = "MoveLeft"
length = 0.5
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
"update": 1,
"values": [5, 6, 7, 8, 9]
}
[sub_resource type="Animation" id="Animation_agj62"]
resource_name = "MoveRight"
length = 0.5
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
"update": 1,
"values": [10, 11, 12, 13, 14]
}
[sub_resource type="Animation" id="Animation_45lfy"]
resource_name = "MoveUp"
length = 0.5
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
"update": 1,
"values": [15, 16, 17, 18, 19]
}
[sub_resource type="Animation" id="Animation_mp212"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Sprite2D:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [0]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_uuf00"]
_data = {
"Idle": SubResource("Animation_6br4g"),
"MoveDown": SubResource("Animation_olc18"),
"MoveLeft": SubResource("Animation_l8j6b"),
"MoveRight": SubResource("Animation_agj62"),
"MoveUp": SubResource("Animation_45lfy"),
"RESET": SubResource("Animation_mp212")
}
[node name="Bunny" type="CharacterBody2D" node_paths=PackedStringArray("animation_player", "agent")]
[node name="Bunny" type="CharacterBody2D" node_paths=PackedStringArray("agent")]
collision_layer = 4
collision_mask = 15
script = ExtResource("1_1kj2b")
animation_player = NodePath("BunnyAnimator")
agent = NodePath("NavigationAgent")
[node name="Sprite2D" type="Sprite2D" parent="."]
@ -142,10 +33,5 @@ collision_mask = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource("CircleShape2D_itvjj")
[node name="BunnyAnimator" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_uuf00")
}
[connection signal="body_entered" from="Area2D" to="." method="_on_collision"]
[connection signal="body_exited" from="Area2D" to="." method="_of_collision"]

File diff suppressed because one or more lines are too long

View file

@ -1,7 +1,6 @@
extends CharacterBody2D
class_name Bunny
@export var animation_player : AnimationPlayer
@export var min_distance_to_player := 80.0
@export var max_distance_to_player := 800.0
@export var agent : NavigationAgent2D
@ -34,12 +33,9 @@ func _physics_process(delta):
dir = self.global_position.direction_to(next_location).normalized()
if self.global_position.distance_to(player.global_position) > min_distance_to_player:
self.velocity = dir * delta * 60 * speed
update_animation()
if delta > 0.5:
print(delta)
move_and_slide()
else:
animation_player.stop()
pass
func _on_collision(body):
@ -68,23 +64,8 @@ func sub_on_death(callback : Callable):
on_death_callbacks.push_front(callback)
pass
func update_animation():
match self.velocity:
Vector2.ZERO: animation_player.play("Idle")
_: handle_diagonal_animations(self.velocity)
pass
func handle_diagonal_animations(dir : Vector2):
var left_dot = Vector2.LEFT.dot(dir)
var right_dot = Vector2.RIGHT.dot(dir)
var up_dot = Vector2.UP.dot(dir)
var down_dot = Vector2.DOWN.dot(dir)
var max_dot = minf(left_dot, minf(right_dot, minf(up_dot, down_dot)))
match max_dot:
left_dot: animation_player.play("MoveLeft")
right_dot: animation_player.play("MoveRight")
up_dot: animation_player.play("MoveUp")
down_dot: animation_player.play("MoveDown")
pass