init
This commit is contained in:
commit
f389e4e807
186 changed files with 10853 additions and 0 deletions
BIN
creatures/birb/birb.aseprite
Normal file
BIN
creatures/birb/birb.aseprite
Normal file
Binary file not shown.
21
creatures/birb/birb.aseprite.import
Normal file
21
creatures/birb/birb.aseprite.import
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
[remap]
|
||||
|
||||
importer="aseprite_wizard.plugin.spriteframes"
|
||||
type="SpriteFrames"
|
||||
uid="uid://cyf7ij04grglc"
|
||||
path="res://.godot/imported/birb.aseprite-08ecd7f619e0f36def567cf6f5194cc3.res"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://creatures/birb/birb.aseprite"
|
||||
dest_files=["res://.godot/imported/birb.aseprite-08ecd7f619e0f36def567cf6f5194cc3.res"]
|
||||
|
||||
[params]
|
||||
|
||||
layer/exclude_layers_pattern=""
|
||||
layer/only_visible_layers=false
|
||||
sheet/sheet_type="packed"
|
||||
sheet/sheet_columns=12
|
||||
sheet/frame_padding=0
|
||||
sheet/scale=1
|
||||
animation/round_fps=true
|
||||
40
creatures/birb/birb.gd
Normal file
40
creatures/birb/birb.gd
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
extends CharacterBody2D
|
||||
|
||||
@export var speed: float = 60.0
|
||||
@export var attack_distance: float = 32.0
|
||||
@export var think_time: float = 0.2
|
||||
|
||||
var _target: Player = null
|
||||
var _time_thought: float = 0.0
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
_time_thought += delta
|
||||
if _time_thought >= think_time:
|
||||
_time_thought -= think_time
|
||||
if _target:
|
||||
var x_difference: float = _target.position.x - position.x
|
||||
var distance: float = abs(x_difference)
|
||||
if abs(distance - attack_distance) > speed * think_time:
|
||||
var is_too_far_sgn: float = sign(distance - attack_distance)
|
||||
velocity.x = sign(x_difference) * is_too_far_sgn * speed
|
||||
else:
|
||||
velocity.x = 0
|
||||
$AnimatedSprite2D.flip_h = x_difference < 0
|
||||
else:
|
||||
velocity.x = 0
|
||||
|
||||
if not is_on_floor():
|
||||
velocity += get_gravity() * delta
|
||||
|
||||
move_and_slide()
|
||||
|
||||
|
||||
func _on_detection_body_entered(body: Node2D) -> void:
|
||||
if body is Player:
|
||||
_target = body
|
||||
|
||||
|
||||
func _on_chase_body_exited(body: Node2D) -> void:
|
||||
if body == _target:
|
||||
_target = null
|
||||
1
creatures/birb/birb.gd.uid
Normal file
1
creatures/birb/birb.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c7744j3mcamav
|
||||
49
creatures/birb/birb.tscn
Normal file
49
creatures/birb/birb.tscn
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
[gd_scene format=3 uid="uid://bosbrhc3oprau"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c7744j3mcamav" path="res://creatures/birb/birb.gd" id="1_lyo8d"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://cyf7ij04grglc" path="res://creatures/birb/birb.aseprite" id="2_ba6cv"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_feb5d"]
|
||||
radius = 5.0
|
||||
height = 14.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_lyo8d"]
|
||||
radius = 52.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_ba6cv"]
|
||||
radius = 110.0
|
||||
|
||||
[node name="Birb" type="CharacterBody2D" unique_id=428810294]
|
||||
collision_layer = 4
|
||||
script = ExtResource("1_lyo8d")
|
||||
metadata/_edit_group_ = true
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." unique_id=581143480]
|
||||
sprite_frames = ExtResource("2_ba6cv")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="." unique_id=1744954023]
|
||||
position = Vector2(0, 1)
|
||||
shape = SubResource("CapsuleShape2D_feb5d")
|
||||
|
||||
[node name="NavigationAgent2D" type="NavigationAgent2D" parent="." unique_id=1295779953]
|
||||
|
||||
[node name="Detection" type="Area2D" parent="." unique_id=151830843]
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
monitorable = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Detection" unique_id=1217467707]
|
||||
shape = SubResource("CircleShape2D_lyo8d")
|
||||
debug_color = Color(0, 0.6, 0.69803923, 0.16862746)
|
||||
|
||||
[node name="Chase" type="Area2D" parent="." unique_id=172000915]
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
monitorable = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Chase" unique_id=567870323]
|
||||
shape = SubResource("CircleShape2D_ba6cv")
|
||||
debug_color = Color(0, 0.6, 0.69803923, 0)
|
||||
|
||||
[connection signal="body_entered" from="Detection" to="." method="_on_detection_body_entered"]
|
||||
[connection signal="body_exited" from="Chase" to="." method="_on_chase_body_exited"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue