Add new scene for enemies

This commit is contained in:
James Skemp 2023-10-10 20:05:07 -05:00
parent 9fe331f651
commit c396e065b1
2 changed files with 79 additions and 0 deletions

11
mob.gd Normal file
View File

@ -0,0 +1,11 @@
extends RigidBody2D
# Called when the node enters the scene tree for the first time.
func _ready():
var mob_types = $AnimatedSprite2D.sprite_frames.get_animation_names()
$AnimatedSprite2D.play(mob_types[randi() % mob_types.size()])
func _on_visible_on_screen_notifier_2d_screen_exited():
queue_free()

68
mob.tscn Normal file
View File

@ -0,0 +1,68 @@
[gd_scene load_steps=10 format=3 uid="uid://bco33bjwfjfk4"]
[ext_resource type="Script" path="res://mob.gd" id="1_ko801"]
[ext_resource type="Texture2D" uid="uid://b17hlggrnubsd" path="res://art/enemyFlyingAlt_1.png" id="1_rv6ba"]
[ext_resource type="Texture2D" uid="uid://bfb8tsbfkuwbi" path="res://art/enemyFlyingAlt_2.png" id="2_blwfb"]
[ext_resource type="Texture2D" uid="uid://d0oyetwn5opqo" path="res://art/enemySwimming_1.png" id="3_m71rh"]
[ext_resource type="Texture2D" uid="uid://ceco6gu5matva" path="res://art/enemySwimming_2.png" id="4_j6qkt"]
[ext_resource type="Texture2D" uid="uid://pylpmb0f16re" path="res://art/enemyWalking_1.png" id="5_5h368"]
[ext_resource type="Texture2D" uid="uid://dca0bhlcdvy2j" path="res://art/enemyWalking_2.png" id="6_jxtn0"]
[sub_resource type="SpriteFrames" id="SpriteFrames_mldxg"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": ExtResource("1_rv6ba")
}, {
"duration": 1.0,
"texture": ExtResource("2_blwfb")
}],
"loop": true,
"name": &"fly",
"speed": 3.0
}, {
"frames": [{
"duration": 1.0,
"texture": ExtResource("3_m71rh")
}, {
"duration": 1.0,
"texture": ExtResource("4_j6qkt")
}],
"loop": true,
"name": &"swim",
"speed": 3.0
}, {
"frames": [{
"duration": 1.0,
"texture": ExtResource("5_5h368")
}, {
"duration": 1.0,
"texture": ExtResource("6_jxtn0")
}],
"loop": true,
"name": &"walk",
"speed": 3.0
}]
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_h8rqe"]
radius = 35.0
height = 100.0
[node name="Mob" type="RigidBody2D"]
collision_mask = 0
gravity_scale = 0.0
script = ExtResource("1_ko801")
metadata/_edit_group_ = true
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
scale = Vector2(0.75, 0.75)
sprite_frames = SubResource("SpriteFrames_mldxg")
animation = &"fly"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
rotation = 1.5708
shape = SubResource("CapsuleShape2D_h8rqe")
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."]
[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"]