From c2cbeba20c0937e97c2fe6c120568e2accb6af92 Mon Sep 17 00:00:00 2001 From: Artur <2123806@stud.th-mannheim.de> Date: Wed, 15 Apr 2026 07:11:06 +0200 Subject: [PATCH 1/3] created card ui --- scenes/PerkCard.tscn | 68 +++++++++++++++++++++++++++++++++++++ scenes/game.tscn | 30 ++++++++++++---- scripts/level_up_manager.gd | 4 ++- scripts/perk_card.gd | 4 +++ scripts/perk_card.gd.uid | 1 + scripts/perk_effects.gd | 6 ++-- 6 files changed, 102 insertions(+), 11 deletions(-) create mode 100644 scenes/PerkCard.tscn create mode 100644 scripts/perk_card.gd create mode 100644 scripts/perk_card.gd.uid diff --git a/scenes/PerkCard.tscn b/scenes/PerkCard.tscn new file mode 100644 index 0000000..2fa4c19 --- /dev/null +++ b/scenes/PerkCard.tscn @@ -0,0 +1,68 @@ +[gd_scene format=3 uid="uid://cgl06rqop270h"] + +[ext_resource type="Script" uid="uid://dw5y2tp34fxys" path="res://scripts/perk_card.gd" id="1_t8gqh"] +[ext_resource type="Texture2D" uid="uid://duo145bmwho8d" path="res://assets/UI assets pack 2/UI books & more.png" id="2_nlhlf"] +[ext_resource type="FontFile" uid="uid://cq0jx2aapggkg" path="res://assets/fonts/slkscrb.ttf" id="3_n4umd"] +[ext_resource type="FontFile" uid="uid://brooj0hba7650" path="res://assets/fonts/slkscr.ttf" id="4_40ty6"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_fgk3h"] +atlas = ExtResource("2_nlhlf") +region = Rect2(561, 17, 46, 62) + +[sub_resource type="LabelSettings" id="LabelSettings_qag4p"] +line_spacing = 0.0 +font = ExtResource("3_n4umd") +font_size = 5 + +[sub_resource type="LabelSettings" id="LabelSettings_ni87r"] +font = ExtResource("4_40ty6") +font_size = 3 + +[node name="PerkCard" type="Control" unique_id=1471811151] +layout_mode = 3 +anchors_preset = 0 +script = ExtResource("1_t8gqh") + +[node name="Card" type="TextureRect" parent="." unique_id=1832247473] +texture_filter = 1 +layout_mode = 0 +offset_right = 40.0 +offset_bottom = 40.0 +texture = SubResource("AtlasTexture_fgk3h") + +[node name="Description" type="Label" parent="Card" unique_id=2006873472] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -20.5 +offset_top = 7.0 +offset_right = 20.5 +offset_bottom = 23.0 +grow_horizontal = 2 +text = "AOE +-Feuerball" +label_settings = SubResource("LabelSettings_qag4p") +horizontal_alignment = 1 + +[node name="Name" type="Label" parent="Card" unique_id=859816848] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -20.0 +offset_top = -36.0 +offset_right = 20.0 +grow_horizontal = 2 +grow_vertical = 0 +text = "Das ist ein test" +label_settings = SubResource("LabelSettings_ni87r") +horizontal_alignment = 1 +autowrap_mode = 2 + +[node name="Button" type="Button" parent="." unique_id=1274377333] +layout_mode = 0 +offset_right = 46.0 +offset_bottom = 62.0 diff --git a/scenes/game.tscn b/scenes/game.tscn index 8086475..c446e16 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -2406,8 +2406,13 @@ script = ExtResource("10_vtaks") [node name="CanvasLayer" type="CanvasLayer" parent="." unique_id=1323249211] [node name="ProgressBar" type="ProgressBar" parent="CanvasLayer" unique_id=825658619] -offset_right = 607.0 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -303.5 +offset_right = 303.5 offset_bottom = 27.0 +grow_horizontal = 2 max_value = 5.0 step = 1.0 show_percentage = false @@ -2415,15 +2420,26 @@ show_percentage = false [node name="LevelUpManager" type="Control" parent="CanvasLayer" unique_id=292400493] process_mode = 3 layout_mode = 3 -anchors_preset = 0 -offset_right = 40.0 -offset_bottom = 40.0 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +grow_horizontal = 2 script = ExtResource("16_rysoc") [node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/LevelUpManager" unique_id=957625333] -layout_mode = 0 -offset_right = 40.0 -offset_bottom = 40.0 +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -20.0 +offset_top = 350.0 +offset_right = 20.0 +offset_bottom = 390.0 +grow_horizontal = 2 +grow_vertical = 2 +alignment = 1 [node name="PerkEffects" type="Node2D" parent="." unique_id=2027136639] script = ExtResource("16_ca42v") diff --git a/scripts/level_up_manager.gd b/scripts/level_up_manager.gd index df3766e..f34f622 100644 --- a/scripts/level_up_manager.gd +++ b/scripts/level_up_manager.gd @@ -24,8 +24,10 @@ func show_perks(): for x in chosen: var button = Button.new() button.text = x.name + "\n" + x.description + button.custom_minimum_size = Vector2(200, 500) + button.size_flags_horizontal = Control.SIZE_SHRINK_CENTER button.pressed.connect(func(): select_perk(x)) - $HBoxContainer.add_child(button) + $HBoxContainer.add_child(button) func select_perk(perk): perk.effect.call() diff --git a/scripts/perk_card.gd b/scripts/perk_card.gd new file mode 100644 index 0000000..509e895 --- /dev/null +++ b/scripts/perk_card.gd @@ -0,0 +1,4 @@ +extends Control + +@export var icon: Texture2D +# Called when the node enters the scene tree for the first time. diff --git a/scripts/perk_card.gd.uid b/scripts/perk_card.gd.uid new file mode 100644 index 0000000..b0c3dcd --- /dev/null +++ b/scripts/perk_card.gd.uid @@ -0,0 +1 @@ +uid://dw5y2tp34fxys diff --git a/scripts/perk_effects.gd b/scripts/perk_effects.gd index e8d0a4e..3306a28 100644 --- a/scripts/perk_effects.gd +++ b/scripts/perk_effects.gd @@ -12,17 +12,17 @@ func _ready() -> void: cauldron = witch.get_node("CauldronBar") var dsh = Perk.new() dsh.name = "Doppelter Shuriken" - dsh.description = "Wirft zwei Shurikens statt einem" + dsh.description = "Wirft zwei Shurikens\n statt einem" dsh.effect = double_shuriken available_perks.append(dsh) var faoe = Perk.new() faoe.name = "AOE-Fireball" - faoe.description = "Feuerbälle erzeugen eine Explosion bei Berührung" + faoe.description = "Feuerbälle erzeugen\n eine Explosion\n bei Berührung" faoe.effect = fireball_aoe available_perks.append(faoe) var bexp = Perk.new() bexp.name = "Brewing-Explosion" - bexp.description = "Die Hexe erzeugt eine Explosion am Ende des Brauens" + bexp.description = "Die Hexe erzeugt\n eine Explosion am\n Ende des Brauens" bexp.effect = brew_explosion available_perks.append(bexp) From 681471259bd11917766583a0e3c428976ced7ac7 Mon Sep 17 00:00:00 2001 From: Artur David Date: Wed, 15 Apr 2026 16:09:46 +0200 Subject: [PATCH 2/3] improved card size --- scenes/PerkCard.tscn | 69 +++++++++++++++++++++++++++---------- scenes/game.tscn | 2 ++ scripts/Perk.gd | 1 + scripts/level_up_manager.gd | 11 +++--- scripts/perk_card.gd | 38 +++++++++++++++++++- 5 files changed, 96 insertions(+), 25 deletions(-) diff --git a/scenes/PerkCard.tscn b/scenes/PerkCard.tscn index 2fa4c19..502a9a5 100644 --- a/scenes/PerkCard.tscn +++ b/scenes/PerkCard.tscn @@ -1,68 +1,101 @@ -[gd_scene format=3 uid="uid://cgl06rqop270h"] +[gd_scene format=3 uid="uid://bbhpa50ef6702"] [ext_resource type="Script" uid="uid://dw5y2tp34fxys" path="res://scripts/perk_card.gd" id="1_t8gqh"] [ext_resource type="Texture2D" uid="uid://duo145bmwho8d" path="res://assets/UI assets pack 2/UI books & more.png" id="2_nlhlf"] [ext_resource type="FontFile" uid="uid://cq0jx2aapggkg" path="res://assets/fonts/slkscrb.ttf" id="3_n4umd"] [ext_resource type="FontFile" uid="uid://brooj0hba7650" path="res://assets/fonts/slkscr.ttf" id="4_40ty6"] +[ext_resource type="Texture2D" uid="uid://cdktimg5axaxj" path="res://assets/Fire Pixel Bullet 16x16/All_Fire_Bullet_Pixel_16x16_01.png" id="4_nlhlf"] [sub_resource type="AtlasTexture" id="AtlasTexture_fgk3h"] atlas = ExtResource("2_nlhlf") region = Rect2(561, 17, 46, 62) [sub_resource type="LabelSettings" id="LabelSettings_qag4p"] -line_spacing = 0.0 +line_spacing = 5.0 font = ExtResource("3_n4umd") -font_size = 5 +font_size = 12 + +[sub_resource type="AtlasTexture" id="AtlasTexture_n4umd"] +atlas = ExtResource("4_nlhlf") +region = Rect2(258, 241, 25, 14) [sub_resource type="LabelSettings" id="LabelSettings_ni87r"] font = ExtResource("4_40ty6") -font_size = 3 +font_size = 11 [node name="PerkCard" type="Control" unique_id=1471811151] +custom_minimum_size = Vector2(200, 300) layout_mode = 3 anchors_preset = 0 script = ExtResource("1_t8gqh") [node name="Card" type="TextureRect" parent="." unique_id=1832247473] texture_filter = 1 +custom_minimum_size = Vector2(200, 300) layout_mode = 0 offset_right = 40.0 offset_bottom = 40.0 texture = SubResource("AtlasTexture_fgk3h") -[node name="Description" type="Label" parent="Card" unique_id=2006873472] +[node name="Name" type="Label" parent="Card" unique_id=2006873472] layout_mode = 1 anchors_preset = 5 anchor_left = 0.5 anchor_right = 0.5 -offset_left = -20.5 -offset_top = 7.0 -offset_right = 20.5 -offset_bottom = 23.0 +offset_left = -50.5 +offset_top = 43.0 +offset_right = 50.5 +offset_bottom = 92.0 grow_horizontal = 2 -text = "AOE --Feuerball" +text = "Zweizeilige +Überschrift +" label_settings = SubResource("LabelSettings_qag4p") horizontal_alignment = 1 -[node name="Name" type="Label" parent="Card" unique_id=859816848] +[node name="TextureRect" type="TextureRect" parent="Card/Name" unique_id=2128840891] layout_mode = 1 anchors_preset = 7 anchor_left = 0.5 anchor_top = 1.0 anchor_right = 0.5 anchor_bottom = 1.0 -offset_left = -20.0 -offset_top = -36.0 -offset_right = 20.0 +offset_left = -24.5 +offset_top = -10.0 +offset_right = 24.5 +offset_bottom = 19.0 grow_horizontal = 2 grow_vertical = 0 -text = "Das ist ein test" +texture = SubResource("AtlasTexture_n4umd") + +[node name="Description" type="Label" parent="Card" unique_id=859816848] +layout_mode = 1 +anchors_preset = 7 +anchor_left = 0.5 +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +offset_left = -65.0 +offset_top = -176.0 +offset_right = 69.0 +offset_bottom = -43.0 +grow_horizontal = 2 +grow_vertical = 0 +text = "Text in Zeile Eins +Text in Zeile Eins +Text in Zeile Eins +Text in Zeile Eins +Text in Zeile Zwei +Text in Zeile Drei +Text in Zeile Vier +Text in Zeile Fünf" label_settings = SubResource("LabelSettings_ni87r") horizontal_alignment = 1 autowrap_mode = 2 [node name="Button" type="Button" parent="." unique_id=1274377333] layout_mode = 0 -offset_right = 46.0 -offset_bottom = 62.0 +offset_right = 200.0 +offset_bottom = 300.0 + +[connection signal="pressed" from="Button" to="." method="_on_button_pressed"] diff --git a/scenes/game.tscn b/scenes/game.tscn index c446e16..c29d57c 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -2427,6 +2427,7 @@ grow_horizontal = 2 script = ExtResource("16_rysoc") [node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/LevelUpManager" unique_id=957625333] +custom_minimum_size = Vector2(1000, 400) layout_mode = 1 anchors_preset = 8 anchor_left = 0.5 @@ -2439,6 +2440,7 @@ offset_right = 20.0 offset_bottom = 390.0 grow_horizontal = 2 grow_vertical = 2 +theme_override_constants/separation = 50 alignment = 1 [node name="PerkEffects" type="Node2D" parent="." unique_id=2027136639] diff --git a/scripts/Perk.gd b/scripts/Perk.gd index c32ff4a..d656bb3 100644 --- a/scripts/Perk.gd +++ b/scripts/Perk.gd @@ -3,4 +3,5 @@ class_name Perk @export var name: String @export var description: String +@export var icon: Texture2D = null var effect: Callable diff --git a/scripts/level_up_manager.gd b/scripts/level_up_manager.gd index f34f622..e18cb9b 100644 --- a/scripts/level_up_manager.gd +++ b/scripts/level_up_manager.gd @@ -3,6 +3,7 @@ extends Control @onready var perk_effects = get_node("/root/Game/PerkEffects") var perks +@onready var perkCard = preload("res://scenes/PerkCard.tscn") # Called when the node enters the scene tree for the first time. func _ready() -> void: perks = perk_effects.available_perks @@ -22,12 +23,10 @@ func show_perks(): shuffled.shuffle() var chosen = shuffled.slice(0, 3) for x in chosen: - var button = Button.new() - button.text = x.name + "\n" + x.description - button.custom_minimum_size = Vector2(200, 500) - button.size_flags_horizontal = Control.SIZE_SHRINK_CENTER - button.pressed.connect(func(): select_perk(x)) - $HBoxContainer.add_child(button) + var card = perkCard.instantiate() + $HBoxContainer.add_child(card) + card.setup(x, func(): select_perk(x)) + func select_perk(perk): perk.effect.call() diff --git a/scripts/perk_card.gd b/scripts/perk_card.gd index 509e895..15f9ed7 100644 --- a/scripts/perk_card.gd +++ b/scripts/perk_card.gd @@ -1,4 +1,40 @@ extends Control - @export var icon: Texture2D # Called when the node enters the scene tree for the first time. +var on_select: Callable + + + +func setup(perk: Perk, select: Callable): + $Button.modulate.a = 0 + $Card/Name.text = perk.name + $Card/Description.text = perk.description + if perk.icon != null: + $Card/Name/TextureRect.texture = perk.icon + animate_in() + on_select = select + $Button.pressed.connect(_on_button_pressed) + + + +func _on_button_pressed() -> void: + await animate_out() + on_select.call() + pass # Replace with function body. + +func animate_in(): + await get_tree().process_frame + var start_y = global_position.y + 500 + var end_y = global_position.y + global_position.y = start_y + var tween = create_tween() + tween.tween_property(self, "global_position:y", end_y, 0.3).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_QUAD) + +func animate_out(): + var start_y = global_position.y + var end_y = global_position.y - 500 + global_position.y = start_y + var tween = create_tween() + tween.tween_property(self, "global_position:y", end_y, 0.3).set_ease(Tween.EASE_IN).set_trans(Tween.TRANS_QUAD) + await tween.finished + From 452325a0b4f31630003b8f3c525a326155d68fc7 Mon Sep 17 00:00:00 2001 From: Artur <2123806@stud.th-mannheim.de> Date: Wed, 15 Apr 2026 17:22:15 +0200 Subject: [PATCH 3/3] fixed explosion calculation and finished cards + xp bar --- scenes/game.tscn | 29 +++++++++++++++++++++++++++++ scripts/explosion.gd | 1 + scripts/fireball.gd | 2 +- scripts/level_up_manager.gd | 6 ++++++ scripts/perk_card.gd | 4 +++- 5 files changed, 40 insertions(+), 2 deletions(-) diff --git a/scenes/game.tscn b/scenes/game.tscn index c29d57c..86d18f2 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -17,6 +17,7 @@ [ext_resource type="Script" uid="uid://ckv6prbe1o7s1" path="res://scripts/drop_manager.gd" id="10_vtaks"] [ext_resource type="Script" uid="uid://pmmc7tivuuo4" path="res://scripts/perk_effects.gd" id="16_ca42v"] [ext_resource type="Script" uid="uid://dm1sntwjrv3vl" path="res://scripts/level_up_manager.gd" id="16_rysoc"] +[ext_resource type="Texture2D" uid="uid://dp8o40ssuh8ip" path="res://assets/Tiny RPG Mana Soul GUI v1.0/20250421barB-Sheet.png" id="16_ssvqc"] [sub_resource type="Resource" id="Resource_ssvqc"] script = ExtResource("6_ir15t") @@ -2417,6 +2418,26 @@ max_value = 5.0 step = 1.0 show_percentage = false +[node name="NinePatchRect" type="NinePatchRect" parent="CanvasLayer/ProgressBar" unique_id=1364517669] +texture_filter = 1 +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -6.5 +offset_top = -1.0 +offset_right = 5.5 +offset_bottom = 2.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("16_ssvqc") +draw_center = false +region_rect = Rect2(0, 0, 95, 15) +patch_margin_left = 7 +patch_margin_top = 5 +patch_margin_right = 8 +patch_margin_bottom = 6 + [node name="LevelUpManager" type="Control" parent="CanvasLayer" unique_id=292400493] process_mode = 3 layout_mode = 3 @@ -2426,6 +2447,14 @@ anchor_right = 0.5 grow_horizontal = 2 script = ExtResource("16_rysoc") +[node name="ColorRect" type="ColorRect" parent="CanvasLayer/LevelUpManager" unique_id=1319513730] +layout_mode = 1 +offset_left = -656.0 +offset_top = -9.0 +offset_right = 642.0 +offset_bottom = 728.0 +color = Color(0, 0, 0, 0.0627451) + [node name="HBoxContainer" type="HBoxContainer" parent="CanvasLayer/LevelUpManager" unique_id=957625333] custom_minimum_size = Vector2(1000, 400) layout_mode = 1 diff --git a/scripts/explosion.gd b/scripts/explosion.gd index 7dc348c..f05a1c3 100644 --- a/scripts/explosion.gd +++ b/scripts/explosion.gd @@ -3,6 +3,7 @@ extends Area2D # Called when the node enters the scene tree for the first time. func _ready(): + await get_tree().physics_frame for body in get_overlapping_bodies(): if body.is_in_group("enemies"): body.hit() diff --git a/scripts/fireball.gd b/scripts/fireball.gd index 526921a..42421c0 100644 --- a/scripts/fireball.gd +++ b/scripts/fireball.gd @@ -10,6 +10,6 @@ func _on_body_entered(body: Node2D) -> void: if fireball_aoe: var boom = explosion_scene.instantiate() boom.global_position = global_position - get_parent().add_child(boom) + get_parent().call_deferred("add_child", boom) queue_free() diff --git a/scripts/level_up_manager.gd b/scripts/level_up_manager.gd index e18cb9b..a04db52 100644 --- a/scripts/level_up_manager.gd +++ b/scripts/level_up_manager.gd @@ -2,6 +2,7 @@ extends Control @onready var perk_effects = get_node("/root/Game/PerkEffects") + var perks @onready var perkCard = preload("res://scenes/PerkCard.tscn") # Called when the node enters the scene tree for the first time. @@ -18,6 +19,8 @@ func _process(delta: float) -> void: func show_perks(): if perks.is_empty(): return + var tween = create_tween() + tween.tween_property($ColorRect, "color:a", 0.6, 0.3) get_tree().paused = true var shuffled = perks.duplicate() shuffled.shuffle() @@ -33,3 +36,6 @@ func select_perk(perk): get_tree().paused = false perks.erase(perk) for child in $HBoxContainer.get_children(): child.queue_free() + var tween = create_tween() + tween.tween_property($ColorRect, "color:a", 0.0, 0.3) + await tween.finished diff --git a/scripts/perk_card.gd b/scripts/perk_card.gd index 15f9ed7..cb622da 100644 --- a/scripts/perk_card.gd +++ b/scripts/perk_card.gd @@ -12,8 +12,10 @@ func setup(perk: Perk, select: Callable): if perk.icon != null: $Card/Name/TextureRect.texture = perk.icon animate_in() + $Button.modulate.a = 0.3 + $Button.mouse_entered.connect(func(): $Button.modulate.a = 0.6) + $Button.mouse_exited.connect(func(): $Button.modulate.a = 0.3) on_select = select - $Button.pressed.connect(_on_button_pressed)