Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends KinematicBody2D
- const SPEED = 100
- const GRAVITY = 60
- const JUMP_POWER = -180
- const FLOOR = Vector2(0, -1)
- var velocity = Vector2()
- var on_ground = false
- var isAttacking = false
- func _physics_process(_delta):
- if Input.is_action_pressed("ui_left") && isAttacking == false:
- velocity.x = -SPEED
- $player.play("walk")
- on_ground = true
- elif Input.is_action_pressed("move_right") && isAttacking == false:
- velocity.x = SPEED
- $player.play("walk")
- on_ground = true
- else:
- on_ground = true
- velocity.x = 0
- if Input.is_action_pressed("ui_up") && isAttacking == false:
- on_ground = true
- velocity.y = JUMP_POWER
- on_ground = false
- else:
- on_ground = true
- if Input.is_action_just_pressed("attack_jab"):
- $player.play("jab");
- isAttacking = true;
- on_ground = true
- else:
- isAttacking = false
- if Input.is_action_just_pressed("roundhouse"):
- $player.play('roundhouse')
- isAttacking = true;
- on_ground = true;
- else:
- isAttacking = false
- if Input.is_action_just_pressed("teep"):
- $player.play('teep')
- isAttacking = true;
- on_ground = true;
- if Input.is_action_just_pressed("attack_jab") and Input.is_action_pressed("move_right"):
- $player.play("elbow");
- isAttacking = true;
- on_ground = true
- else:
- isAttacking = false
- if Input.is_action_just_pressed("attack cross"):
- $player.play('cross')
- isAttacking = true;
- on_ground = true;
- else:
- isAttacking = false
- if Input.is_action_pressed("ui_up") && isAttacking == false:
- on_ground = true
- velocity.y = JUMP_POWER
- on_ground = false
- velocity.y += GRAVITY
- velocity = move_and_slide(velocity, FLOOR)
- func _on_player_animation_finished():
- if on_ground == true && isAttacking == false:
- $player.play("idle")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement