add enemy slime
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
[gd_scene load_steps=14 format=4 uid="uid://cy3dg66pt8abt"]
|
[gd_scene load_steps=15 format=4 uid="uid://cy3dg66pt8abt"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://3wumh6kpw3ai" path="res://scenes/player.tscn" id="1_uwrxv"]
|
[ext_resource type="PackedScene" uid="uid://3wumh6kpw3ai" path="res://scenes/player.tscn" id="1_uwrxv"]
|
||||||
[ext_resource type="Texture2D" uid="uid://0syymy7ijylx" path="res://assets/sprites/world_tileset.png" id="1_yqjtg"]
|
[ext_resource type="Texture2D" uid="uid://0syymy7ijylx" path="res://assets/sprites/world_tileset.png" id="1_yqjtg"]
|
||||||
[ext_resource type="PackedScene" uid="uid://xacwq0rohthg" path="res://scenes/platform.tscn" id="3_lnu2h"]
|
[ext_resource type="PackedScene" uid="uid://xacwq0rohthg" path="res://scenes/platform.tscn" id="3_lnu2h"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dotk5aceo1m0k" path="res://scenes/coin.tscn" id="4_lbhrr"]
|
[ext_resource type="PackedScene" uid="uid://dotk5aceo1m0k" path="res://scenes/coin.tscn" id="4_lbhrr"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dpox5fa2pojpo" path="res://scenes/killzone.tscn" id="5_iywne"]
|
[ext_resource type="PackedScene" uid="uid://dpox5fa2pojpo" path="res://scenes/killzone.tscn" id="5_iywne"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bvw0afyajdmht" path="res://scenes/slime.tscn" id="6_p57ef"]
|
||||||
|
|
||||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_iywne"]
|
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_iywne"]
|
||||||
texture = ExtResource("1_yqjtg")
|
texture = ExtResource("1_yqjtg")
|
||||||
@@ -307,6 +308,21 @@ sources/0 = SubResource("TileSetAtlasSource_lnu2h")
|
|||||||
|
|
||||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_iywne"]
|
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_iywne"]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_lbhrr"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath(".:position")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(370, 69)]
|
||||||
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_lnu2h"]
|
[sub_resource type="Animation" id="Animation_lnu2h"]
|
||||||
resource_name = "move"
|
resource_name = "move"
|
||||||
length = 2.0
|
length = 2.0
|
||||||
@@ -324,21 +340,6 @@ tracks/0/keys = {
|
|||||||
"values": [Vector2(370, 69), Vector2(481, 69)]
|
"values": [Vector2(370, 69), Vector2(481, 69)]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_lbhrr"]
|
|
||||||
length = 0.001
|
|
||||||
tracks/0/type = "value"
|
|
||||||
tracks/0/imported = false
|
|
||||||
tracks/0/enabled = true
|
|
||||||
tracks/0/path = NodePath(".:position")
|
|
||||||
tracks/0/interp = 1
|
|
||||||
tracks/0/loop_wrap = true
|
|
||||||
tracks/0/keys = {
|
|
||||||
"times": PackedFloat32Array(0),
|
|
||||||
"transitions": PackedFloat32Array(1),
|
|
||||||
"update": 0,
|
|
||||||
"values": [Vector2(370, 69)]
|
|
||||||
}
|
|
||||||
|
|
||||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_iywne"]
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_iywne"]
|
||||||
_data = {
|
_data = {
|
||||||
&"RESET": SubResource("Animation_lbhrr"),
|
&"RESET": SubResource("Animation_lbhrr"),
|
||||||
@@ -418,3 +419,6 @@ libraries = {
|
|||||||
&"": SubResource("AnimationLibrary_iywne")
|
&"": SubResource("AnimationLibrary_iywne")
|
||||||
}
|
}
|
||||||
autoplay = "move"
|
autoplay = "move"
|
||||||
|
|
||||||
|
[node name="Slime" parent="." instance=ExtResource("6_p57ef")]
|
||||||
|
position = Vector2(569, 96)
|
||||||
|
|||||||
67
scenes/slime.tscn
Normal file
67
scenes/slime.tscn
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
[gd_scene load_steps=10 format=3 uid="uid://bvw0afyajdmht"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://cxpc8xcf3r6rg" path="res://scripts/slime.gd" id="1_n6pvg"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://do7enjpf3pftb" path="res://assets/sprites/slime_green.png" id="1_p2gj0"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dpox5fa2pojpo" path="res://scenes/killzone.tscn" id="2_n6pvg"]
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_pjw23"]
|
||||||
|
atlas = ExtResource("1_p2gj0")
|
||||||
|
region = Rect2(0, 24, 24, 24)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_2npkn"]
|
||||||
|
atlas = ExtResource("1_p2gj0")
|
||||||
|
region = Rect2(24, 24, 24, 24)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_fd6lc"]
|
||||||
|
atlas = ExtResource("1_p2gj0")
|
||||||
|
region = Rect2(48, 24, 24, 24)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_gstla"]
|
||||||
|
atlas = ExtResource("1_p2gj0")
|
||||||
|
region = Rect2(72, 24, 24, 24)
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_v5wyi"]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_pjw23")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_2npkn")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_fd6lc")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_gstla")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"default",
|
||||||
|
"speed": 7.0
|
||||||
|
}]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_0l8pv"]
|
||||||
|
size = Vector2(10, 13)
|
||||||
|
|
||||||
|
[node name="Slime" type="Node2D"]
|
||||||
|
script = ExtResource("1_n6pvg")
|
||||||
|
|
||||||
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||||
|
position = Vector2(0, -12)
|
||||||
|
sprite_frames = SubResource("SpriteFrames_v5wyi")
|
||||||
|
autoplay = "default"
|
||||||
|
frame_progress = 0.45857617
|
||||||
|
|
||||||
|
[node name="Killzone" parent="." instance=ExtResource("2_n6pvg")]
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Killzone"]
|
||||||
|
position = Vector2(0, -6.5)
|
||||||
|
shape = SubResource("RectangleShape2D_0l8pv")
|
||||||
|
|
||||||
|
[node name="RayCastRight" type="RayCast2D" parent="."]
|
||||||
|
position = Vector2(0, -6)
|
||||||
|
target_position = Vector2(8, 0)
|
||||||
|
|
||||||
|
[node name="RayCastLeft" type="RayCast2D" parent="."]
|
||||||
|
position = Vector2(0, -6)
|
||||||
|
target_position = Vector2(-9, 0)
|
||||||
21
scripts/slime.gd
Normal file
21
scripts/slime.gd
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
extends Node2D
|
||||||
|
|
||||||
|
@export var speed = 60
|
||||||
|
|
||||||
|
var direction = 1
|
||||||
|
|
||||||
|
@onready var ray_cast_right: RayCast2D = $RayCastRight
|
||||||
|
@onready var ray_cast_left: RayCast2D = $RayCastLeft
|
||||||
|
@onready var animated_sprite: AnimatedSprite2D = $AnimatedSprite2D
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if ray_cast_right.is_colliding():
|
||||||
|
direction = -1
|
||||||
|
animated_sprite.flip_h = true
|
||||||
|
|
||||||
|
if ray_cast_left.is_colliding():
|
||||||
|
direction = 1
|
||||||
|
animated_sprite.flip_h = false
|
||||||
|
|
||||||
|
position.x += direction * speed * delta
|
||||||
1
scripts/slime.gd.uid
Normal file
1
scripts/slime.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://cxpc8xcf3r6rg
|
||||||
Reference in New Issue
Block a user