Duck and slide states and handling stub

This commit is contained in:
Jakob Feldmann 2022-07-25 22:51:27 +02:00
parent 1351dbb004
commit 59e87c846a
3 changed files with 24 additions and 3 deletions

View File

@ -94,6 +94,14 @@ texture={
[input] [input]
ui_accept={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777221,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777222,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":32,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
]
}
move_left={ move_left={
"deadzone": 0.5, "deadzone": 0.5,
"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null) "events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null)
@ -126,6 +134,12 @@ boost_move={
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":1,"pressure":0.0,"pressed":false,"script":null) , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":1,"pressure":0.0,"pressed":false,"script":null)
] ]
} }
duck={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"physical_scancode":0,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
]
}
[layer_names] [layer_names]

View File

@ -133,6 +133,9 @@ script = ExtResource( 2 )
[node name="BlobbyStateMachine" type="Node" parent="."] [node name="BlobbyStateMachine" type="Node" parent="."]
script = ExtResource( 3 ) script = ExtResource( 3 )
coyote_hanging = null
init_boost = null
init_boost_type = null
[node name="JumpBufferTimer" type="Timer" parent="BlobbyStateMachine"] [node name="JumpBufferTimer" type="Timer" parent="BlobbyStateMachine"]
wait_time = 0.067 wait_time = 0.067

View File

@ -14,6 +14,7 @@ onready var sprite = parent.get_node("BlobbySprite")
# Adds the intial states # Adds the intial states
func _ready(): func _ready():
add_state("idle") add_state("idle")
add_state("duck")
add_state("run") add_state("run")
add_state("walk") add_state("walk")
add_state("jump") add_state("jump")
@ -40,6 +41,8 @@ func _state_logic(delta):
match self.state: match self.state:
"idle": "idle":
handle_input_ref = funcref(self, "handle_idle_input") handle_input_ref = funcref(self, "handle_idle_input")
"duck":
handle_input_ref = funcref(self, "handle_duck_input")
"walk": "walk":
handle_input_ref = funcref(self, "handle_walk_input") handle_input_ref = funcref(self, "handle_walk_input")
"run": "run":
@ -65,11 +68,10 @@ func _state_logic(delta):
func handle_idle_input(delta, direction) -> Vector2: func handle_idle_input(delta, direction) -> Vector2:
if Input.is_action_pressed("boost_move"):
return parent.handle_grounded_movement(delta, direction)
else:
return parent.handle_grounded_movement(delta, direction) return parent.handle_grounded_movement(delta, direction)
func handle_duck_input(delta, direction) -> Vector2:
return parent.handle_duck_movement(delta, direction)
func handle_walk_input(delta, direction) -> Vector2: func handle_walk_input(delta, direction) -> Vector2:
return parent.handle_grounded_movement(delta, direction) return parent.handle_grounded_movement(delta, direction)
@ -144,6 +146,8 @@ func _get_transition(_delta):
elif parent.velocity.x != 0: elif parent.velocity.x != 0:
if Input.is_action_pressed("boost_move"): if Input.is_action_pressed("boost_move"):
new_state = states.run new_state = states.run
elif Input.is_action_just_pressed("duck"):
new_state = states.duck
else: else:
new_state = states.walk new_state = states.walk
coyote_hanging = false coyote_hanging = false