@@ -7,7 +7,6 @@ export var MAX_SPEED = 80
7
7
export var FRICTION = 500
8
8
export var ROLL_SPEED = 125
9
9
10
-
11
10
enum {
12
11
MOVE ,
13
12
ROLL ,
@@ -27,34 +26,42 @@ onready var animationState = animationTree.get("parameters/playback")
27
26
onready var swordHitbox = $ HitboxPivot/SwordHitbox
28
27
onready var hurtbox = $ Hurtbox
29
28
onready var blinkAnimationPlayer = $ BlinkAnimationPlayer
30
-
31
-
29
+ onready var timer = get_node ( "Timer" )
30
+ onready var timer2 = get_node ( "Timer2" )
32
31
33
32
34
33
func _ready ():
35
34
randomize ()
36
- stats .connect ("no_health" , self , "queue_free " )
35
+ stats .connect ("no_health" , self , "game_over " )
37
36
animationTree .active = true
38
37
swordHitbox .knockback_vector = roll_vector
39
-
40
- func do_nothing ():
41
- pass
38
+
39
+
40
+ func game_over ():
41
+ queue_free ()
42
+ stats .health = 4
43
+ timer .set_wait_time (2 )
44
+ timer .start ()
45
+
42
46
43
47
func check_enemies ():
44
48
total += 1
45
49
if total == 10 :
50
+ playerHealth = 0
51
+ stats .health = 4
46
52
get_tree ().change_scene ("res://Game Over/GameOverWin.tscn" )
47
53
54
+
48
55
func _physics_process (delta ):
49
-
50
56
match state :
51
57
MOVE :
52
58
move_state (delta )
53
59
ROLL :
54
60
roll_state ()
55
61
ATTACK :
56
62
attack_state ()
57
-
63
+
64
+
58
65
func move_state (delta ):
59
66
var input_vector = Vector2 .ZERO
60
67
input_vector .x = Input .get_action_strength ("ui_right" ) - Input .get_action_strength ("ui_left" )
@@ -81,26 +88,32 @@ func move_state(delta):
81
88
82
89
if Input .is_action_just_pressed ("attack" ):
83
90
state = ATTACK
84
-
91
+
92
+
85
93
func roll_state ():
86
94
velocity = roll_vector * ROLL_SPEED
87
95
animationState .travel ("Roll" )
88
96
move ()
89
-
97
+
98
+
90
99
func attack_state ():
91
100
velocity = Vector2 .ZERO
92
101
animationState .travel ("Attack" )
93
-
102
+
103
+
94
104
func move ():
95
105
velocity = move_and_slide (velocity )
96
-
106
+
107
+
97
108
func roll_animation_finished ():
98
109
velocity = velocity * 0.8
99
110
state = MOVE
100
111
112
+
101
113
func attack_animation_finished ():
102
114
state = MOVE
103
115
116
+
104
117
func _on_Hurtbox_area_entered (area ):
105
118
stats .health -= area .damage
106
119
hurtbox .start_invincibility (0.6 )
@@ -109,8 +122,11 @@ func _on_Hurtbox_area_entered(area):
109
122
get_tree ().current_scene .add_child (playerHurtSound )
110
123
playerHealth += 1
111
124
if playerHealth == 4 :
125
+ timer2 .set_wait_time (2 )
126
+ timer2 .start ()
112
127
get_tree ().change_scene ("res://Game Over/GameOver.tscn" )
113
128
129
+
114
130
func _on_Hurtbox_invinciblity_started ():
115
131
blinkAnimationPlayer .play ("Start" )
116
132
@@ -125,6 +141,13 @@ func _on_FlowerHitBox_area_entered(area):
125
141
stats .health += 1
126
142
127
143
128
-
129
144
func _on_SwordHitbox_area_entered (area ):
130
145
check_enemies ()
146
+
147
+
148
+ func _on_Timer_timeout ():
149
+ pass
150
+
151
+
152
+ func _on_Timer2_timeout ():
153
+ pass
0 commit comments