rename hit variables
This commit is contained in:
parent
56004d5b9b
commit
51846f007f
3 changed files with 13 additions and 13 deletions
|
|
@ -2,7 +2,7 @@ extends PlayerState
|
||||||
|
|
||||||
|
|
||||||
var previous_state_path: String
|
var previous_state_path: String
|
||||||
var hit_dir: String
|
var hit_type: String
|
||||||
var hit_node_ref: WeakRef
|
var hit_node_ref: WeakRef
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -11,19 +11,19 @@ func _enter(_previous_state_path: String, _data: Dictionary[String, Variant] = {
|
||||||
player.velocity = Vector2.ZERO
|
player.velocity = Vector2.ZERO
|
||||||
player.move_and_slide()
|
player.move_and_slide()
|
||||||
assert(
|
assert(
|
||||||
_data.get("hit_dir") == "left" or _data.get("hit_dir") == "right",
|
_data.get("hit") == "left" or _data.get("hit") == "right",
|
||||||
"Invalid hit_dir ("+str(_data.get("hit_dir"))+")."
|
"Invalid hit_type ("+str(_data.get("hit"))+")."
|
||||||
)
|
)
|
||||||
print("previous state path: "+_previous_state_path)
|
print("previous state path: "+_previous_state_path)
|
||||||
|
|
||||||
previous_state_path = _previous_state_path
|
previous_state_path = _previous_state_path
|
||||||
hit_dir = _data.get("hit_dir")
|
hit_type = _data.get("hit")
|
||||||
|
|
||||||
#player.sprite.play('up' if player.id == 1 else 'down')
|
#player.sprite.play('up' if player.id == 1 else 'down')
|
||||||
#player.sprite.frame = 1
|
#player.sprite.frame = 1
|
||||||
#player.sprite.pause()
|
#player.sprite.pause()
|
||||||
|
|
||||||
player.anim_player.play("hit_"+hit_dir+"_up" if player.id == 1 else "hit_"+hit_dir+"_down")
|
player.anim_player.play("hit_"+hit_type+"_up" if player.id == 1 else "hit_"+hit_type+"_down")
|
||||||
assert(
|
assert(
|
||||||
player.anim_player.current_animation == "hit_left_up" or
|
player.anim_player.current_animation == "hit_left_up" or
|
||||||
player.anim_player.current_animation == "hit_left_down" or
|
player.anim_player.current_animation == "hit_left_down" or
|
||||||
|
|
@ -38,7 +38,7 @@ func _enter(_previous_state_path: String, _data: Dictionary[String, Variant] = {
|
||||||
# flip entire node horizontally if spawning left
|
# flip entire node horizontally if spawning left
|
||||||
# flip vertically if player 2
|
# flip vertically if player 2
|
||||||
hit_node.scale = Vector2(
|
hit_node.scale = Vector2(
|
||||||
-1 if hit_dir == "left" else 1,
|
-1 if hit_type == "left" else 1,
|
||||||
1 if player.id == 1 else -1
|
1 if player.id == 1 else -1
|
||||||
)
|
)
|
||||||
player.add_child(hit_node)
|
player.add_child(hit_node)
|
||||||
|
|
@ -46,7 +46,7 @@ func _enter(_previous_state_path: String, _data: Dictionary[String, Variant] = {
|
||||||
# set position according to frame width and height
|
# set position according to frame width and height
|
||||||
@warning_ignore("integer_division")
|
@warning_ignore("integer_division")
|
||||||
hit_node.global_position = player.global_position + Vector2(
|
hit_node.global_position = player.global_position + Vector2(
|
||||||
(sprite_texture.get_width()/2)*(-1 if hit_dir == "left" else 1),
|
(sprite_texture.get_width()/2)*(-1 if hit_type == "left" else 1),
|
||||||
(sprite_texture.get_height()*-1) if player.id == 1 else 4
|
(sprite_texture.get_height()*-1) if player.id == 1 else 4
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -74,10 +74,10 @@ func _on_hit_end() -> void:
|
||||||
return
|
return
|
||||||
elif Input.is_action_pressed('p'+str(player.id)+'_hit_left'):
|
elif Input.is_action_pressed('p'+str(player.id)+'_hit_left'):
|
||||||
print("transitioning to hitting left")
|
print("transitioning to hitting left")
|
||||||
finished.emit(HITTING, {"hit_dir": "left"})
|
finished.emit(HITTING, {"hit": "left"})
|
||||||
return
|
return
|
||||||
elif Input.is_action_pressed('p'+str(player.id)+'_hit_right'):
|
elif Input.is_action_pressed('p'+str(player.id)+'_hit_right'):
|
||||||
print("transitioning to hitting right")
|
print("transitioning to hitting right")
|
||||||
finished.emit(HITTING, {"hit_dir": "right"})
|
finished.emit(HITTING, {"hit": "right"})
|
||||||
return
|
return
|
||||||
printerr("hit cooldown did not return")
|
printerr("hit cooldown did not return")
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ func _state_physics_update(_delta: float) -> void:
|
||||||
finished.emit(RUNNING)
|
finished.emit(RUNNING)
|
||||||
return
|
return
|
||||||
elif Input.is_action_pressed('p'+str(player.id)+'_hit_left'):
|
elif Input.is_action_pressed('p'+str(player.id)+'_hit_left'):
|
||||||
finished.emit(HITTING, {"hit_dir": "left"})
|
finished.emit(HITTING, {"hit": "left"})
|
||||||
return
|
return
|
||||||
elif Input.is_action_pressed('p'+str(player.id)+'_hit_right'):
|
elif Input.is_action_pressed('p'+str(player.id)+'_hit_right'):
|
||||||
finished.emit(HITTING, {"hit_dir": "right"})
|
finished.emit(HITTING, {"hit": "right"})
|
||||||
return
|
return
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@ func _state_physics_update(_delta: float) -> void:
|
||||||
finished.emit(IDLE)
|
finished.emit(IDLE)
|
||||||
return
|
return
|
||||||
elif Input.is_action_just_pressed('p'+str(player.id)+'_hit_left'):
|
elif Input.is_action_just_pressed('p'+str(player.id)+'_hit_left'):
|
||||||
finished.emit(HITTING, {"hit_dir": "left"})
|
finished.emit(HITTING, {"hit": "left"})
|
||||||
return
|
return
|
||||||
elif Input.is_action_just_pressed('p'+str(player.id)+'_hit_right'):
|
elif Input.is_action_just_pressed('p'+str(player.id)+'_hit_right'):
|
||||||
finished.emit(HITTING, {"hit_dir": "right"})
|
finished.emit(HITTING, {"hit": "right"})
|
||||||
return
|
return
|
||||||
|
|
||||||
if abs(player.velocity.x) > abs(player.velocity.y):
|
if abs(player.velocity.x) > abs(player.velocity.y):
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue