![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | dk dk |
extends Area2D
export var speed = 100
var screen_size
signal pontua2
func _ready():
screen_size = get_viewport_rect().size
func _process(delta):
var velocity =Vector2()
if Input.is_action_pressed(“descer”):
velocity.y += 1
if Input.is_action_pressed(“sobe”):
velocity.y -= 1
if velocity.length() > 0:
velocity = velocity.normalized() * speed
$galinha2.play()
else:
$galinha2.stop()
position += velocity * delta
position.y = clamp(position.y,0,screen_size.y)
if velocity.y > 0:
$galinha.animation = "baixo"
elif velocity.x < 0:
$galinha.animation = "cima"
func _on_player_body_entered(body):
if body.name == “ganha”:
emit_signal(“pontua2”)
else:
$“audio de colisao”.play()
position.x = 944
position.y = 696