Skip to content

Commit

Permalink
feat: toggle buttons for changing the rules
Browse files Browse the repository at this point in the history
  • Loading branch information
russmatney committed Jun 23, 2024
1 parent b3bff40 commit a817c9e
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 4 deletions.
27 changes: 26 additions & 1 deletion src/BloxGame.gd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ var score = 0

@onready var crtv_effect = $%CRTVEffect

@onready var tetris_button: Button = $%TetrisMode
@onready var puyo_button: Button = $%PuyoMode
@onready var combined_button: Button = $%CombinedMode

@onready var tetris_rules = preload("res://src/rules/TetrisGridRules.tres")
@onready var puyo_rules = preload("res://src/rules/PuyoGridRules.tres")
@onready var combined_rules = preload("res://src/rules/PuyoPlusTetrisGridRules.tres")
var rule_buttons = []

## ready #############################################

func _ready():
Expand All @@ -38,12 +47,28 @@ func _ready():
camera.offset = bucket.bucket_center()

restart_button.pressed.connect(func():
Log.info("restart pressed!")
reset_score_label()
bucket.restart())

rule_buttons = [tetris_button, puyo_button, combined_button]
tetris_button.pressed.connect(func(): set_rules(tetris_rules))
puyo_button.pressed.connect(func(): set_rules(puyo_rules))
combined_button.pressed.connect(func(): set_rules(combined_rules))
set_rules.call_deferred(combined_rules)

start_game()

func set_rules(rules: GridRules):
rule_buttons.map(func(b): b.set_pressed(false))
bucket.grid_rules = rules
match rules:
tetris_rules:
tetris_button.set_pressed(true)
puyo_rules:
puyo_button.set_pressed(true)
combined_rules:
combined_button.set_pressed(true)

## start game #############################################

func start_game():
Expand Down
38 changes: 35 additions & 3 deletions src/BloxGame.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

[sub_resource type="Resource" id="Resource_upt77"]
script = ExtResource("3_g3a7t")
width = 10
width = 8
height = 12

[sub_resource type="ShaderMaterial" id="ShaderMaterial_2o1j2"]
Expand All @@ -18,7 +18,7 @@ shader_parameter/scanlines_opacity = 0.2
shader_parameter/scanlines_width = 0.1
shader_parameter/grille_opacity = 0.2
shader_parameter/resolution = Vector2(1920, 1440)
shader_parameter/pixelate = true
shader_parameter/pixelate = false
shader_parameter/roll = true
shader_parameter/roll_speed = 1.2
shader_parameter/roll_size = 8.0
Expand All @@ -27,7 +27,7 @@ shader_parameter/distort_intensity = 0.01
shader_parameter/noise_opacity = 0.1
shader_parameter/noise_speed = 2.0
shader_parameter/static_noise_intensity = 0.06
shader_parameter/aberration = 0.01
shader_parameter/aberration = 0.00500005
shader_parameter/brightness = 2.2
shader_parameter/discolor = false
shader_parameter/warp_amount = 0.4
Expand Down Expand Up @@ -113,6 +113,38 @@ fit_content = true
scroll_active = false
autowrap_mode = 0

[node name="CenterContainer2" type="CenterContainer" parent="UI/HUD/HBoxContainer/LeftSide/VBoxContainer"]
layout_mode = 2
size_flags_vertical = 10

[node name="VBoxContainer" type="VBoxContainer" parent="UI/HUD/HBoxContainer/LeftSide/VBoxContainer/CenterContainer2"]
layout_mode = 2

[node name="TetrisMode" type="Button" parent="UI/HUD/HBoxContainer/LeftSide/VBoxContainer/CenterContainer2/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
focus_mode = 0
toggle_mode = true
text = "Tetris"

[node name="PuyoMode" type="Button" parent="UI/HUD/HBoxContainer/LeftSide/VBoxContainer/CenterContainer2/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
focus_mode = 0
toggle_mode = true
text = "Puyo"

[node name="CombinedMode" type="Button" parent="UI/HUD/HBoxContainer/LeftSide/VBoxContainer/CenterContainer2/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
focus_mode = 0
toggle_mode = true
text = "Combined"

[node name="MarginContainer2" type="MarginContainer" parent="UI/HUD/HBoxContainer/LeftSide/VBoxContainer"]
custom_minimum_size = Vector2(2.08165e-12, 64)
layout_mode = 2

[node name="BucketMarginContainer" type="MarginContainer" parent="UI/HUD/HBoxContainer"]
unique_name_in_owner = true
custom_minimum_size = Vector2(384, 2.08165e-12)
Expand Down

0 comments on commit a817c9e

Please sign in to comment.