Advertisement
Guest User

Untitled

a guest
Apr 18th, 2023
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. extends Area2D
  2.  
  3. export var Speed:int
  4. var velocity = Vector2()
  5. var screensize = Vector2 (480, 720)
  6. func get_input():
  7. velocity = Vector2()
  8. if Input.is_action_pressed ("ui_left"):
  9. velocity.x -= 1
  10. if Input.is_action_pressed ("ui_right"):
  11. velocity.x += 1
  12. if Input.is_action_pressed ("ui_up"):
  13. velocity.y -= 1
  14. if Input.is_action_pressed ("ui_down"):
  15. velocity.y += 1
  16. if velocity.length() > 0:
  17. velocity = velocity.normalized() * Speed
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement