extends Entity class_name Player signal color_changed(color: Color) signal lives_changed(lives: int) @onready var sprite_2d: Sprite2D = $Sprite2D const ATTACK := preload("res://scene/attack.tscn") func _physics_process(delta: float) -> void: var input_direction = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down") velocity = input_direction * speed move_and_slide() for i in range(get_slide_collision_count()): var collision := get_slide_collision(i) if collision.get_collider() is Chest: var buff: Buff = collision.get_collider().open(self) if buff: match(buff.color): buff.colors.RED: lives += 1 color.r -= 0.25 lives_changed.emit(lives) buff.colors.GREEN: $Camera2D.zoom -= Vector2(0.4, 0.4) color.g -= 0.25 buff.colors.BLUE: speed += 12 color.b -= 0.25 sprite_2d.modulate = color color_changed.emit(color) if Input.is_action_just_pressed("ui_accept"): var attack: Attack = ATTACK.instantiate() attack.set_initiator(self) get_parent().add_sibling(attack)