Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends KinematicBody2D
- const SPEED = 100
- const GRAVITY = 10
- const JUMP_POWER = -250
- 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")
- elif Input.is_action_pressed("move_right") && isAttacking == false:
- velocity.x = SPEED
- $player.play("walk")
- if Input.is_action_pressed("ui_up") && isAttacking == false:
- if on_ground == true:
- velocity.y = JUMP_POWER
- on_ground = false
- if Input.is_action_just_pressed("attack_jab"):
- $player.play("jab");
- isAttacking = true;
- on_ground = true
- if Input.is_action_just_pressed("roundhouse"):
- $player.play('roundhouse')
- isAttacking = true;
- on_ground = true;
- velocity.y += GRAVITY
- velocity = move_and_slide(velocity, FLOOR)
- if is_on_floor():
- on_ground = true
- else:
- on_ground = false
- func _on_player_animation_finished():
- if $player.animation == 'jab:':
- isAttacking = false;
- on_ground = true;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement