Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extends KinematicBody2D
- const SPEED = 210
- var dir = "down"
- var move = Vector2()
- var input = false
- func _ready():
- func _physics_process(delta):
- if Input.is_action_pressed("ui_up"):
- move.y += SPEED
- dir = "up"
- elif Input.is_action_pressed("ui_down"):
- move.y -= SPEED
- dir = "down"
- else:
- move.y = 0
- if Input.is_action_pressed("ui_right"):
- move.x += SPEED
- dir = "right"
- elif Input.is_action_pressed("ui_left"):
- move.x -= SPEED
- dir = "left"
- else:
- move.x = 0
- if Input.is_action_pressed("ui_up") or Input.is_action_pressed("ui_down") or Input.is_action_pressed("ui_right") or Input.is_action_pressed("ui_left"):
- input = true
- if dir == "down":
- $AnimatedSprite.play("idle_down")
- if input == true:
- §AnimatedSprite2D("walk_down")
- move_and_slide(move)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement