-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpato.gd
49 lines (37 loc) · 973 Bytes
/
pato.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
42
43
44
45
46
47
48
49
extends CharacterBody2D
var lado = 1
var vel = Vector2()
var speed = 100
var queda = 1
func _ready():
$quack.wait_time = randf_range(0.8,2)
randomize()
$movimento.wait_time = randf_range(0.4, 2)
$anima.wait_time = randf_range(0.6, 1)
func _process(delta):
#movimentacao horizontal
position.x += speed*lado*delta
#movitantacao vertical
position.y -= 140*queda*delta
#espelhamento da animacao
if lado<0:
$AnimatedSprite2D.flip_h = true
else:
$AnimatedSprite2D.flip_h = false
func _on_movimento_timeout():
lado = lado*(-1)
func _on_anima_timeout():
if $AnimatedSprite2D.animation == "cima":
$AnimatedSprite2D.animation = "lado"
elif $AnimatedSprite2D.animation == "lado":
$AnimatedSprite2D.animation = "cima"
func mata():
$AnimatedSprite2D.animation = "susto"
$morte.start()
func _on_morte_timeout():
$quack.stop()
$AnimatedSprite2D.animation = "morte"
queda = -1
lado = 0
func _on_quack_timeout():
$audio.play()