bullet.gd 575 B

1234567891011121314151617181920212223242526272829
  1. extends KinematicBody2D
  2. var direction = Vector2()
  3. export(float) var SPEED = 1000.0
  4. func _ready():
  5. set_as_toplevel(true)
  6. func _physics_process(delta):
  7. if is_outside_view_bounds():
  8. queue_free()
  9. var motion = direction * SPEED * delta
  10. var collision_info = move_and_collide(motion)
  11. if collision_info:
  12. queue_free()
  13. func is_outside_view_bounds():
  14. return position.x > OS.get_screen_size().x or position.x < 0.0 \
  15. or position.y > OS.get_screen_size().y or position.y < 0.0
  16. func _draw():
  17. draw_circle(Vector2(), $CollisionShape2D.shape.radius, Color('#ffffff'))