Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. extends KinematicBody2D
  2.  
  3. const SPEED = 210
  4. var dir = "down"
  5. var move = Vector2()
  6.  
  7. func _ready():
  8.  
  9. func _physics_process(delta):
  10.     if Input_is_action_pressed("ui_up):
  11.         move.y += SPEED
  12.         dir = "up"
  13.         elif Input.is_action_pressed("ui_down"):
  14.             move.y -= SPEED
  15.             dir = "down"
  16.     else:
  17.         move.y = 0
  18.    
  19.     if Input.is_action_pressed("ui_right"):
  20.         move.x += SPEED
  21.         dir = right
  22.         elif Input.is_action_pressed("ui_left"):
  23.             move.x -= SPEED
  24.             dir = left
  25.  
  26. move_and_slide()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement