godot-shooter / asteroids / files / weapons / Bomb.gd
Branch asteroids · default branch · all branches
Bomb.gd
| 1 | extends Node2D |
| 2 | |
| 3 | var hurt_enemies = [] |
| 4 | export var damage_amount = 50 |
| 5 | |
| 6 | func _ready() -> void: |
| 7 | $AnimationPlayer.play("explode") |
| 8 | pass # Replace with function body. |
| 9 | |
| 10 | func _on_Area2D_body_entered(body: Node) -> void: |
| 11 | if body is Enemy: |
| 12 | var already_hurt_enemy = hurt_enemies.has(body) |
| 13 | if already_hurt_enemy: |
| 14 | return |
| 15 | hurt_enemies.push_back(body) |
| 16 | body.hurt(damage_amount) |