Reorganize file structure of project
This commit is contained in:
33
Entities/Characters/Animals/Chicken/Scripts/npc_chicken.gd
Normal file
33
Entities/Characters/Animals/Chicken/Scripts/npc_chicken.gd
Normal file
@@ -0,0 +1,33 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
enum States {
|
||||
IDLE,
|
||||
PECKING
|
||||
}
|
||||
|
||||
@onready var animated_sprite_2d: AnimatedSprite2D = $AnimatedSprite2D
|
||||
|
||||
var current_state := States.IDLE
|
||||
var pecking_sched := randf_range(8.0, 25.0)
|
||||
var pecking_timer := 0.0
|
||||
|
||||
func _ready() -> void:
|
||||
_print_sched()
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if current_state == States.IDLE:
|
||||
pecking_timer += delta
|
||||
if pecking_timer >= pecking_sched:
|
||||
current_state = States.PECKING
|
||||
animated_sprite_2d.play("pecking")
|
||||
await animated_sprite_2d.animation_finished
|
||||
animated_sprite_2d.play("idle")
|
||||
pecking_sched = randf_range(8.0, 25.0)
|
||||
pecking_timer = 0
|
||||
current_state = States.IDLE
|
||||
_print_sched()
|
||||
|
||||
|
||||
func _print_sched() -> void:
|
||||
print("%s Pecking Schedule: %f" % [name, pecking_sched])
|
||||
@@ -0,0 +1 @@
|
||||
uid://c5pt6iroi01si
|
||||
99
Entities/Characters/Animals/Chicken/npc_chicken.tscn
Normal file
99
Entities/Characters/Animals/Chicken/npc_chicken.tscn
Normal file
@@ -0,0 +1,99 @@
|
||||
[gd_scene format=3 uid="uid://clqfyxjtn67m"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c5pt6iroi01si" path="res://Entities/Characters/Animals/Chicken/Scripts/npc_chicken.gd" id="1_etrql"]
|
||||
[ext_resource type="Texture2D" uid="uid://d4lf74neoqf4p" path="res://Assets/Spritesheets/Animals/Chickens/Chicken_01.png" id="1_hjr72"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_etrql"]
|
||||
atlas = ExtResource("1_hjr72")
|
||||
region = Rect2(0, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_cps5e"]
|
||||
atlas = ExtResource("1_hjr72")
|
||||
region = Rect2(32, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_hjr72"]
|
||||
atlas = ExtResource("1_hjr72")
|
||||
region = Rect2(0, 64, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_hgb1c"]
|
||||
atlas = ExtResource("1_hjr72")
|
||||
region = Rect2(32, 64, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_b7crd"]
|
||||
atlas = ExtResource("1_hjr72")
|
||||
region = Rect2(64, 64, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4ggxf"]
|
||||
atlas = ExtResource("1_hjr72")
|
||||
region = Rect2(96, 64, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_m8e2q"]
|
||||
atlas = ExtResource("1_hjr72")
|
||||
region = Rect2(128, 64, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_myiu2"]
|
||||
atlas = ExtResource("1_hjr72")
|
||||
region = Rect2(160, 64, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wmbj4"]
|
||||
atlas = ExtResource("1_hjr72")
|
||||
region = Rect2(192, 64, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_t08bh"]
|
||||
atlas = ExtResource("1_hjr72")
|
||||
region = Rect2(224, 64, 32, 32)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_hgb1c"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_etrql")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_cps5e")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle",
|
||||
"speed": 2.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_hjr72")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_hgb1c")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_b7crd")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_4ggxf")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_m8e2q")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_myiu2")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_wmbj4")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_t08bh")
|
||||
}],
|
||||
"loop": false,
|
||||
"name": &"pecking",
|
||||
"speed": 8.0
|
||||
}]
|
||||
|
||||
[node name="Npc Chicken" type="CharacterBody2D" unique_id=1839801182]
|
||||
y_sort_enabled = true
|
||||
script = ExtResource("1_etrql")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=1119508709]
|
||||
y_sort_enabled = true
|
||||
position = Vector2(0, 6)
|
||||
sprite_frames = SubResource("SpriteFrames_hgb1c")
|
||||
animation = &"pecking"
|
||||
autoplay = "idle"
|
||||
offset = Vector2(0, -6)
|
||||
32
Entities/Characters/Animals/Frog/npc_frog.tscn
Normal file
32
Entities/Characters/Animals/Frog/npc_frog.tscn
Normal file
@@ -0,0 +1,32 @@
|
||||
[gd_scene format=3 uid="uid://c2p8fteeqyikf"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://ksgfv6hgw8i" path="res://Assets/Spritesheets/Animals/Frogs/Frog_01.png" id="1_rggf3"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_xdptu"]
|
||||
atlas = ExtResource("1_rggf3")
|
||||
region = Rect2(0, 0, 32, 32)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4bqs7"]
|
||||
atlas = ExtResource("1_rggf3")
|
||||
region = Rect2(32, 0, 32, 32)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_ui74g"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 3.0,
|
||||
"texture": SubResource("AtlasTexture_xdptu")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_4bqs7")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"default",
|
||||
"speed": 2.0
|
||||
}]
|
||||
|
||||
[node name="Npc Frog" type="CharacterBody2D" unique_id=1908167002]
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=1739011570]
|
||||
sprite_frames = SubResource("SpriteFrames_ui74g")
|
||||
autoplay = "default"
|
||||
frame_progress = 0.9973062
|
||||
Reference in New Issue
Block a user