extends Area2D export var speed = 600 export var w = 96 var screen_size func _ready(): screen_size = get_viewport_rect().size $AnimationPlayer.play("idle") func _process(delta): var velocity = Vector2() if Input.is_action_pressed("ui_right"): velocity.x += 1 $Sprite.flip_h = true if Input.is_action_pressed("ui_left"): velocity.x -= 1 $Sprite.flip_h = false if velocity.length() > 0: velocity = velocity.normalized() * speed $AnimationPlayer.play("walk") else: $AnimationPlayer.play("idle") position += velocity * delta position.x = clamp(position.x, w/2, screen_size.x - (w/2)) func _on_Player_body_entered(body): if body.kind == "Apple": print("Apple") body.queue_free() # kill Apple else: print("bomb")