core.gd 785 B

12345678910111213141516171819202122232425262728
  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. # Inset like the blocks, so the gap to the first ring matches the gap between tiles.
  21. draw_circle(Vector2.ZERO, radius - Block.GAP / 2.0, Params.COLOR_RED, true, -1.0, true)