fix: better vaccum caterpillar sprites, consistent caterpillar behaviour

This commit is contained in:
Jakob Feldmann 2023-10-03 21:16:46 +02:00
parent 522e472c4d
commit 12a7a3d76a
20 changed files with 549 additions and 442 deletions

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 692 B

View File

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Caterpilllar.png-f7385704d20b491d5205bc11eb188006.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/enemy/Caterpilllar.png"
dest_files=[ "res://.import/Caterpilllar.png-f7385704d20b491d5205bc11eb188006.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=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=false
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=false
svg/scale=1.0

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 604 B

After

Width:  |  Height:  |  Size: 703 B

View File

@ -9,6 +9,11 @@
config_version=4 config_version=4
_global_script_classes=[ { _global_script_classes=[ {
"base": "AudioStreamPlayer",
"class": "ACVoiceBox",
"language": "GDScript",
"path": "res://addons/ACVoicebox/ACVoicebox.gd"
}, {
"base": "KinematicBody2D", "base": "KinematicBody2D",
"class": "Actor", "class": "Actor",
"language": "GDScript", "language": "GDScript",
@ -90,6 +95,7 @@ _global_script_classes=[ {
"path": "res://src/StateMachines/StateMachine.gd" "path": "res://src/StateMachines/StateMachine.gd"
} ] } ]
_global_script_class_icons={ _global_script_class_icons={
"ACVoiceBox": "",
"Actor": "", "Actor": "",
"AudibleButton": "", "AudibleButton": "",
"AudibleCheckbox": "", "AudibleCheckbox": "",

View File

@ -4385,7 +4385,7 @@ texture = SubResource( 62 )
offset = Vector2( 1, 0 ) offset = Vector2( 1, 0 )
hframes = 6 hframes = 6
vframes = 6 vframes = 6
frame = 9 frame = 5
__meta__ = { __meta__ = {
"_editor_description_": "YXNlcHJpdGVfd2l6YXJkX2NvbmZpZwpwbGF5ZXJ8PUJsb2JieVNwcml0ZS9CbG9iYnltYXRpb25QbGF5ZXIKc291cmNlfD1yZXM6Ly9hc3NldHMvYmxvYmJ5L2Jsb2JieS1zcHJpdGVzaGVldHQuYXNlcHJpdGUKbGF5ZXJ8PUJsb2JieQpvcF9leHB8PUZhbHNlCm9fZm9sZGVyfD0Kb19uYW1lfD0Kb25seV92aXNpYmxlfD1GYWxzZQpvX2V4X3B8PQo=" "_editor_description_": "YXNlcHJpdGVfd2l6YXJkX2NvbmZpZwpwbGF5ZXJ8PUJsb2JieVNwcml0ZS9CbG9iYnltYXRpb25QbGF5ZXIKc291cmNlfD1yZXM6Ly9hc3NldHMvYmxvYmJ5L2Jsb2JieS1zcHJpdGVzaGVldHQuYXNlcHJpdGUKbGF5ZXJ8PUJsb2JieQpvcF9leHB8PUZhbHNlCm9fZm9sZGVyfD0Kb19uYW1lfD0Kb25seV92aXNpYmxlfD1GYWxzZQpvX2V4X3B8PQo="
} }

View File

@ -32,6 +32,7 @@ func execute_movement(delta: float) -> void:
# velocity # velocity
var v = Vector2(velocity.x * movement, 0) var v = Vector2(velocity.x * movement, 0)
time += delta time += delta
$AnimationPlayer.play("moving")
move_and_slide_with_snap( move_and_slide_with_snap(
v.rotated(rotation), snap.rotated(rotation), FLOOR_NORMAL, false, 4, PI, false v.rotated(rotation), snap.rotated(rotation), FLOOR_NORMAL, false, 4, PI, false
) )

View File

@ -1,6 +1,6 @@
[gd_scene load_steps=7 format=2] [gd_scene load_steps=8 format=2]
[ext_resource path="res://assets/enemy/enemy.png" type="Texture" id=1] [ext_resource path="res://assets/enemy/Caterpilllar.png" type="Texture" id=1]
[ext_resource path="res://src/Actors/Enemies/Caterpillar.gd" type="Script" id=2] [ext_resource path="res://src/Actors/Enemies/Caterpillar.gd" type="Script" id=2]
[ext_resource path="res://src/StateMachines/CaterpillarStateMachine.gd" type="Script" id=3] [ext_resource path="res://src/StateMachines/CaterpillarStateMachine.gd" type="Script" id=3]
@ -13,6 +13,23 @@ extents = Vector2( 15, 8.61814 )
[sub_resource type="RectangleShape2D" id=1] [sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 14.7108, 7.85442 ) extents = Vector2( 14.7108, 7.85442 )
[sub_resource type="Animation" id=4]
resource_name = "moving"
loop = true
step = 0.05
tracks/0/type = "value"
tracks/0/path = NodePath("enemy:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.25, 0.5, 0.75 ),
"transitions": PoolRealArray( 1, 1, 1, 1 ),
"update": 0,
"values": [ Vector2( 1, 1 ), Vector2( 1.05, 1 ), Vector2( 1.1, 1.05 ), Vector2( 1.05, 1.1 ) ]
}
[node name="Caterpillar" type="KinematicBody2D" groups=["harmful"]] [node name="Caterpillar" type="KinematicBody2D" groups=["harmful"]]
scale = Vector2( 0.747749, 0.572926 ) scale = Vector2( 0.747749, 0.572926 )
collision_layer = 2 collision_layer = 2
@ -21,11 +38,12 @@ collision/safe_margin = 0.001
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="enemy" type="Sprite" parent="."] [node name="enemy" type="Sprite" parent="."]
position = Vector2( 0, -1.90735e-06 ) position = Vector2( 0, -3.49085 )
scale = Vector2( 0.286789, 0.276348 ) scale = Vector2( 1.01, 1.02 )
texture = ExtResource( 1 ) texture = ExtResource( 1 )
[node name="VisibilityEnabler2D" type="VisibilityEnabler2D" parent="."] [node name="VisibilityEnabler2D" type="VisibilityEnabler2D" parent="."]
visible = false
position = Vector2( 1362.81, -0.138177 ) position = Vector2( 1362.81, -0.138177 )
scale = Vector2( 15.4865, 1.28502 ) scale = Vector2( 15.4865, 1.28502 )
rect = Rect2( -89, -10, 2, 20 ) rect = Rect2( -89, -10, 2, 20 )
@ -33,30 +51,35 @@ process_parent = true
physics_process_parent = true physics_process_parent = true
[node name="SlopeRaycastLeft" type="RayCast2D" parent="."] [node name="SlopeRaycastLeft" type="RayCast2D" parent="."]
visible = false
position = Vector2( -7.5, 12 ) position = Vector2( -7.5, 12 )
enabled = true enabled = true
cast_to = Vector2( 0, 2 ) cast_to = Vector2( 0, 2 )
collision_mask = 8 collision_mask = 8
[node name="SlopeRaycastRight" type="RayCast2D" parent="."] [node name="SlopeRaycastRight" type="RayCast2D" parent="."]
visible = false
position = Vector2( 7.5, 12 ) position = Vector2( 7.5, 12 )
enabled = true enabled = true
cast_to = Vector2( 0, 2 ) cast_to = Vector2( 0, 2 )
collision_mask = 8 collision_mask = 8
[node name="WallRaycastLeft" type="RayCast2D" parent="."] [node name="WallRaycastLeft" type="RayCast2D" parent="."]
visible = false
position = Vector2( -14.711, 11.5 ) position = Vector2( -14.711, 11.5 )
enabled = true enabled = true
cast_to = Vector2( -3, 0 ) cast_to = Vector2( -3, 0 )
collision_mask = 8 collision_mask = 8
[node name="WallRaycastRight" type="RayCast2D" parent="."] [node name="WallRaycastRight" type="RayCast2D" parent="."]
visible = false
position = Vector2( 14.711, 11.5 ) position = Vector2( 14.711, 11.5 )
enabled = true enabled = true
cast_to = Vector2( 3, 0 ) cast_to = Vector2( 3, 0 )
collision_mask = 8 collision_mask = 8
[node name="StompDetector" type="Area2D" parent="." groups=["weakpoint"]] [node name="StompDetector" type="Area2D" parent="." groups=["weakpoint"]]
visible = false
modulate = Color( 0, 0.0392157, 1, 1 ) modulate = Color( 0, 0.0392157, 1, 1 )
light_mask = 0 light_mask = 0
position = Vector2( 0, -6.44095 ) position = Vector2( 0, -6.44095 )
@ -66,26 +89,34 @@ monitorable = false
priority = 1.0 priority = 1.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="StompDetector"] [node name="CollisionShape2D" type="CollisionShape2D" parent="StompDetector"]
visible = false
position = Vector2( 0, -2.28618 ) position = Vector2( 0, -2.28618 )
shape = SubResource( 2 ) shape = SubResource( 2 )
[node name="EnemySkin" type="Area2D" parent="."] [node name="EnemySkin" type="Area2D" parent="."]
process_priority = -1 process_priority = -1
visible = false
collision_layer = 2 collision_layer = 2
collision_mask = 127 collision_mask = 127
input_pickable = false input_pickable = false
[node name="CollisionPolygon2D" type="CollisionShape2D" parent="EnemySkin"] [node name="CollisionPolygon2D" type="CollisionShape2D" parent="EnemySkin"]
visible = false
position = Vector2( 0, 3.49085 ) position = Vector2( 0, 3.49085 )
shape = SubResource( 3 ) shape = SubResource( 3 )
[node name="EnemyBody" type="CollisionShape2D" parent="."] [node name="EnemyBody" type="CollisionShape2D" parent="."]
visible = false
position = Vector2( -6.37697e-07, 4.36357 ) position = Vector2( -6.37697e-07, 4.36357 )
shape = SubResource( 1 ) shape = SubResource( 1 )
[node name="StateMachine" type="Node2D" parent="."] [node name="StateMachine" type="Node2D" parent="."]
visible = false
script = ExtResource( 3 ) script = ExtResource( 3 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/moving = SubResource( 4 )
[connection signal="body_entered" from="StompDetector" to="." method="_on_StompDetector_body_entered"] [connection signal="body_entered" from="StompDetector" to="." method="_on_StompDetector_body_entered"]
[connection signal="area_entered" from="EnemySkin" to="." method="_on_EnemySkin_area_entered"] [connection signal="area_entered" from="EnemySkin" to="." method="_on_EnemySkin_area_entered"]
[connection signal="body_entered" from="EnemySkin" to="." method="_on_EnemySkin_body_entered"] [connection signal="body_entered" from="EnemySkin" to="." method="_on_EnemySkin_body_entered"]

View File

@ -4,6 +4,7 @@ const PhysicsFunc = preload("res://src/Utilities/Physic/PhysicsFunc.gd")
export var invincible := false export var invincible := false
export var speed := 80 export var speed := 80
export var acceleration := 80 export var acceleration := 80
export var is_harmful := true
func _ready() -> void: func _ready() -> void:
$StompDetector.monitoring = !invincible $StompDetector.monitoring = !invincible
@ -22,8 +23,6 @@ func _physics_process(delta: float) -> void:
mass, delta) mass, delta)
velocity.y = move_and_slide(velocity, FLOOR_NORMAL).y velocity.y = move_and_slide(velocity, FLOOR_NORMAL).y
if player_entered_stomp:
$Sprite.frame = 1
# TODO Detects player over gaps # TODO Detects player over gaps
func player_on_floor_direction() -> float: func player_on_floor_direction() -> float:
@ -33,3 +32,43 @@ func player_on_floor_direction() -> float:
if collider.is_in_group("player"): if collider.is_in_group("player"):
return sign(collider.position.x - self.position.x) return sign(collider.position.x - self.position.x)
return 0.0 return 0.0
func _on_StompDetector_body_entered(body: Node) -> void:
if !body.is_in_group("player"):
return
var incoming_vel_vector: Vector2 = body.velocity.normalized()
print(rad2deg(abs(incoming_vel_vector.angle_to(Vector2.DOWN.rotated(rotation)))))
if abs(incoming_vel_vector.angle_to(Vector2.DOWN.rotated(rotation))) > deg2rad(95) \
&& is_harmful:
print("too shallow entry")
body.die()
return
signal_manager.emit_signal("got_stomped")
#get_node("EnemyBody").disabled = true
if(killable):
remove_from_group("harmful")
die()
else:
switch_spikes()
func switch_spikes() -> void:
is_harmful = !is_harmful
if $Sprite.frame == 0:
$Sprite.frame = 1
else:
$Sprite.frame = 0
func die() -> void:
queue_free()
func _on_EnemySkin_area_entered(area: Area2D) -> void:
pass
func _on_EnemySkin_body_entered(body: Node) -> void:
if body.is_in_group("player") && is_harmful:
body.die()

View File

@ -2,7 +2,6 @@ extends Actor
class_name Enemy class_name Enemy
export(bool) var killable := true export(bool) var killable := true
var player_entered_stomp = false
func _on_StompDetector_body_entered(body: Node) -> void: func _on_StompDetector_body_entered(body: Node) -> void:
@ -10,14 +9,11 @@ func _on_StompDetector_body_entered(body: Node) -> void:
return return
var incoming_vel_vector: Vector2 = body.velocity.normalized() var incoming_vel_vector: Vector2 = body.velocity.normalized()
print(rad2deg(abs(incoming_vel_vector.angle_to(Vector2.DOWN.rotated(rotation))))) print(rad2deg(abs(incoming_vel_vector.angle_to(Vector2.DOWN.rotated(rotation)))))
if abs(incoming_vel_vector.angle_to(Vector2.DOWN.rotated(rotation))) > deg2rad(95) \ if abs(incoming_vel_vector.angle_to(Vector2.DOWN.rotated(rotation))) > deg2rad(95):
&& !player_entered_stomp:
print("too shallow entry") print("too shallow entry")
body.die() body.die()
player_entered_stomp = false
return return
signal_manager.emit_signal("got_stomped") signal_manager.emit_signal("got_stomped")
player_entered_stomp = true
#get_node("EnemyBody").disabled = true #get_node("EnemyBody").disabled = true
if(killable): if(killable):
remove_from_group("harmful") remove_from_group("harmful")
@ -35,5 +31,5 @@ func _on_EnemySkin_area_entered(area: Area2D) -> void:
func _on_EnemySkin_body_entered(body: Node) -> void: func _on_EnemySkin_body_entered(body: Node) -> void:
if body.is_in_group("player") && !player_entered_stomp: if body.is_in_group("player"):
body.die() body.die()

View File

@ -125,9 +125,6 @@ unique_name_in_owner = true
position = Vector2( -70, 1 ) position = Vector2( -70, 1 )
scale = Vector2( 0.878906, 0.936025 ) scale = Vector2( 0.878906, 0.936025 )
[node name="BlobbySprite" parent="Blobby" index="5"]
frame = 8
[node name="BlobbymationTree" parent="Blobby/BlobbySprite" index="0"] [node name="BlobbymationTree" parent="Blobby/BlobbySprite" index="0"]
parameters/playback = SubResource( 6 ) parameters/playback = SubResource( 6 )
@ -223,9 +220,8 @@ speed = 16
[node name="DartingEnemy" parent="." instance=ExtResource( 6 )] [node name="DartingEnemy" parent="." instance=ExtResource( 6 )]
position = Vector2( 609, 67 ) position = Vector2( 609, 67 )
mass = 1.0
killable = false killable = false
speed = 300
acceleration = 800
[connection signal="body_exited" from="Blobby/BlobbySkin" to="Blobby" method="_on_BlobbySkin_body_exited"] [connection signal="body_exited" from="Blobby/BlobbySkin" to="Blobby" method="_on_BlobbySkin_body_exited"]

View File

@ -128,7 +128,7 @@ death_sound_1 = null
death_sound_2 = null death_sound_2 = null
[node name="BlobbySprite" parent="Blobby" index="5"] [node name="BlobbySprite" parent="Blobby" index="5"]
frame = 7 frame = 6
[node name="BlobbymationTree" parent="Blobby/BlobbySprite" index="0"] [node name="BlobbymationTree" parent="Blobby/BlobbySprite" index="0"]
parameters/playback = SubResource( 7 ) parameters/playback = SubResource( 7 )

View File

@ -132,9 +132,6 @@ jump_buffer_filled = null
death_sound_1 = null death_sound_1 = null
death_sound_2 = null death_sound_2 = null
[node name="BlobbySprite" parent="Blobby" index="5"]
frame = 5
[node name="BlobbymationTree" parent="Blobby/BlobbySprite" index="0"] [node name="BlobbymationTree" parent="Blobby/BlobbySprite" index="0"]
parameters/playback = SubResource( 53 ) parameters/playback = SubResource( 53 )

View File

@ -135,7 +135,7 @@ death_sound_1 = null
death_sound_2 = null death_sound_2 = null
[node name="BlobbySprite" parent="Blobby" index="5"] [node name="BlobbySprite" parent="Blobby" index="5"]
frame = 10 frame = 9
[node name="BlobbymationTree" parent="Blobby/BlobbySprite" index="0"] [node name="BlobbymationTree" parent="Blobby/BlobbySprite" index="0"]
parameters/playback = SubResource( 6 ) parameters/playback = SubResource( 6 )
@ -194,8 +194,8 @@ max_speed = 100
[node name="DartingEnemy" parent="." instance=ExtResource( 20 )] [node name="DartingEnemy" parent="." instance=ExtResource( 20 )]
position = Vector2( -446, 259 ) position = Vector2( -446, 259 )
speed = 200 mass = 1.0
acceleration = 320 killable = false
[node name="TileMap" type="TileMap" parent="."] [node name="TileMap" type="TileMap" parent="."]
unique_name_in_owner = true unique_name_in_owner = true

View File

@ -131,9 +131,6 @@ unique_name_in_owner = true
position = Vector2( -64, -1.90735e-06 ) position = Vector2( -64, -1.90735e-06 )
scale = Vector2( 0.878906, 0.936025 ) scale = Vector2( 0.878906, 0.936025 )
[node name="BlobbySprite" parent="Blobby" index="5"]
frame = 10
[node name="BlobbymationTree" parent="Blobby/BlobbySprite" index="0"] [node name="BlobbymationTree" parent="Blobby/BlobbySprite" index="0"]
parameters/playback = SubResource( 6 ) parameters/playback = SubResource( 6 )

File diff suppressed because one or more lines are too long

View File

@ -15,13 +15,16 @@ var halted = false
var returning = false var returning = false
var initial_distance : float = 1.0 var initial_distance : float = 1.0
export(float) var velocity = 1 export(float) var return_velocity = 10
export(float) var initial_velocity = 20
export(float) var max_velocity = 200 export(float) var max_velocity = 200
export(float) var acceleration_force = 1200 export(float) var acceleration_force = 1200
export(float) var mass = 10 export(float) var mass = 10
export(bool) var avoid_crushing = false export(bool) var avoid_crushing = false
export(bool) var fast_retrigger = false export(bool) var fast_retrigger = false
var velocity = initial_velocity
func _ready() -> void: func _ready() -> void:
$FlyingLaserCutterBody/Sprite/AnimationPlayer.play("default") $FlyingLaserCutterBody/Sprite/AnimationPlayer.play("default")
@ -49,8 +52,8 @@ func _physics_process(delta: float) -> void:
if halted && avoid_crushing: if halted && avoid_crushing:
return return
returning = true returning = true
velocity=1 velocity = initial_velocity
body.position.x += (max_velocity/3)*-1*delta body.position.x += return_velocity * -1 * delta
else: else:
returning = false returning = false

View File

@ -72,6 +72,10 @@ shader_param/oscilation_speed = 0.2
[node name="FlyingLaserCutter" type="Node2D"] [node name="FlyingLaserCutter" type="Node2D"]
script = ExtResource( 2 ) script = ExtResource( 2 )
return_velocity = 80.0
initial_velocity = 30.0
max_velocity = 190.0
acceleration_force = 1000.0
[node name="FlyingLaserCutterBody" type="KinematicBody2D" parent="."] [node name="FlyingLaserCutterBody" type="KinematicBody2D" parent="."]
collision_layer = 32 collision_layer = 32