feat: let blobby ride on frog
This commit is contained in:
parent
317ce3d2b7
commit
311abfcc6f
@ -51,6 +51,8 @@ var detect_timer := 0.0
|
||||
|
||||
var reversing_possible_searching := true
|
||||
|
||||
var attached_player = null
|
||||
|
||||
|
||||
func _ready():
|
||||
default_jump_distance = default_jump_distance * tilemap.cell_size.x
|
||||
@ -75,6 +77,9 @@ func bind_to_anchor(anchor_node: Node2D, radius: float ) -> void:
|
||||
|
||||
|
||||
func _on_StompDetector_body_entered(body: Node) -> void:
|
||||
if body.is_in_group("player"):
|
||||
attached_player = body
|
||||
$FeelerRayCast.collision_mask -= 1
|
||||
if !body.is_in_group("player") || is_hurt:
|
||||
return
|
||||
var incoming_vel_vector: Vector2 = body.velocity.normalized()
|
||||
@ -92,6 +97,10 @@ func _on_StompDetector_body_entered(body: Node) -> void:
|
||||
$FrogSprite.material = invincible_shader
|
||||
$HurtTimer.start()
|
||||
|
||||
func _on_StompDetector_body_exited(body: Node) -> void:
|
||||
if attached_player == body:
|
||||
$FeelerRayCast.collision_mask += 1
|
||||
attached_player = null
|
||||
|
||||
func execute_movement(delta: float) -> void:
|
||||
# Navigation2DServer.map_get_path()
|
||||
@ -109,12 +118,15 @@ func execute_movement(delta: float) -> void:
|
||||
velocity.y = velocity.y * 0.8
|
||||
was_restricted = true
|
||||
velocity = move_and_slide(velocity, FLOOR_NORMAL, false, 4, 0.785398, false)
|
||||
|
||||
if(is_on_floor()):
|
||||
velocity = Vector2(0,0)
|
||||
|
||||
# Reverse direction when hitting limit
|
||||
|
||||
|
||||
|
||||
|
||||
func die() -> void:
|
||||
levelState.kills += 1
|
||||
queue_free()
|
||||
@ -298,8 +310,15 @@ func jump():
|
||||
v = consider_jumping_on_top()
|
||||
if(v == zero_vector && can_reverse_facing_direction()):
|
||||
reverse_facing_direction()
|
||||
|
||||
# if attached_player != null && v != zero_vector:
|
||||
# move_with_player(v)
|
||||
|
||||
velocity = v
|
||||
|
||||
#func move_with_player(v: Vector2):
|
||||
# print(v)
|
||||
# attached_player.move_and_slide(v * 10)
|
||||
|
||||
func correct_jump_direction(v: Vector2) -> Vector2:
|
||||
if sign(v.x) != get_facing_direction():
|
||||
@ -518,3 +537,6 @@ func _on_HurtTimer_timeout() -> void:
|
||||
is_hurt = false
|
||||
#if(is_bound): add_to_group("harmful")
|
||||
$FrogSprite.material = null
|
||||
|
||||
|
||||
|
||||
|
||||
@ -574,6 +574,7 @@ wait_time = 3.236
|
||||
one_shot = true
|
||||
|
||||
[connection signal="body_entered" from="StompDetector" to="." method="_on_StompDetector_body_entered"]
|
||||
[connection signal="body_exited" from="StompDetector" to="." method="_on_StompDetector_body_exited"]
|
||||
[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="timeout" from="HurtTimer" to="." method="_on_HurtTimer_timeout"]
|
||||
|
||||
@ -23,7 +23,6 @@ func _ready() -> void:
|
||||
# TODO Limit spring deformation
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _physics_process(delta: float) -> void:
|
||||
var bc = _body_contact()
|
||||
if !bc:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user