Hashtop

Cena player pong

Nov 5th, 2020
233
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. parent é um kinematicbody2d
  2. collisionshape2d - extends 5, 125
  3. sprite - texture player com scale 0.5, 0.5
  4.  
  5. //código
  6. extends KinematicBody2D
  7.  
  8. export var player := 1
  9.  
  10. var velocity
  11.  
  12. var speed = 300
  13. var dir = Vector2.ZERO
  14.  
  15. func _physics_process(delta: float) -> void:
  16.     get_input(delta)
  17.    
  18.    
  19.  
  20.  
  21. func get_input(delta):
  22.     dir = Vector2.ZERO
  23.     if Input.is_action_pressed("up" + str(player)):
  24.         dir.y -= 1
  25.    
  26.     if Input.is_action_pressed("down" + str(player)):
  27.         dir.y += 1
  28.    
  29.     dir = dir.normalized()
  30.    
  31.     velocity = speed * dir
  32.    
  33.     move_and_slide(velocity) * delta
  34.  
RAW Paste Data