Here is the code, ignore the area_entered signals.
extends CharacterBody2D
class_name Player
var speed : float = 7000
var acceleration_smoothing : float = 0.2
var gravity : float = 250
signal died
signal portal
func _ready():
$IceArea.body_shape_entered.connect(_on_ice_entered)
$PortalArea.body_shape_entered.connect(_on_portal_entered)
func _process(dt):
var direction = Input.get_axis('left', 'right')
velocity = lerp(velocity, Vector2(speed * direction * dt, velocity.y), acceleration_smoothing)
if direction > 0:
$AnimatedSprite2D.flip_h = false
if direction < 0:
$AnimatedSprite2D.flip_h = true
if Input.is_action_just_pressed('flip'):
gravity *= -1
$AnimatedSprite2D.flip_v = !$AnimatedSprite2D.flip_v
velocity.y += gravity * dt
move_and_slide()
func _on_ice_entered(_body_rid, body, _body_shape_index, _local_shape_index):
died.emit()
func _on_portal_entered(_body_rid, body, _body_shape_index, _local_shape_index):
portal.emit()