Bomb.gd 802 B

123456789101112131415161718192021222324252627282930313233343536
  1. extends "res://entities/GridBasedMovable.gd"
  2. @onready var invulnerable_timer = $InvulnerableTimer
  3. func _physics_process(delta):
  4. _handle_movement(delta)
  5. func _on_Health_no_health() -> void:
  6. explode()
  7. func _ready() -> void:
  8. super._ready()
  9. enable_movement = false
  10. invincible = true
  11. await get_tree().create_timer(0.2).timeout
  12. invincible = false
  13. enable_movement = true
  14. func hit():
  15. explode()
  16. func explode():
  17. #if !invulnerable_timer.is_stopped():
  18. # "called explode while invulnerable"
  19. # return
  20. var Explosion = load("res://entities/BombExplosion.tscn")
  21. var explosion_instance = Explosion.instantiate()
  22. var game = SceneManager.game_scene
  23. game.add_child(explosion_instance)
  24. explosion_instance.position = position
  25. print ("explosion at: " + str(position))
  26. call_deferred("queue_free")