-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlayer.gd
executable file
·80 lines (43 loc) · 1.15 KB
/
Player.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
extends KinematicBody2D
onready var sprite = get_node("Sprite")
var velocity = Vector2()
var anim = "move"
#Speed
var move_speed = 30
var dash_speed = 40
var speed = move_speed
func _input(event):
if(event.is_action_pressed("ui_right")):
velocity.x = speed
if get_node("Timer").is_stopped() == false :
speed = dash_speed
print("doble tap")
else: get_node("Timer").start()
func _physics_process(delta):
if Input.is_action_pressed("ui_left"):
velocity.x = -speed
if get_node("Timer").is_processing():
double_tap_left()
else: get_node("Timer").start()
if Input.is_action_just_released("ui_right"):
velocity.x = 0
speed = move_speed
if Input.is_action_just_released("ui_left"):
velocity.x = 0
speed = move_speed
move_and_slide(velocity)
if velocity.x == 0:
anim = "idle"
elif velocity.x == 30:
anim = "move"
elif velocity.x == -30:
anim = "move"
elif velocity.x == 40:
anim = "dash"
elif velocity.x == -40:
anim = "dash"
if velocity.x > 0:
sprite.set_flip_h(false)
elif velocity.x < 0:
sprite.set_flip_h(true)
sprite.play(anim)