Advertisement
salahzar

move sprite.gd

Jan 16th, 2019
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. extends KinematicBody2D
  2.  
  3. # Declare member variables here. Examples:
  4. # var a = 2
  5. # var b = "text"
  6. const SPEED = 200
  7. const GRAVITY = 100
  8. const JUMP = 500
  9. # Called when the node enters the scene tree for the first time.
  10. func _ready():
  11.     pass # Replace with function body.
  12.  
  13. func _physics_process(delta):
  14.     var move = Vector2()
  15.     if Input.is_action_pressed("ui_down"):
  16.         move.y = SPEED
  17.     if Input.is_action_pressed("ui_up"):
  18.         move.y = -SPEED
  19.     if Input.is_action_pressed("ui_left"):
  20.         move.x = -SPEED
  21.     if Input.is_action_pressed("ui_right"):
  22.         move.x = SPEED
  23.        
  24.     if Input.is_action_pressed("ui_accept"):
  25.         move.y -= JUMP
  26.    
  27.        
  28.     move.y += 100
  29.  
  30.     move_and_slide(move)
  31. #
  32. #   -------> aumenta la x
  33. #   |
  34. #   v   aumenta  la y
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement