Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends KinematicBody2D
- const SPEED = 300
- const GRAVITY = 40
- const NORMAL = Vector2(0, -1)
- const FORCA_JUMP = -800
- var motion = Vector2()
- var screen_size
- func _ready():
- screen_size = get_viewport().size
- func _physics_process(delta):
- _movimento()
- func _movimento():
- motion.y += GRAVITY
- #LEFT AND RIGHT
- if Input.is_action_pressed("ui_left"):
- motion.x = -SPEED
- $Sprite.play("Walk")
- $Sprite.flip_h = false
- elif Input.is_action_pressed("ui_right"):
- motion.x = SPEED
- $Sprite.play("Walk")
- $Sprite.flip_h = true
- else:
- motion.x = 0
- $Sprite.play("Idle")
- # ATTACK
- if Input.is_action_just_released("ui_down"):
- $Sprite.play("Golpe_1")
- #JUMP
- if is_on_floor():
- if Input.is_action_just_pressed("ui_up"):
- motion.y = FORCA_JUMP
- else:
- $Sprite.play("Jump")
- motion = move_and_slide(motion,NORMAL)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement