Added bat enemies with stats and better touch controls

This commit is contained in:
Alan Youngblood
2024-11-10 14:05:00 -05:00
parent f398efdcff
commit 6555ebe4c2
16 changed files with 141 additions and 4 deletions

View File

@ -0,0 +1,17 @@
extends KinematicBody2D
var knockback = Vector2.ZERO
onready var stats = $Stats
func _physics_process(delta):
knockback = knockback.move_toward(Vector2.ZERO, 200 * delta)
knockback = move_and_slide(knockback)
func _on_Hurtbox_area_entered(area):
stats.health -= area.damage
knockback = area.knockback_vector * 120
#queue_free() # Replace with function body.
func _on_Stats_no_health():
queue_free()

View File

@ -0,0 +1,74 @@
[gd_scene load_steps=14 format=2]
[ext_resource path="res://Enemies/Bat.png" type="Texture" id=1]
[ext_resource path="res://Shadows/SmallShadow.png" type="Texture" id=2]
[ext_resource path="res://Overlap/Hurtbox.tscn" type="PackedScene" id=3]
[ext_resource path="res://Enemies/Bat.gd" type="Script" id=4]
[ext_resource path="res://Stats.tscn" type="PackedScene" id=5]
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 0, 0, 16, 24 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 1 )
region = Rect2( 16, 0, 16, 24 )
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 1 )
region = Rect2( 32, 0, 16, 24 )
[sub_resource type="AtlasTexture" id=4]
atlas = ExtResource( 1 )
region = Rect2( 48, 0, 16, 24 )
[sub_resource type="AtlasTexture" id=5]
atlas = ExtResource( 1 )
region = Rect2( 64, 0, 16, 24 )
[sub_resource type="SpriteFrames" id=6]
animations = [ {
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ) ],
"loop": true,
"name": "Fly",
"speed": 10.0
} ]
[sub_resource type="CircleShape2D" id=7]
radius = 4.12311
[sub_resource type="CapsuleShape2D" id=8]
radius = 7.0
height = 6.0
[node name="Bat" type="KinematicBody2D"]
collision_layer = 16
script = ExtResource( 4 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
frames = SubResource( 6 )
animation = "Fly"
frame = 4
playing = true
offset = Vector2( 0, -12 )
[node name="ShadowSprite" type="Sprite" parent="."]
texture = ExtResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 7 )
[node name="Hurtbox" parent="." instance=ExtResource( 3 )]
collision_layer = 8
[node name="CollisionShape2D" parent="Hurtbox" index="0"]
position = Vector2( 0, -14 )
shape = SubResource( 8 )
[node name="Stats" parent="." instance=ExtResource( 5 )]
max_health = 2
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
[connection signal="no_health" from="Stats" to="." method="_on_Stats_no_health"]
[editable path="Hurtbox"]