Advertisement
Guest User

Untitled

a guest
Feb 4th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
GDB 0.43 KB | None | 0 0
  1. extends KinematicBody2D
  2.  
  3. const SPEED =200
  4. const GRAVITY = 10
  5. const JUMP_POWER = -400
  6.  
  7. var velocity = Vector2()
  8.  
  9.  
  10. func _process(delta):
  11.  
  12.     velocity.y += GRAVITY
  13.  
  14.     if Input.is_action_pressed("ui_right"):
  15.         velocity.x = SPEED
  16.  
  17.  
  18.     elif Input.is_action_pressed("ui_left"):
  19.         velocity.x = -SPEED
  20.  
  21.  
  22.     else:
  23.         velocity.x = 0
  24.  
  25.  
  26.     if Input.is_action_just_pressed("ui_up"):
  27.         velocity.y = JUMP_POWER
  28.  
  29.     move_and_slide(velocity)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement