Add basic slug which currently just approaches the player
This commit is contained in:
parent
9df0fe6c86
commit
880481c4b3
44
characters/pests/Slug.gd
Normal file
44
characters/pests/Slug.gd
Normal file
@ -0,0 +1,44 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
const SPEED := 50
|
||||
|
||||
var _velocity := Vector2.ZERO
|
||||
|
||||
onready var _agent: NavigationAgent2D = $NavigationAgent2D
|
||||
|
||||
var target: Node2D = null
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
call_deferred("_find_target")
|
||||
|
||||
func _find_target() -> void:
|
||||
target = find_parent("YSort").get_node("Player")
|
||||
_agent.set_target_location(target.global_position)
|
||||
|
||||
func _at_target() -> void:
|
||||
print("at target")
|
||||
pass
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if target == null:
|
||||
if $AnimatedSprite.animation != "still":
|
||||
$AnimatedSprite.play("still")
|
||||
return
|
||||
|
||||
var target_velocity = Vector2.ZERO
|
||||
if not _agent.is_navigation_finished():
|
||||
var direction_towards_travel := global_position.direction_to(_agent.get_next_location())
|
||||
target_velocity = direction_towards_travel * SPEED
|
||||
|
||||
_velocity += (target_velocity - _velocity) * delta * 2.0
|
||||
|
||||
if _velocity.length_squared() > 16:
|
||||
if $AnimatedSprite.animation != "crawl":
|
||||
$AnimatedSprite.play("crawl")
|
||||
else:
|
||||
if $AnimatedSprite.animation != "still":
|
||||
$AnimatedSprite.play("still")
|
||||
|
||||
#print(_velocity)
|
||||
var _vel := move_and_slide(_velocity)
|
47
characters/pests/Slug.tscn
Normal file
47
characters/pests/Slug.tscn
Normal file
@ -0,0 +1,47 @@
|
||||
[gd_scene load_steps=10 format=2]
|
||||
|
||||
[ext_resource path="res://characters/pests/slug_frame0005.png" type="Texture" id=1]
|
||||
[ext_resource path="res://characters/pests/slug_frame0004.png" type="Texture" id=2]
|
||||
[ext_resource path="res://characters/pests/slug_frame0003.png" type="Texture" id=3]
|
||||
[ext_resource path="res://characters/pests/slug_frame0000.png" type="Texture" id=4]
|
||||
[ext_resource path="res://characters/pests/slug_frame0002.png" type="Texture" id=5]
|
||||
[ext_resource path="res://characters/pests/slug_frame0001.png" type="Texture" id=6]
|
||||
[ext_resource path="res://characters/pests/Slug.gd" type="Script" id=7]
|
||||
|
||||
[sub_resource type="SpriteFrames" id=1]
|
||||
animations = [ {
|
||||
"frames": [ ExtResource( 4 ), ExtResource( 6 ), ExtResource( 5 ), ExtResource( 3 ), ExtResource( 2 ), ExtResource( 1 ) ],
|
||||
"loop": true,
|
||||
"name": "crawl",
|
||||
"speed": 5.0
|
||||
}, {
|
||||
"frames": [ ExtResource( 4 ) ],
|
||||
"loop": true,
|
||||
"name": "still",
|
||||
"speed": 5.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=2]
|
||||
radius = 6.0
|
||||
height = 40.0
|
||||
|
||||
[node name="Slug" type="KinematicBody2D"]
|
||||
collision_layer = 0
|
||||
collision_mask = 0
|
||||
script = ExtResource( 7 )
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
position = Vector2( 0, -19 )
|
||||
scale = Vector2( 0.5, 0.5 )
|
||||
frames = SubResource( 1 )
|
||||
animation = "crawl"
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2( 1, -7 )
|
||||
rotation = 1.5708
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="NavigationAgent2D" type="NavigationAgent2D" parent="."]
|
||||
path_desired_distance = 8.0
|
||||
target_desired_distance = 12.0
|
||||
path_max_distance = 64.0
|
BIN
characters/pests/slug.kra
(Stored with Git LFS)
Normal file
BIN
characters/pests/slug.kra
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
characters/pests/slug_anim.kra
(Stored with Git LFS)
Normal file
BIN
characters/pests/slug_anim.kra
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
characters/pests/slug_anim~000.kra
(Stored with Git LFS)
Normal file
BIN
characters/pests/slug_anim~000.kra
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
characters/pests/slug_frame0000.png
(Stored with Git LFS)
Normal file
BIN
characters/pests/slug_frame0000.png
(Stored with Git LFS)
Normal file
Binary file not shown.
35
characters/pests/slug_frame0000.png.import
Normal file
35
characters/pests/slug_frame0000.png.import
Normal file
@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/slug_frame0000.png-4554be2c95b61ee8aefd1ef0f3e37490.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://characters/pests/slug_frame0000.png"
|
||||
dest_files=[ "res://.import/slug_frame0000.png-4554be2c95b61ee8aefd1ef0f3e37490.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
BIN
characters/pests/slug_frame0001.png
(Stored with Git LFS)
Normal file
BIN
characters/pests/slug_frame0001.png
(Stored with Git LFS)
Normal file
Binary file not shown.
35
characters/pests/slug_frame0001.png.import
Normal file
35
characters/pests/slug_frame0001.png.import
Normal file
@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/slug_frame0001.png-4b0d20e6d8c9d01ab554797cea35467f.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://characters/pests/slug_frame0001.png"
|
||||
dest_files=[ "res://.import/slug_frame0001.png-4b0d20e6d8c9d01ab554797cea35467f.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
BIN
characters/pests/slug_frame0002.png
(Stored with Git LFS)
Normal file
BIN
characters/pests/slug_frame0002.png
(Stored with Git LFS)
Normal file
Binary file not shown.
35
characters/pests/slug_frame0002.png.import
Normal file
35
characters/pests/slug_frame0002.png.import
Normal file
@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/slug_frame0002.png-afbbb401f066c0394f879eb57eb364b0.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://characters/pests/slug_frame0002.png"
|
||||
dest_files=[ "res://.import/slug_frame0002.png-afbbb401f066c0394f879eb57eb364b0.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
BIN
characters/pests/slug_frame0003.png
(Stored with Git LFS)
Normal file
BIN
characters/pests/slug_frame0003.png
(Stored with Git LFS)
Normal file
Binary file not shown.
35
characters/pests/slug_frame0003.png.import
Normal file
35
characters/pests/slug_frame0003.png.import
Normal file
@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/slug_frame0003.png-2c0a41a6d8d411d6b8b3d35db8a1d173.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://characters/pests/slug_frame0003.png"
|
||||
dest_files=[ "res://.import/slug_frame0003.png-2c0a41a6d8d411d6b8b3d35db8a1d173.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
BIN
characters/pests/slug_frame0004.png
(Stored with Git LFS)
Normal file
BIN
characters/pests/slug_frame0004.png
(Stored with Git LFS)
Normal file
Binary file not shown.
35
characters/pests/slug_frame0004.png.import
Normal file
35
characters/pests/slug_frame0004.png.import
Normal file
@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/slug_frame0004.png-158aac7e5467feab60b354c84585ef91.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://characters/pests/slug_frame0004.png"
|
||||
dest_files=[ "res://.import/slug_frame0004.png-158aac7e5467feab60b354c84585ef91.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
BIN
characters/pests/slug_frame0005.png
(Stored with Git LFS)
Normal file
BIN
characters/pests/slug_frame0005.png
(Stored with Git LFS)
Normal file
Binary file not shown.
35
characters/pests/slug_frame0005.png.import
Normal file
35
characters/pests/slug_frame0005.png.import
Normal file
@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/slug_frame0005.png-24788f4b796ec108ce8836f392f04005.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://characters/pests/slug_frame0005.png"
|
||||
dest_files=[ "res://.import/slug_frame0005.png-24788f4b796ec108ce8836f392f04005.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
13
levels/Level0A.gd
Normal file
13
levels/Level0A.gd
Normal file
@ -0,0 +1,13 @@
|
||||
extends Node2D
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a: int = 2
|
||||
# var b: String = "text"
|
||||
|
||||
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta: float) -> void:
|
||||
# pass
|
File diff suppressed because one or more lines are too long
@ -15,3 +15,7 @@ func _ready():
|
||||
var sch = $HudInner/Panel/Scheduler
|
||||
sch.postie_times = postie_times
|
||||
sch.days_on_this_level = num_days
|
||||
|
||||
var w2d: World2D = get_world_2d()
|
||||
# random place to put it, but needed to get our navigation working:
|
||||
Navigation2DServer.map_set_edge_connection_margin(w2d.navigation_map, 10.0)
|
||||
|
Loading…
Reference in New Issue
Block a user