diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-09-20 22:12:44 +0200 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-09-20 22:12:44 +0200 |
commit | a38f65c261e9d7b23d046cb76b5aeedc05c4b54d (patch) | |
tree | 8cc96d41dc44b75ac1e9f2b95735af7c753a7c74 /whispy_woods.gd | |
parent | 3fdb011ef62249a514a8eba2556cc9f6ea5ea477 (diff) |
next commit
Diffstat (limited to 'whispy_woods.gd')
-rw-r--r-- | whispy_woods.gd | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/whispy_woods.gd b/whispy_woods.gd new file mode 100644 index 0000000..b5f4058 --- /dev/null +++ b/whispy_woods.gd @@ -0,0 +1,58 @@ +extends Area2D + + +var hp: int = 6 : + set(value): + hp = value + Game.boss_hp_changed.emit(hp) + + +func _ready() -> void: + Game.boss_initialized.emit(hp) + + +func _process(_delta: float) -> void: + # TODO: spawn apples + # TODO: blow wind + pass + + +func hit_by_projectile(hit_position: Vector2): + var effect_star_scene := preload("res://effect_star.tscn") + for direction in [Vector2(1, 1), Vector2(1, -1), Vector2(-1, -1), Vector2(-1, 1)]: + var effect_star := effect_star_scene.instantiate() + effect_star.global_position = hit_position + get_tree().current_scene.add_child(effect_star) + var tween := get_tree().create_tween() + tween.tween_property( + effect_star, + "global_position", + effect_star.global_position + direction * 16, + 0.1 + ) + tween.tween_callback(func(): + effect_star.queue_free() + ) + + SoundManager.play_sound("Hurt") + + hp -= 1 + + $EyeRight.play("eye_closed") + $Mouth.play("eye_closed") + $Tear.visible = true + var tween = get_tree().create_tween() + tween.tween_property(self, "modulate", Color(1, 1, 1, 0.2), 0.1) + tween.tween_property(self, "modulate", Color(1, 1, 1, 0.8), 0.1) + tween.tween_property(self, "modulate", Color(1, 1, 1, 0.2), 0.1) + tween.tween_property(self, "modulate", Color(1, 1, 1, 0.8), 0.1) + + if hp > 0: + tween.tween_callback(func(): + modulate = Color(1, 1, 1, 1.0) + $EyeRight.play("eye_open") + $Mouth.play("mouth_idle") + $Tear.visible = false + ) + elif hp <= 0: + Game.boss_defeated.emit() |