Brick.gd 446 B

1234567891011121314151617181920212223242526272829303132
  1. extends StaticBody2D
  2. signal kace_broken
  3. signal kace_damaged
  4. var life: int
  5. func setup(x: int, y: int, max_life: int):
  6. position.x = x * 40
  7. position.y = y * 20
  8. life = randi() % max_life + 1
  9. update() # For custom drawing
  10. func damage():
  11. life = life - 1
  12. emit_signal("kace_damaged")
  13. update() # For custom drawing
  14. if life < 1:
  15. blow_up()
  16. func blow_up():
  17. emit_signal("kace_broken")
  18. queue_free()
  19. func impact(pos: Vector2):
  20. damage()