Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var current = state_machine.get_current_node()
- velocity.y += _gravity
- if velocity.y > MAXFALLSPEED:
- velocity.y = MAXFALLSPEED
- elif velocity.y > 0:
- state_machine.travel("fall 2")
- else:
- if sworddrawn && current == "idle":
- state_machine.travel("idle-2")
- if Input.is_action_just_pressed("Light Attack"):
- if (current == "idle-2" || current == "walk 2"):
- state_machine.travel(attacks[randi()%2])
- return
- elif current == "idle":
- state_machine.travel("punch")
- return
- elif current == "walk":
- state_machine.travel("run-punch")
- return
- if Input.is_action_just_pressed("Heavy Attack"):
- if (current == "idle-2" || current == "walk 2"):
- state_machine.travel("attack1")
- return
- elif current == "idle":
- state_machine.travel("kick")
- return
- if Input.is_action_just_pressed("Draw Sword Sheathe Sword"):
- if sworddrawn:
- state_machine.travel("idle")
- sworddrawn = false
- elif !sworddrawn:
- state_machine.travel("idle-2")
- sworddrawn = true
- if is_on_floor:
- if Input.is_action_pressed("move_right"):
- if sworddrawn:
- state_machine.travel("walk 2")
- if not sworddrawn:
- state_machine.travel("walk")
- velocity.x = MAXSPEED
- $Sprite.scale.x = 1
- elif Input.is_action_pressed("move_left"):
- if sworddrawn:
- state_machine.travel("walk 2")
- if not sworddrawn:
- state_machine.travel("walk")
- velocity.x = -MAXSPEED
- $Sprite.scale.x = -1
- else:
- velocity.x = 0
- if sworddrawn:
- state_machine.travel("idle-2")
- elif not sworddrawn:
- state_machine.travel("idle")
- if Input.is_action_just_pressed("jump"):
- state_machine.travel("jump")
- velocity.y = -JUMPFORCE
- if Input.is_action_pressed("move_right"):
- velocity.x = MAXSPEED
- $Sprite.scale.x = 1
- elif Input.is_action_pressed("move_left"):
- velocity.x = -MAXSPEED
- $Sprite.scale.x = -1
- else:
- velocity.x = 0
- velocity = move_and_slide(velocity,vector2.UP)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement