1
0

core.gd 883 B

1234567891011121314151617181920212223242526272829
  1. class_name Core
  2. extends StaticBody2D
  3. ## The red core. Hitting it in the game scene wins the level.
  4. ## Nominal radius; the core is drawn and collides [constant Block.GAP] / 2 inside it, like the
  5. ## blocks, so the gap to the first ring matches the gap between tiles.
  6. @export var radius := Params.CORE_RADIUS
  7. func _ready() -> void:
  8. collision_layer = Params.LAYER_BLOCKS
  9. collision_mask = 0
  10. var shape := CircleShape2D.new()
  11. shape.radius = radius - Block.GAP / 2.0
  12. var collision := CollisionShape2D.new()
  13. collision.shape = shape
  14. add_child(collision)
  15. ## Grows to fill the screen; returns when the animation ends.
  16. func explode() -> void:
  17. collision_layer = 0
  18. var tween := create_tween()
  19. tween.tween_property(self, "scale", scale * 20.0, 1.0)
  20. await tween.finished
  21. func _draw() -> void:
  22. draw_circle(Vector2.ZERO, radius - Block.GAP / 2.0, Params.COLOR_RED, true, -1.0, true)