-
Notifications
You must be signed in to change notification settings - Fork 0
/
Player_2.gd
41 lines (33 loc) · 823 Bytes
/
Player_2.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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("ui_down"):
velocity.y += 1
if Input.is_action_pressed("ui_up"):
velocity.y -= 1
if velocity.length() > 0:
velocity = velocity.normalized()* speed
$AnimatedSprite.play()
else:
$AnimatedSprite.stop()
position += velocity*delta
position.y = clamp(position.y,0,screen_size.y)
if velocity.y > 0:
$AnimatedSprite.animation = "baixo"
if velocity.y < 0:
$AnimatedSprite.animation = "cima"
func _on_Player_2_body_entered(body):
if body.name == "ganha":
emit_signal("pontua2")
else:
$AudioStreamPlayer2D.play()
position.x = 944
position.y = 696
func volta():
position.x = 944
position.y = 696