fix: reworked stomping mechanic

This commit is contained in:
Jakob Feldmann 2023-04-04 20:42:16 +02:00
parent 403750a9b0
commit 3fd696d988
15 changed files with 112 additions and 234 deletions

View File

@ -14,6 +14,11 @@ _global_script_classes=[ {
"language": "GDScript", "language": "GDScript",
"path": "res://src/Actors/Actor.gd" "path": "res://src/Actors/Actor.gd"
}, { }, {
"base": "Actor",
"class": "Enemy",
"language": "GDScript",
"path": "res://src/Actors/Enemies/Beings/Enemy.gd"
}, {
"base": "Line2D", "base": "Line2D",
"class": "RayCastDebugLines", "class": "RayCastDebugLines",
"language": "GDScript", "language": "GDScript",
@ -31,6 +36,7 @@ _global_script_classes=[ {
} ] } ]
_global_script_class_icons={ _global_script_class_icons={
"Actor": "", "Actor": "",
"Enemy": "",
"RayCastDebugLines": "", "RayCastDebugLines": "",
"RayCaster": "", "RayCaster": "",
"StateMachine": "" "StateMachine": ""

View File

@ -9,6 +9,8 @@ const PhysicsConst = preload("res://src/Utilities/Physic/PhysicsConst.gd")
const FLOOR_NORMAL := Vector2.UP const FLOOR_NORMAL := Vector2.UP
var stomp_feedback := 1200 var stomp_feedback := 1200
var reset_stomp_time := 0.108
var stomp_time := 0.108
var inair_velocity := 21 var inair_velocity := 21
var wallslide_threshold := 1000 var wallslide_threshold := 1000
var base_floor_friction := 0.5 var base_floor_friction := 0.5

View File

@ -23,41 +23,35 @@ var previous_rotation = 0
var snap_possible = true var snap_possible = true
var shielded = false var shielded = false
# When the Enemy stomp AREA enters the enemy collision area -> stomp func execute_movement() -> void:
func _on_BlobbySkin_area_entered(area: Area2D) -> void: if(levelState.is_dead):
if area.is_in_group("weakpoint"): return
stomping = true var snap = Vector2.DOWN * 128
if area.is_in_group("harmful") && !levelState.is_dead: var center_floor_rot = 0
die() var floor_rot = 0
if area.is_in_group("pit"): var onfloor = is_on_floor()
shielded = false
die()
# get rotation of floor, compare collided floor with floor under center
# When the Enemy collision BODY enters the enemy collision area -> die if onfloor:
func _on_BlobbySkin_body_entered(body: Node) -> void: # TODO: Problem when correctly rotating?
if body.is_in_group("harmful") && !levelState.is_dead: center_floor_rot = $SlopeRaycast.get_collision_normal().rotated(PI/2).angle()
die() floor_rot = get_floor_normal().rotated(PI/2).angle()
if(abs(center_floor_rot) > PI/4+0.1):
center_floor_rot = floor_rot
func _on_JumpBufferTimer_timeout() -> void: # snap when on slopes
jump_buffer_filled = false if((abs(floor_rot) > 0.1 || abs(center_floor_rot) > 0.1) && snap_possible):
velocity = move_and_slide_with_snap(velocity.rotated(floor_rot),
snap, FLOOR_NORMAL, true)
func handle_grounded_movement(delta: float, direction: Vector2) -> Vector2: # normal slide on flat floor
return calculate_grounded_velocity(velocity, delta, direction) else:
velocity = move_and_slide(velocity.rotated(floor_rot),FLOOR_NORMAL)
func handle_jump_movement(delta: float, direction: Vector2) -> Vector2: rotation = 0
return calculate_jump_velocity(velocity, delta, direction) if($SlopeRaycastLeft.is_colliding() && $SlopeRaycastRight.is_colliding() && $SlopeRaycast.is_colliding()):
rotation = calculate_slope_rotation(onfloor)
func handle_duck_movement(delta: float, direction: Vector2) -> Vector2: # rotate related to floor slope
return calculate_duck_velocity(velocity, delta, direction) # Convert velocity back to local space.
# TODO: Downward velocity should be increased by gravity
func handle_fall_movement(delta: float, direction: Vector2) -> Vector2: velocity = velocity.rotated(-floor_rot) if snap_possible else velocity
return calculate_fall_velocity(velocity, delta, direction)
func handle_wallslide_movement(delta: float, direction: Vector2) -> Vector2:
return calculate_wallslide_velocity(velocity, delta, direction)
func calculate_duck_velocity( func calculate_duck_velocity(
@ -265,6 +259,9 @@ func calculate_jump_velocity(
var additive_jump_force = velocity_jump_boost_ratio * abs(velocity.x) * mass var additive_jump_force = velocity_jump_boost_ratio * abs(velocity.x) * mass
if stomping: if stomping:
additive_jump_force += stomp_feedback / delta additive_jump_force += stomp_feedback / delta
stomp_time -= delta
if stomp_time <= 0:
stomp_time = reset_stomp_time
stomping = false stomping = false
if state != "jump": if state != "jump":
@ -275,7 +272,7 @@ func calculate_jump_velocity(
delta delta
) )
if !Input.is_action_pressed("jump"): if !Input.is_action_pressed("jump") && !stomping:
# Smooth transition from jumping to falling # Smooth transition from jumping to falling
if velocity.y > _gravity * delta * 10: if velocity.y > _gravity * delta * 10:
linear_velocity.y += _gravity * delta * 10 linear_velocity.y += _gravity * delta * 10
@ -288,7 +285,7 @@ func calculate_jump_velocity(
else: else:
linear_velocity.y += _gravity * delta linear_velocity.y += _gravity * delta
# TODO This poop too # TODO This is poop too
if -20 < velocity.x and velocity.x < 20: if -20 < velocity.x and velocity.x < 20:
linear_velocity.x += inair_velocity * direction.x linear_velocity.x += inair_velocity * direction.x
@ -370,35 +367,6 @@ func execute_airstrafe(
air_strafe_charges -= 1 air_strafe_charges -= 1
return linear_velocity return linear_velocity
func execute_movement() -> void:
if(levelState.is_dead):
return
var snap = Vector2.DOWN * 128
var center_floor_rot = 0
var floor_rot = 0
var onfloor = is_on_floor()
# get rotation of floor, compare collided floor with floor under center
if onfloor:
# TODO: Problem when correctly rotating?
center_floor_rot = $SlopeRaycast.get_collision_normal().rotated(PI/2).angle()
floor_rot = get_floor_normal().rotated(PI/2).angle()
if(abs(center_floor_rot) > PI/4+0.1):
center_floor_rot = floor_rot
# snap when on slopes
if((abs(floor_rot) > 0.1 || abs(center_floor_rot) > 0.1) && snap_possible):
velocity = move_and_slide_with_snap(velocity.rotated(floor_rot),
snap, FLOOR_NORMAL, true)
# normal slide on flat floor
else:
velocity = move_and_slide(velocity.rotated(floor_rot),FLOOR_NORMAL)
rotation = 0
if($SlopeRaycastLeft.is_colliding() && $SlopeRaycastRight.is_colliding() && $SlopeRaycast.is_colliding()):
rotation = calculate_slope_rotation(onfloor)
# rotate related to floor slope
# Convert velocity back to local space.
# TODO: Downward velocity should be increased by gravity
velocity = velocity.rotated(-floor_rot) if snap_possible else velocity
func calculate_slope_rotation(onfloor: bool) -> float: func calculate_slope_rotation(onfloor: bool) -> float:
var angle = 0 var angle = 0
@ -423,6 +391,10 @@ func calculate_slope_rotation(onfloor: bool) -> float:
pass pass
return angle return angle
# TODO could be expanded with a parameter about what got stomped
func stomp() -> void:
stomping = true
func receive_power_up(kind: String) -> void: func receive_power_up(kind: String) -> void:
if kind == "shield": if kind == "shield":
$BubbleShieldViewport/IridescenceBall.visible = true $BubbleShieldViewport/IridescenceBall.visible = true
@ -450,6 +422,22 @@ func respawn() -> void:
# Is tied to the death animation # Is tied to the death animation
get_tree().reload_current_scene() get_tree().reload_current_scene()
# When the Enemy stomp AREA enters the enemy collision area -> stomp
func _on_BlobbySkin_area_entered(area: Area2D) -> void:
if area.is_in_group("harmful") && !levelState.is_dead:
die()
if area.is_in_group("pit"):
shielded = false
die()
# When the Enemy collision BODY enters the enemy collision area -> die
func _on_BlobbySkin_body_entered(body: Node) -> void:
if body.is_in_group("harmful") && !levelState.is_dead:
die()
func _on_JumpBufferTimer_timeout() -> void:
jump_buffer_filled = false
# This problem stems from trying to decelerate a walk # This problem stems from trying to decelerate a walk
# that was caused by the moving environment and not by input # that was caused by the moving environment and not by input
# It is particularly usefull for moving floor physics # It is particularly usefull for moving floor physics
@ -465,15 +453,28 @@ func _on_Blobby_got_grounded() -> void:
floor_friction = base_floor_friction floor_friction = base_floor_friction
air_strafe_charges = air_strafe_charges + 1 if max_air_strafe_charges > air_strafe_charges else 0 air_strafe_charges = air_strafe_charges + 1 if max_air_strafe_charges > air_strafe_charges else 0
func _on_BlobbySkin_body_exited(body:Node) -> void: func _on_BlobbySkin_body_exited(body:Node) -> void:
# This is for drop through platforms # This is for drop through platforms
if body.get_collision_mask_bit(7): if body.get_collision_mask_bit(7):
set_collision_mask_bit(7, true) set_collision_mask_bit(7, true)
func _on_InvincibilityTimer_timeout() -> void: func _on_InvincibilityTimer_timeout() -> void:
$BlobbySprite.material = null $BlobbySprite.material = null
for area in $BlobbySkin.get_overlapping_areas(): for area in $BlobbySkin.get_overlapping_areas():
if area.is_in_group("harmful"): if area.is_in_group("harmful"):
die() die()
func handle_grounded_movement(delta: float, direction: Vector2) -> Vector2:
return calculate_grounded_velocity(velocity, delta, direction)
func handle_jump_movement(delta: float, direction: Vector2) -> Vector2:
return calculate_jump_velocity(velocity, delta, direction)
func handle_duck_movement(delta: float, direction: Vector2) -> Vector2:
return calculate_duck_velocity(velocity, delta, direction)
func handle_fall_movement(delta: float, direction: Vector2) -> Vector2:
return calculate_fall_velocity(velocity, delta, direction)
func handle_wallslide_movement(delta: float, direction: Vector2) -> Vector2:
return calculate_wallslide_velocity(velocity, delta, direction)

View File

@ -21,6 +21,7 @@ var state_time := 0.0
func _ready(): func _ready():
signalManager.connect("getback_timer_up", parent, "die") signalManager.connect("getback_timer_up", parent, "die")
signalManager.connect("power_up_collected", parent, "receive_power_up") signalManager.connect("power_up_collected", parent, "receive_power_up")
signalManager.connect("got_stomped", parent, "stomp")
anim_player.play("RESET") anim_player.play("RESET")
add_state("idle") add_state("idle")
add_state("duck") add_state("duck")

View File

@ -1,4 +1,4 @@
extends Actor extends Enemy
onready var left_src = $SlopeRaycastLeft onready var left_src = $SlopeRaycastLeft
onready var right_src = $SlopeRaycastRight onready var right_src = $SlopeRaycastRight
@ -11,15 +11,6 @@ var snap = Vector2.DOWN * 24
func _ready() -> void: func _ready() -> void:
velocity.x = -120 velocity.x = -120
# TODO adapt to groups
func _on_StompDetector_body_entered(body: Node) -> void:
if body.global_position.y > get_node("StompDetector").global_position.y:
return
$StompDetector.remove_from_group("weakpoint")
get_node("EnemyBody").disabled = true
die()
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
# rotation # rotation
var movement = max(0,sign(sin(time*15))) var movement = max(0,sign(sin(time*15)))
@ -34,13 +25,3 @@ func _physics_process(delta: float) -> void:
var v = Vector2(velocity.x * movement, 0) var v = Vector2(velocity.x * movement, 0)
time += delta time += delta
move_and_slide_with_snap(v.rotated(rotation), snap.rotated(rotation), FLOOR_NORMAL, false, 4, PI) move_and_slide_with_snap(v.rotated(rotation), snap.rotated(rotation), FLOOR_NORMAL, false, 4, PI)
func die() -> void:
queue_free()
levelState.kills += 1
func _on_EnemySkin_area_entered(area:Area2D) -> void:
if area.is_in_group("harmful"):
get_node("EnemyBody").disabled = true
die()

View File

@ -10,7 +10,7 @@ extents = Vector2( 2.72463, 1.17848 )
extents = Vector2( 15, 6.12039 ) extents = Vector2( 15, 6.12039 )
[sub_resource type="RectangleShape2D" id=3] [sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 15.534, 10.0962 ) extents = Vector2( 14.563, 9.38461 )
[node name="Caterpillar" type="KinematicBody2D" groups=["harmful"]] [node name="Caterpillar" type="KinematicBody2D" groups=["harmful"]]
scale = Vector2( 0.8, 0.5 ) scale = Vector2( 0.8, 0.5 )
@ -66,7 +66,7 @@ collision_layer = 2
input_pickable = false input_pickable = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="StompDetector"] [node name="CollisionShape2D" type="CollisionShape2D" parent="StompDetector"]
position = Vector2( -4.76837e-07, 0.561345 ) position = Vector2( 0, -0.2 )
shape = SubResource( 2 ) shape = SubResource( 2 )
[node name="EnemySkin" type="Area2D" parent="." groups=["player"]] [node name="EnemySkin" type="Area2D" parent="." groups=["player"]]
@ -74,6 +74,7 @@ process_priority = -1
collision_mask = 126 collision_mask = 126
[node name="CollisionPolygon2D" type="CollisionShape2D" parent="EnemySkin"] [node name="CollisionPolygon2D" type="CollisionShape2D" parent="EnemySkin"]
position = Vector2( 0, 3.76 )
scale = Vector2( 1.03, 1.04 ) scale = Vector2( 1.03, 1.04 )
shape = SubResource( 3 ) shape = SubResource( 3 )

View File

@ -1,15 +1,8 @@
extends Actor extends Enemy
func _ready() -> void: func _ready() -> void:
set_physics_process(false) set_physics_process(false)
# TODO adapt to groups
func _on_StompDetector_body_entered(body: Node) -> void:
if body.global_position.y > get_node("StompDetector").global_position.y:
return
$StompDetector.remove_from_group("weakpoint")
get_node("EnemyBody").disabled = true
die()
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
velocity.y += _gravity * delta velocity.y += _gravity * delta
@ -24,12 +17,3 @@ func player_on_floor_direction():
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 return 0
func die() -> void:
queue_free()
levelState.kills += 1
func _on_EnemySkin_area_entered(area:Area2D) -> void:
if area.is_in_group("harmful"):
get_node("EnemyBody").disabled = true
die()

View File

@ -4,10 +4,10 @@
[ext_resource path="res://src/Actors/Enemies/Beings/DartingEnemy.gd" type="Script" id=2] [ext_resource path="res://src/Actors/Enemies/Beings/DartingEnemy.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1] [sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 2.72463, 1.17848 ) extents = Vector2( 2.72463, 1.43961 )
[sub_resource type="RectangleShape2D" id=2] [sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 15, 6.12039 ) extents = Vector2( 15, 3.0301 )
[sub_resource type="RectangleShape2D" id=3] [sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 15.534, 10.0962 ) extents = Vector2( 15.534, 10.0962 )
@ -30,21 +30,23 @@ process_parent = true
physics_process_parent = true physics_process_parent = true
[node name="EnemyBody" type="CollisionShape2D" parent="." groups=["harmful"]] [node name="EnemyBody" type="CollisionShape2D" parent="." groups=["harmful"]]
position = Vector2( 0, 6.48802 ) position = Vector2( 0, 4.61815 )
scale = Vector2( 5.68128, 5.29182 ) scale = Vector2( 5.68128, 5.29182 )
shape = SubResource( 1 ) shape = SubResource( 1 )
[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 )
position = Vector2( 0, -6.44095 ) position = Vector2( 0, -6.44095 )
collision_layer = 2 collision_layer = 2
input_pickable = false input_pickable = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="StompDetector"] [node name="CollisionShape2D" type="CollisionShape2D" parent="StompDetector"]
position = Vector2( -4.76837e-07, 0.561345 ) position = Vector2( 0, -2.52895 )
shape = SubResource( 2 ) shape = SubResource( 2 )
[node name="LedgeDetectorRays" type="Node2D" parent="."] [node name="LedgeDetectorRays" type="Node2D" parent="."]
visible = false
position = Vector2( -14, 12 ) position = Vector2( -14, 12 )
[node name="RayCast2D" type="RayCast2D" parent="LedgeDetectorRays"] [node name="RayCast2D" type="RayCast2D" parent="LedgeDetectorRays"]
@ -63,10 +65,11 @@ collision_mask = 121
[node name="EnemySkin" type="Area2D" parent="." groups=["player"]] [node name="EnemySkin" type="Area2D" parent="." groups=["player"]]
process_priority = -1 process_priority = -1
visible = false
collision_mask = 126 collision_mask = 126
[node name="CollisionPolygon2D" type="CollisionShape2D" parent="EnemySkin"] [node name="CollisionPolygon2D" type="CollisionShape2D" parent="EnemySkin"]
position = Vector2( 5.96046e-07, 2.5 ) position = Vector2( -8.07794e-28, 1.5 )
scale = Vector2( 1.03, 1.04 ) scale = Vector2( 1.03, 1.04 )
shape = SubResource( 3 ) shape = SubResource( 3 )

View File

@ -1,33 +1,22 @@
extends Actor extends Actor
class_name Enemy
func _ready() -> void:
set_physics_process(false)
velocity.x = -30
# TODO adapt to groups # TODO adapt to groups
# TODO Engine error here(what does it WANT???) # TODO Engine error here(what does it WANT???)
func _on_StompDetector_body_entered(body: Node) -> void: func _on_StompDetector_body_entered(body: Node) -> void:
if body.global_position.y > get_node("StompDetector").global_position.y: if body.global_position.y > get_node("StompDetector").global_position.y:
return return
if body.is_in_group("player"):
signalManager.emit_signal("got_stomped")
remove_from_group("harmful")
$StompDetector.remove_from_group("weakpoint") $StompDetector.remove_from_group("weakpoint")
get_node("EnemyBody").disabled = true get_node("EnemyBody").disabled = true
die() die()
func _physics_process(delta: float) -> void:
velocity.y += _gravity * delta
if is_on_wall():
velocity.x *= -1.0
velocity.y = move_and_slide(velocity, FLOOR_NORMAL).y
func die() -> void: func die() -> void:
queue_free() queue_free()
levelState.kills += 1 levelState.kills += 1
func _on_EnemySkin_area_entered(area:Area2D) -> void: func _on_EnemySkin_area_entered(area:Area2D) -> void:
if area.is_in_group("harmful"): if area.is_in_group("harmful"):
get_node("EnemyBody").disabled = true get_node("EnemyBody").disabled = true

View File

@ -1,56 +0,0 @@
[gd_scene load_steps=6 format=2]
[ext_resource path="res://assets/enemy/enemy.png" type="Texture" id=1]
[ext_resource path="res://src/Actors/Enemies/Beings/Enemy.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 2.72463, 1.17848 )
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 15.4794, 6.68174 )
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 15.534, 10.0962 )
[node name="Enemy" type="KinematicBody2D" groups=["harmful"]]
collision_layer = 2
collision_mask = 9
script = ExtResource( 2 )
[node name="enemy" type="Sprite" parent="."]
position = Vector2( 0, -1.90735e-06 )
scale = Vector2( 0.286789, 0.276348 )
texture = ExtResource( 1 )
[node name="VisibilityEnabler2D" type="VisibilityEnabler2D" parent="."]
position = Vector2( 1362.81, -0.138177 )
scale = Vector2( 15.4865, 1.28502 )
rect = Rect2( -89, -10, 2, 20 )
process_parent = true
physics_process_parent = true
[node name="EnemyBody" type="CollisionShape2D" parent="." groups=["harmful"]]
position = Vector2( 0, 6.48802 )
scale = Vector2( 5.68128, 5.29182 )
shape = SubResource( 1 )
[node name="StompDetector" type="Area2D" parent="." groups=["weakpoint"]]
modulate = Color( 0, 0.0392157, 1, 1 )
position = Vector2( 0, -6.44095 )
collision_layer = 2
input_pickable = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="StompDetector"]
shape = SubResource( 2 )
[node name="EnemySkin" type="Area2D" parent="." groups=["player"]]
process_priority = -1
collision_mask = 126
[node name="CollisionPolygon2D" type="CollisionShape2D" parent="EnemySkin"]
position = Vector2( 5.96046e-07, 2.5 )
scale = Vector2( 1.03, 1.04 )
shape = SubResource( 3 )
[connection signal="body_entered" from="StompDetector" to="." method="_on_StompDetector_body_entered"]
[connection signal="area_entered" from="EnemySkin" to="." method="_on_EnemySkin_area_entered"]

View File

@ -1,19 +1,9 @@
extends Actor extends Enemy
func _ready() -> void: func _ready() -> void:
set_physics_process(false) set_physics_process(false)
velocity.x = -30 velocity.x = -40
# TODO adapt to groups
func _on_StompDetector_body_entered(body: Node) -> void:
if body.global_position.y > get_node("StompDetector").global_position.y:
return
$StompDetector.remove_from_group("weakpoint")
get_node("EnemyBody").disabled = true
die()
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
velocity.y += _gravity * delta velocity.y += _gravity * delta
@ -26,13 +16,3 @@ func is_at_ledge():
if !raycast.is_colliding(): if !raycast.is_colliding():
return true return true
return false return false
func die() -> void:
queue_free()
levelState.kills += 1
func _on_EnemySkin_area_entered(area:Area2D) -> void:
if area.is_in_group("harmful"):
get_node("EnemyBody").disabled = true
die()

View File

@ -1,4 +1,4 @@
extends Actor extends Enemy
func _ready() -> void: func _ready() -> void:
@ -7,13 +7,6 @@ func _ready() -> void:
# TODO adapt to groups # TODO adapt to groups
func _on_StompDetector_body_entered(body: Node) -> void:
if body.global_position.y > get_node("StompDetector").global_position.y:
return
$StompDetector.remove_from_group("weakpoint")
get_node("EnemyBody").disabled = true
die()
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
velocity.y += _gravity * delta velocity.y += _gravity * delta
if is_on_wall() or !is_safe_drop(): if is_on_wall() or !is_safe_drop():
@ -27,12 +20,3 @@ func is_safe_drop():
if collider.is_in_group("harmful"): if collider.is_in_group("harmful"):
return false return false
return true return true
func die() -> void:
queue_free()
levelState.kills += 1
func _on_EnemySkin_area_entered(area:Area2D) -> void:
if area.is_in_group("harmful"):
get_node("EnemyBody").disabled = true
die()

View File

@ -4,13 +4,13 @@
[ext_resource path="res://src/Actors/Enemies/Beings/SmortEnemy.gd" type="Script" id=2] [ext_resource path="res://src/Actors/Enemies/Beings/SmortEnemy.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=1] [sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 2.72463, 1.17848 ) extents = Vector2( 2.64025, 1.38585 )
[sub_resource type="RectangleShape2D" id=2] [sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 15, 6.12039 ) extents = Vector2( 15, 4.5301 )
[sub_resource type="RectangleShape2D" id=3] [sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 15.534, 10.0962 ) extents = Vector2( 15.534, 10.8173 )
[node name="SmortEnemy" type="KinematicBody2D" groups=["harmful"]] [node name="SmortEnemy" type="KinematicBody2D" groups=["harmful"]]
collision_layer = 2 collision_layer = 2
@ -30,8 +30,8 @@ process_parent = true
physics_process_parent = true physics_process_parent = true
[node name="EnemyBody" type="CollisionShape2D" parent="." groups=["harmful"]] [node name="EnemyBody" type="CollisionShape2D" parent="." groups=["harmful"]]
position = Vector2( 0, 6.48802 ) position = Vector2( -6.85453e-07, 5.42069 )
scale = Vector2( 5.68128, 5.29182 ) scale = Vector2( 5.56089, 5.35462 )
shape = SubResource( 1 ) shape = SubResource( 1 )
[node name="StompDetector" type="Area2D" parent="." groups=["weakpoint"]] [node name="StompDetector" type="Area2D" parent="." groups=["weakpoint"]]
@ -41,7 +41,7 @@ collision_layer = 2
input_pickable = false input_pickable = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="StompDetector"] [node name="CollisionShape2D" type="CollisionShape2D" parent="StompDetector"]
position = Vector2( -4.76837e-07, 0.561345 ) position = Vector2( 0, -1.08915 )
shape = SubResource( 2 ) shape = SubResource( 2 )
[node name="LedgeDetectorRays" type="Node2D" parent="."] [node name="LedgeDetectorRays" type="Node2D" parent="."]
@ -68,7 +68,7 @@ process_priority = -1
collision_mask = 126 collision_mask = 126
[node name="CollisionPolygon2D" type="CollisionShape2D" parent="EnemySkin"] [node name="CollisionPolygon2D" type="CollisionShape2D" parent="EnemySkin"]
position = Vector2( 5.96046e-07, 2.5 ) position = Vector2( 6.77626e-21, 2 )
scale = Vector2( 1.03, 1.04 ) scale = Vector2( 1.03, 1.04 )
shape = SubResource( 3 ) shape = SubResource( 3 )

View File

@ -67,11 +67,12 @@ func bind_to_anchor(anchor_node: Node2D, radius: float ) -> void:
func _on_StompDetector_body_entered(body: Node) -> void: func _on_StompDetector_body_entered(body: Node) -> void:
if body.global_position.y > get_node("StompDetector").global_position.y: if body.global_position.y - 1 > get_node("StompDetector").global_position.y:
return return
if body.is_in_group("player"): if body.is_in_group("player") && !is_hurt:
remove_from_group("harmful") remove_from_group("harmful")
$StompDetector.remove_from_group("weakpoint") $StompDetector.remove_from_group("weakpoint")
signalManager.emit_signal("got_stomped")
is_hurt = true is_hurt = true

View File

@ -8,6 +8,7 @@ signal frees_updated()
signal player_died() signal player_died()
signal level_completed() signal level_completed()
signal power_up_collected(kind) signal power_up_collected(kind)
signal got_stomped()
func _on_Timer_timeout() -> void: func _on_Timer_timeout() -> void:
emit_signal("getback_timer_up") emit_signal("getback_timer_up")