From e89b80a825f4299c9d030a601e6dc4fa1dd2402d Mon Sep 17 00:00:00 2001 From: Artur David Date: Tue, 14 Apr 2026 16:35:50 +0200 Subject: [PATCH] cauldron change color based on collected fruits --- scenes/witch.tscn | 2 +- scripts/apple.gd | 2 +- scripts/cauldron_bar.gd | 13 ++++++++++++- scripts/grape.gd | 4 ++-- scripts/witch.gd | 2 +- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/scenes/witch.tscn b/scenes/witch.tscn index 2ec769d..f9333ed 100644 --- a/scenes/witch.tscn +++ b/scenes/witch.tscn @@ -255,7 +255,7 @@ region = Rect2(96, 96, 96, 96) [sub_resource type="AtlasTexture" id="AtlasTexture_gyfn7"] atlas = ExtResource("5_vid1f") -region = Rect2(288, 192, 96, 96) +region = Rect2(480, 96, 96, 96) [node name="Witch" type="CharacterBody2D" unique_id=1188927311] script = ExtResource("1_b1vsk") diff --git a/scripts/apple.gd b/scripts/apple.gd index 20fc21e..17c58df 100644 --- a/scripts/apple.gd +++ b/scripts/apple.gd @@ -1,5 +1,5 @@ extends DropsBase - +class_name Apple # Called when the node enters the scene tree for the first time. diff --git a/scripts/cauldron_bar.gd b/scripts/cauldron_bar.gd index a4e88ab..c98cde3 100644 --- a/scripts/cauldron_bar.gd +++ b/scripts/cauldron_bar.gd @@ -4,6 +4,7 @@ var base = AtlasTexture.new() var yellow = AtlasTexture.new() var orange = AtlasTexture.new() var red = AtlasTexture.new() +var purple = AtlasTexture.new() var slots: Array[TextureRect] = [] var colors: Array[AtlasTexture] = [] var burning_colors: Array[AtlasTexture] = [] @@ -19,8 +20,10 @@ func _ready() -> void: orange.region = Rect2(192, 96, 96, 96) red.atlas = preload("res://assets/Cauldron's Brew/Cauldron and Powder.png") red.region = Rect2(288, 96, 96, 96) + purple.atlas = preload("res://assets/Cauldron's Brew/Cauldron and Powder.png") + purple.region = Rect2(480, 96, 96, 96) slots = [$Empty1, $Empty2, $Empty3] - colors = [base, yellow, red, orange] + colors = [base, yellow, red, orange, purple] enrich_burning_colors() pass # Replace with function body. @@ -51,3 +54,11 @@ func enrich_burning_colors(): burning.atlas = color.atlas burning.region = Rect2(color.region.position.x, color.region.position.y + 96, 96, 96) burning_colors.append(burning) + +func progres_bar(fruit, progress): + + if fruit is Apple: + change_texture(progress,3) + if fruit is Grape: + change_texture(progress, 4) + pass diff --git a/scripts/grape.gd b/scripts/grape.gd index de0350a..10e975c 100644 --- a/scripts/grape.gd +++ b/scripts/grape.gd @@ -1,4 +1,4 @@ extends DropsBase - - +class_name Grape + # Called when the node enters the scene tree for the first time. diff --git a/scripts/witch.gd b/scripts/witch.gd index 6df9c04..d8ea78a 100644 --- a/scripts/witch.gd +++ b/scripts/witch.gd @@ -16,7 +16,7 @@ func _physics_process(delta: float) -> void: func _on_collect(DropsBase): if is_casting: return - $CauldronBar.change_texture(bar_progress,3) + $CauldronBar.progres_bar(DropsBase, bar_progress) bar_progress += 1 if bar_progress == 3: bar_progress = 0