Slime with tracking
This commit is contained in:
parent
5a16c33249
commit
0d9fa06557
6 changed files with 195 additions and 1 deletions
34
ressources/images/blob-1.png.png.import
Normal file
34
ressources/images/blob-1.png.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://devrwnq1oj3qv"
|
||||||
|
path="res://.godot/imported/blob-1.png.png-d6117acd2391c64f472af8433c684912.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://ressources/images/blob-1.png.png"
|
||||||
|
dest_files=["res://.godot/imported/blob-1.png.png-d6117acd2391c64f472af8433c684912.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
34
ressources/images/blob-2-4.png.png.import
Normal file
34
ressources/images/blob-2-4.png.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://b0cua5ecp7bfw"
|
||||||
|
path="res://.godot/imported/blob-2-4.png.png-808d98b15f20529346c9c4c50162a975.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://ressources/images/blob-2-4.png.png"
|
||||||
|
dest_files=["res://.godot/imported/blob-2-4.png.png-808d98b15f20529346c9c4c50162a975.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
34
ressources/images/blob-3.png.png.import
Normal file
34
ressources/images/blob-3.png.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://cc1kqgdbwm1dh"
|
||||||
|
path="res://.godot/imported/blob-3.png.png-902563b57bcfa6ab9c15d19bab7245bc.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://ressources/images/blob-3.png.png"
|
||||||
|
dest_files=["res://.godot/imported/blob-3.png.png-902563b57bcfa6ab9c15d19bab7245bc.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
|
@ -1,7 +1,8 @@
|
||||||
[gd_scene load_steps=7 format=3 uid="uid://durhes43gex7a"]
|
[gd_scene load_steps=8 format=3 uid="uid://durhes43gex7a"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://c7bfiw54rvaq2" path="res://scenes/player_melodie.tscn" id="1_cl1wt"]
|
[ext_resource type="PackedScene" uid="uid://c7bfiw54rvaq2" path="res://scenes/player_melodie.tscn" id="1_cl1wt"]
|
||||||
[ext_resource type="Texture2D" uid="uid://ky4e7158gqf6" path="res://ressources/images/cgj_default_tile.svg" id="2_torsx"]
|
[ext_resource type="Texture2D" uid="uid://ky4e7158gqf6" path="res://ressources/images/cgj_default_tile.svg" id="2_torsx"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cyvqa6g64cw37" path="res://scenes/enemies/slime.tscn" id="3_04ip2"]
|
||||||
|
|
||||||
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_1c4te"]
|
[sub_resource type="WorldBoundaryShape2D" id="WorldBoundaryShape2D_1c4te"]
|
||||||
normal = Vector2(0, 1)
|
normal = Vector2(0, 1)
|
||||||
|
@ -48,3 +49,6 @@ shape = SubResource("WorldBoundaryShape2D_ia1hi")
|
||||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
[node name="Camera2D" type="Camera2D" parent="CanvasLayer"]
|
[node name="Camera2D" type="Camera2D" parent="CanvasLayer"]
|
||||||
|
|
||||||
|
[node name="Slime" parent="." instance=ExtResource("3_04ip2")]
|
||||||
|
position = Vector2(-448, 205)
|
||||||
|
|
34
scenes/enemies/slime.gd
Normal file
34
scenes/enemies/slime.gd
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
extends CharacterBody2D
|
||||||
|
|
||||||
|
|
||||||
|
const SPEED = 100.0
|
||||||
|
var old_pos = Vector2.ZERO
|
||||||
|
@onready var player = get_parent().get_node("Player_Melodie")
|
||||||
|
var player_position = Vector2.ZERO
|
||||||
|
var target_position = Vector2.ZERO
|
||||||
|
|
||||||
|
var move_timer = 2
|
||||||
|
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
player_position = player.position
|
||||||
|
target_position = (player_position - position).normalized()
|
||||||
|
move_and_slide()
|
||||||
|
for i in get_slide_collision_count():
|
||||||
|
var collision = get_slide_collision(i)
|
||||||
|
print("Collided with: ", collision.get_collider().name)
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
var direction : Vector2
|
||||||
|
if move_timer > 0 :
|
||||||
|
move_timer -= delta
|
||||||
|
direction = Vector2.ZERO
|
||||||
|
else :
|
||||||
|
direction = target_position
|
||||||
|
|
||||||
|
if old_pos == position :
|
||||||
|
$AnimatedSprite2D.play("idle")
|
||||||
|
else :
|
||||||
|
$AnimatedSprite2D.play("walk_down")
|
||||||
|
|
||||||
|
velocity = direction * SPEED
|
54
scenes/enemies/slime.tscn
Normal file
54
scenes/enemies/slime.tscn
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
[gd_scene load_steps=7 format=3 uid="uid://cyvqa6g64cw37"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scenes/enemies/slime.gd" id="1_hnufy"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://devrwnq1oj3qv" path="res://ressources/images/blob-1.png.png" id="1_n4mgf"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://b0cua5ecp7bfw" path="res://ressources/images/blob-2-4.png.png" id="2_w8gqg"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cc1kqgdbwm1dh" path="res://ressources/images/blob-3.png.png" id="3_pwpfc"]
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_qfla8"]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("1_n4mgf")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("2_w8gqg")
|
||||||
|
}],
|
||||||
|
"loop": false,
|
||||||
|
"name": &"idle",
|
||||||
|
"speed": 3.0
|
||||||
|
}, {
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("1_n4mgf")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("2_w8gqg")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("3_pwpfc")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("2_w8gqg")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"walk_down",
|
||||||
|
"speed": 3.0
|
||||||
|
}]
|
||||||
|
|
||||||
|
[sub_resource type="CircleShape2D" id="CircleShape2D_bokrm"]
|
||||||
|
radius = 20.0
|
||||||
|
|
||||||
|
[node name="Slime" type="CharacterBody2D"]
|
||||||
|
script = ExtResource("1_hnufy")
|
||||||
|
|
||||||
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||||
|
position = Vector2(-3, 12)
|
||||||
|
sprite_frames = SubResource("SpriteFrames_qfla8")
|
||||||
|
animation = &"idle"
|
||||||
|
frame = 1
|
||||||
|
frame_progress = 1.0
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
shape = SubResource("CircleShape2D_bokrm")
|
||||||
|
disabled = true
|
Loading…
Add table
Reference in a new issue