SHARE
TWEET

Untitled

a guest Aug 13th, 2019 143 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extends KinematicBody2D
  2.  
  3. const SPEED = 300
  4. const GRAVITY = 40
  5. const NORMAL = Vector2(0, -1)
  6. const FORCA_JUMP = -800
  7. var motion = Vector2()
  8. var screen_size
  9.  
  10. func _ready():
  11.     screen_size = get_viewport().size
  12.  
  13. func _physics_process(delta):
  14.     _movimento()
  15.  
  16. func _movimento():
  17.    
  18.     motion.y += GRAVITY
  19.    
  20.     #LEFT AND RIGHT
  21.     if Input.is_action_pressed("ui_left"):
  22.         motion.x = -SPEED
  23.         $Sprite.play("Walk")
  24.         $Sprite.flip_h = false
  25.     elif Input.is_action_pressed("ui_right"):
  26.         motion.x = SPEED
  27.         $Sprite.play("Walk")
  28.         $Sprite.flip_h = true
  29.     else:
  30.             motion.x = 0
  31.             $Sprite.play("Idle")
  32.  
  33.     # ATTACK
  34.     if Input.is_action_just_released("ui_down"):
  35.         $Sprite.play("Golpe_1")
  36.  
  37.    
  38.     #JUMP
  39.     if is_on_floor():
  40.         if Input.is_action_just_pressed("ui_up"):
  41.             motion.y = FORCA_JUMP
  42.     else:
  43.         $Sprite.play("Jump")
  44.        
  45.    
  46.     motion = move_and_slide(motion,NORMAL)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top