forked from AlyssonDaPaz/Mega-Man-X8-16-bit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWallslide.gd
67 lines (52 loc) · 1.69 KB
/
Wallslide.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
extends Movement
class_name WallSlide
export var start_delay := 0.16
export var block_timer := 0.0
onready var particles = character.get_node("animatedSprite").get_node("WallSlide Particles")
var horizontal_speed = 90
var wallgrab_direction := 0
func _Setup() -> void:
character.emit_signal("wallslide")
character.set_direction(- get_pressed_direction())
wallgrab_direction = get_pressed_direction()
func _Update(_delta: float) -> void:
character.set_horizontal_speed(horizontal_speed * wallgrab_direction)
if delay_has_expired():
emit_particles(particles,true)
character.set_vertical_speed(jump_velocity)
func _StartCondition() -> bool:
if not character.is_on_floor() and not block_timer > 0:
if character.is_colliding_with_wall() != 0:
if character.get_vertical_speed() > 0:
if get_pressed_direction() == character.is_colliding_with_wall():
return true
return false
func _EndCondition() -> bool:
if character.is_on_floor():
Log("Floor detected")
return true
if not character.is_in_reach_for_walljump():
Log("No wall detected")
block_timer = 0.01
return true
if get_pressed_direction() != character.is_in_reach_for_walljump():
Log("Not pressing towards wall")
return true
if get_pressed_direction() == 0:
Log("Not pressing")
return true
return false
func _physics_process(delta: float) -> void:
if block_timer > 0:
block_timer += delta
if block_timer > 0.15:
block_timer = 0
func _Interrupt():
if character.get_vertical_speed() > 0:
character.set_vertical_speed(40)
character.set_horizontal_speed(0)
emit_particles(particles,false)
func delay_has_expired() -> bool:
return timer > start_delay
func should_execute_on_hold() -> bool:
return true