Skip to content

Commit

Permalink
feat(shop): able to explore parts
Browse files Browse the repository at this point in the history
  • Loading branch information
SummationX committed Feb 22, 2025
1 parent 9331ecf commit 923a0c8
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 23 deletions.
12 changes: 7 additions & 5 deletions apps/gamejam/brackeys/13/scenes/shop/shop.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,12 @@ offset_bottom = 150.0
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 1
text = "dada
dada"
vertical_alignment = 3

[node name="Right" type="Label" parent="MainBG/CenterScreen/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 1
text = "dad
sdsd"
horizontal_alignment = 2
vertical_alignment = 3

Expand All @@ -133,6 +129,7 @@ offset_bottom = 351.0
texture = ExtResource("1_x5466")

[node name="ScreenPanel" type="TextureRect" parent="MainBG/LeftPanel"]
layout_mode = 0
offset_left = 32.0
offset_top = 34.0
offset_right = 264.0
Expand Down Expand Up @@ -192,7 +189,6 @@ offset_top = 33.0
offset_right = 424.0
offset_bottom = 284.0
texture = ExtResource("4_atpsb")
metadata/_edit_group_ = true

[node name="VBoxContainer" type="VBoxContainer" parent="MainBG/LeftButtons"]
layout_mode = 1
Expand Down Expand Up @@ -378,3 +374,9 @@ lights_off = ExtResource("13_swidh")
[connection signal="pressed" from="MainBG/LeftPanel/HBoxContainer/LeftButton" to="." method="_on_left_button_pressed_left_panel"]
[connection signal="pressed" from="MainBG/LeftPanel/HBoxContainer/EnterButton" to="." method="_on_enter_button_pressed_left_panel"]
[connection signal="pressed" from="MainBG/LeftPanel/HBoxContainer/RightButton" to="." method="_on_right_button_pressed_left_panel"]
[connection signal="pressed" from="MainBG/LeftButtons/VBoxContainer/Button" to="." method="_on_button_1_left_pressed"]
[connection signal="pressed" from="MainBG/LeftButtons/VBoxContainer/Button2" to="." method="_on_button_2_left_pressed"]
[connection signal="pressed" from="MainBG/LeftButtons/VBoxContainer/Button3" to="." method="_on_button_3_left_pressed"]
[connection signal="pressed" from="MainBG/RightButtons/VBoxContainer/Button" to="." method="_on_button_right_pressed"]
[connection signal="pressed" from="MainBG/RightButtons/VBoxContainer/Button2" to="." method="_on_button_2_right_pressed"]
[connection signal="pressed" from="MainBG/RightButtons/VBoxContainer/Button3" to="." method="_on_button_right_3_pressed"]
94 changes: 76 additions & 18 deletions apps/gamejam/brackeys/13/scripts/shop.gd
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
extends ColorRect

# Left Panel
@onready var categories_label := $MainBG/LeftPanel/ScreenPanel/Label
@onready var cate_selected:= categories[current_category]

var categories : Array[StringName]= ["Weapons", "Shield", "Power", "Thrusters"]
var n = 0
@onready var cate_selected:= categories[n]


# Called when the node enters the scene tree for the first time.
func _ready():

pass # Replace with function body.
# Center Panel
@onready var center_label_left := $MainBG/CenterScreen/HBoxContainer/Left
@onready var center_label_right := $MainBG/CenterScreen/HBoxContainer/Right
@onready var shown_text = chunk_array(chosen[current_category], 4)

# Left Panel
var categories : Array[StringName]= ["Weapons", "Shield", "Power", "Thrusters"]
var current_category = 0

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
# Center Panel
var current_parts = 0
var weapons := [
"+1 damage",
"+1 max ammo",
"+1 laser speed",
"+111 test",
"+12 test",
"+13 test",
"+123 test",
"+1244 test",
"+14 test",
]
var shield := []
var power := []
var thrusters := []
var chosen = [weapons, shield, power, thrusters]


#region LeftPanelRegion
Expand All @@ -24,21 +38,65 @@ func _on_left_button_pressed_left_panel() -> void:
if cate_selected == categories[0]:
pass
else:
n -= 1
current_category -= 1
update_categories()

func _on_right_button_pressed_left_panel() -> void:
if cate_selected == categories[3]:
pass
else:
n += 1
current_category += 1
update_categories()

func _on_enter_button_pressed_left_panel() -> void:
pass

func update_categories() -> void:
cate_selected = categories[n]
cate_selected = categories[current_category]
categories_label.text = cate_selected

func _on_enter_button_pressed_left_panel() -> void:
update_parts()

func update_parts() -> void:
center_label_left.text = shown_text[current_parts][0] + "\n" + shown_text[current_parts][1]
center_label_right.text = shown_text[current_parts][2] + "\n" + shown_text[current_parts][3]

func chunk_array(base: Array, size: int) -> Array:
var result = []
for i in range(0, base.size(), size):
var chunk = base.slice(i, i + size) # Get up to 'size' elements
while chunk.size() < size: # Fill missing spots with "empty"
chunk.append("")
result.append(chunk)
return result

#endregion

#region Center Panel

func _on_button_1_left_pressed():
pass # Replace with function body.


func _on_button_2_left_pressed():
pass # Replace with function body.


func _on_button_3_left_pressed():
current_parts -= 1
current_parts = clamp(current_parts, 0, 5)
update_parts()


func _on_button_right_pressed():
pass # Replace with function body.


func _on_button_2_right_pressed():
pass # Replace with function body.


func _on_button_right_3_pressed():
current_parts += 1
current_parts = clamp(current_parts, 0, shown_text.size() - 1)
update_parts()

#endregion

0 comments on commit 923a0c8

Please sign in to comment.