1
0

core.gd 681 B

123456789101112131415161718192021222324252627
  1. class_name Core
  2. extends StaticBody2D
  3. ## The red core. Hitting it in the game scene wins the level.
  4. @export var radius := Params.CORE_RADIUS
  5. func _ready() -> void:
  6. collision_layer = Params.LAYER_BLOCKS
  7. collision_mask = 0
  8. var shape := CircleShape2D.new()
  9. shape.radius = radius
  10. var collision := CollisionShape2D.new()
  11. collision.shape = shape
  12. add_child(collision)
  13. ## Grows to fill the screen; returns when the animation ends.
  14. func explode() -> void:
  15. collision_layer = 0
  16. var tween := create_tween()
  17. tween.tween_property(self, "scale", scale * 20.0, 1.0)
  18. await tween.finished
  19. func _draw() -> void:
  20. draw_circle(Vector2.ZERO, radius, Params.COLOR_RED, true, -1.0, true)