Skip to content

Commit

Permalink
feat: button styles and bottom-up todo
Browse files Browse the repository at this point in the history
  • Loading branch information
russmatney committed Jun 23, 2024
1 parent a817c9e commit 123a759
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
10 changes: 3 additions & 7 deletions src/BloxGrid.gd
Original file line number Diff line number Diff line change
Expand Up @@ -194,26 +194,22 @@ func remove_at_coord(coord: Vector2i) -> BloxCell:

## tetris fall ################################################

func bottom_up_pieces() -> Array[BloxPiece]:
func bottom_up_pieces(_dir: Vector2i) -> Array[BloxPiece]:
# TODO use `dir` to go 'bottom-up' from any direction
var ps: Array[BloxPiece] = []
ps.assign(pieces)
ps.sort_custom(func(pa, pb):
return pa.get_max_y() > pb.get_max_y())
return ps

func apply_step_tetris(dir=Vector2i.DOWN) -> bool:
# hmm i think we should do this bottom up and apply the fall right away
# also there's probably interest in animating the change
var falling_cells = []
var to_fall = []
for piece in bottom_up_pieces():
for piece in bottom_up_pieces(dir):
if can_piece_move(piece, dir, falling_cells):
to_fall.append(piece)
falling_cells.append_array(piece.grid_coords())

# drop them all at once
# (this doesn't seem right, multi-piece stacks won't fall together)
# maybe it's fine/a graphic?
for piece in to_fall:
move_piece(piece, dir, true)

Expand Down
18 changes: 17 additions & 1 deletion src/BloxTheme.tres
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
[gd_resource type="Theme" load_steps=4 format=3 uid="uid://dyh165k6fs4jf"]
[gd_resource type="Theme" load_steps=5 format=3 uid="uid://dyh165k6fs4jf"]

[ext_resource type="FontFile" uid="uid://dgemb4ot8u4n" path="res://assets/fonts/Born2bSportyV2.ttf" id="1_00x6k"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_aebha"]
content_margin_left = 16.0
content_margin_top = 8.0
content_margin_right = 16.0
content_margin_bottom = 8.0
bg_color = Color(0.435294, 0.164706, 0.0117647, 0.701961)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
corner_radius_top_left = 4
corner_radius_top_right = 4
corner_radius_bottom_right = 4
corner_radius_bottom_left = 4

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_rwolb"]
bg_color = Color(0.0364248, 0.263517, 0.310359, 1)

Expand All @@ -10,6 +25,7 @@ bg_color = Color(0.0364248, 0.263517, 0.310359, 1)
[resource]
Button/font_sizes/font_size = 64
Button/fonts/font = ExtResource("1_00x6k")
Button/styles/normal = SubResource("StyleBoxFlat_aebha")
PanelContainer/styles/panel = SubResource("StyleBoxFlat_rwolb")
PanelContainerNoBackground/base_type = &"PanelContainer"
PanelContainerNoBackground/styles/panel = SubResource("StyleBoxEmpty_vipxn")
Expand Down

0 comments on commit 123a759

Please sign in to comment.