Advertisement
HoleForYou

bullet script

Jun 22nd, 2022
1,297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extends AnimatedSprite
  2.  
  3. var direction = 0
  4. var speed = 20
  5. var timer = 0
  6.  
  7. func _ready():
  8.    
  9.     scale = Vector2(0.5, 0.25)
  10.     playing = true
  11.  
  12. func _process(delta):
  13.    
  14.     timer += delta
  15.     if timer > 0.5: queue_free()
  16.    
  17.     scale = scale.linear_interpolate(Vector2(1, 1), delta * 12)
  18.    
  19.     if direction == 0:
  20.         position -= Vector2(speed * 10 * delta, 0)
  21.         flip_h = true
  22.     else:
  23.         position += Vector2(speed * 10 * delta, 0)
  24.         flip_h = false
  25.  
  26. func _on_Area2D_body_entered(body):
  27.    
  28.     if body.has_method("hit"):
  29.         body.hit()
  30.         queue_free()
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement