Skip to content

Commit d72d671

Browse files
committed
New Game now explodes and drops in gems
1 parent 32e866b commit d72d671

File tree

5 files changed

+50
-15
lines changed

5 files changed

+50
-15
lines changed

game_boards/board01/game_board/GameBoard.gd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,9 @@ func debug_print_ascii_table(affected_cells: Array):
497497
func new_game():
498498
Enums.debug_print("Starting new game, resetting board.", Enums.DEBUG_LEVEL.INFO)
499499
# A:
500+
board_props_moves = 0
501+
board_props_score = 0
502+
# A:
500503
for vbox in hbox_container.get_children():
501504
for gem_cell in vbox.get_children():
502505
gem_cell.initialize(GEM_COLOR_NAMES[randi() % GEM_COLOR_NAMES.size()])

game_boards/board_space/game_board/GemBoard.gd

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -499,12 +499,18 @@ func debug_print_ascii_table(affected_cells: Array):
499499
func new_game():
500500
Enums.debug_print("Starting new game, resetting board.", Enums.DEBUG_LEVEL.INFO)
501501
# A:
502+
board_props_moves = 0
503+
board_props_score = 0
504+
# B:
502505
for vbox in hbox_container.get_children():
503506
for gem_cell in vbox.get_children():
504-
gem_cell.initialize(GEM_COLOR_NAMES[randi() % GEM_COLOR_NAMES.size()])
505-
gem_cell.get_child(1).visible = true
506-
gem_cell.get_child(1).position = Enums.SRPITE_POS
507+
gem_cell.explode_gem(gem_cell.gem_color, 0)
508+
await get_tree().create_timer(Enums.EXPLODE_DELAY).timeout
507509
# B:
510+
for vbox in hbox_container.get_children():
511+
for gem_cell in vbox.get_children():
512+
gem_cell.replace_gem(GEM_COLOR_NAMES[randi() % GEM_COLOR_NAMES.size()], 1)
513+
# C:
508514
process_game_round()
509515

510516
func debug_clear_debug_labels():
@@ -513,9 +519,9 @@ func debug_clear_debug_labels():
513519
gem_cell.debug_show_debug_panel(false)
514520
gem_cell.get_child(1).visible = true
515521
gem_cell.get_child(1).position = Enums.SRPITE_POS
516-
var debug_name = Enums.get_color_name_by_value(gem_cell.gem_color).substr(0,1)
517-
var debug_str = "["+debug_name+"] " + str(gem_cell.get_child(1).visible)
518-
Enums.debug_print(debug_str, Enums.DEBUG_LEVEL.DEBUG)
522+
#var debug_name = Enums.get_color_name_by_value(gem_cell.gem_color).substr(0,1)
523+
#var debug_str = "[debug_clear_debug_labels] ["+debug_name+"] " + str(gem_cell.get_child(1).visible)
524+
#Enums.debug_print(debug_str, Enums.DEBUG_LEVEL.DEBUG)
519525

520526
func debug_make_match_col():
521527
var col0:VBoxContainer = hbox_container.get_child(0)

game_boards/board_space/game_board/GemCell.gd

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ func replace_gem(colorIn: Enums.GemColor, rows_to_drop: int = 1):
5454

5555
var beg_pos = Vector2(sprite.position.x, sprite.position.y - drop_height)
5656
sprite.position = beg_pos
57-
57+
sprite.visible = true
58+
5859
# Initialize the gem with the new color and ensure it's visible
5960
initialize(colorIn)
6061
sprite.visible = true # Make sure the sprite is visible if it was hidden after explosion
@@ -64,9 +65,8 @@ func replace_gem(colorIn: Enums.GemColor, rows_to_drop: int = 1):
6465

6566
func drop_in_gem(drop_height: float):
6667
# Tween the "fall" animation from the starting point to the final position
67-
var end_pos = Vector2(sprite.position.x, sprite.position.y + drop_height)
6868
var tween = get_tree().create_tween()
69-
tween.tween_property(sprite, "position", end_pos, Enums.TWEEN_TIME)
69+
tween.tween_property(sprite, "position", Enums.SRPITE_POS, Enums.TWEEN_TIME)
7070

7171
func update_texture():
7272
if gem_color in gem_textures:
@@ -100,7 +100,8 @@ func play_anim_explode(points:int):
100100

101101
# C: show points
102102
label_points.text = "+"+str(points)
103-
anim_player_fx.play("new_points")
103+
if points > 0:
104+
anim_player_fx.play("new_points")
104105

105106
# D: explode animation (exploding sprite)
106107
anim_sprite_explode.visible = true

game_boards/board_space/game_space.gd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,6 @@ func _on_btn_quit_game():
4141
func _on_btn_checkerboard():
4242
game_board.debug_make_gem_grid()
4343
#game_board.debug_make_match_col()
44+
45+
func _on_btn_debug_pressed():
46+
game_board.debug_clear_debug_labels()

game_boards/board_space/game_space.tscn

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=30 format=3 uid="uid://bkaimvifjwkai"]
1+
[gd_scene load_steps=31 format=3 uid="uid://bkaimvifjwkai"]
22

33
[ext_resource type="Script" path="res://game_boards/board_space/game_space.gd" id="1_w6e46"]
44
[ext_resource type="Texture2D" uid="uid://cwhjcn0y744nv" path="res://assets/gems/background-space.png" id="3_f5frv"]
@@ -18,6 +18,7 @@
1818
[ext_resource type="Texture2D" uid="uid://bebhmcgujnoxc" path="res://assets/gui/ButtonText_Large_GreyOutline_Round.png" id="16_20lur"]
1919
[ext_resource type="Texture2D" uid="uid://dcow071sb2a7i" path="res://assets/gui/ButtonText_Large_Orange_Round.png" id="17_oxovp"]
2020
[ext_resource type="Theme" uid="uid://duftrpb020ewi" path="res://themes/game_msg_btm.tres" id="18_jrjnv"]
21+
[ext_resource type="Texture2D" uid="uid://chrsqb6yhlqeq" path="res://assets/gui/ButtonText_Large_Blue_Round.png" id="18_y8cds"]
2122
[ext_resource type="Theme" uid="uid://c68uhjmxln8ao" path="res://themes/game_msg_top.tres" id="19_iidij"]
2223

2324
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_103kv"]
@@ -397,23 +398,23 @@ text = "NEW GAME"
397398
horizontal_alignment = 1
398399
vertical_alignment = 1
399400

400-
[node name="BtnQuitGame" type="TextureButton" parent="."]
401+
[node name="BtnDebug" type="TextureButton" parent="."]
401402
offset_left = 1657.0
402403
offset_top = 393.0
403404
offset_right = 2816.0
404405
offset_bottom = 751.0
405406
scale = Vector2(0.25, 0.25)
406407
texture_normal = ExtResource("16_20lur")
407408

408-
[node name="Label" type="Label" parent="BtnQuitGame"]
409+
[node name="Label" type="Label" parent="BtnDebug"]
409410
layout_mode = 1
410411
anchors_preset = 15
411412
anchor_right = 1.0
412413
anchor_bottom = 1.0
413414
grow_horizontal = 2
414415
grow_vertical = 2
415416
theme_override_font_sizes/font_size = 120
416-
text = "Quit"
417+
text = "CLEAR/RESET"
417418
horizontal_alignment = 1
418419
vertical_alignment = 1
419420

@@ -437,6 +438,26 @@ text = "CHECKERED"
437438
horizontal_alignment = 1
438439
vertical_alignment = 1
439440

441+
[node name="BtnQuitGame" type="TextureButton" parent="."]
442+
offset_left = 1659.0
443+
offset_top = 696.0
444+
offset_right = 2818.0
445+
offset_bottom = 1054.0
446+
scale = Vector2(0.25, 0.25)
447+
texture_normal = ExtResource("18_y8cds")
448+
449+
[node name="Label" type="Label" parent="BtnQuitGame"]
450+
layout_mode = 1
451+
anchors_preset = 15
452+
anchor_right = 1.0
453+
anchor_bottom = 1.0
454+
grow_horizontal = 2
455+
grow_vertical = 2
456+
theme_override_font_sizes/font_size = 120
457+
text = "Quit"
458+
horizontal_alignment = 1
459+
vertical_alignment = 1
460+
440461
[node name="ContMessages" type="Control" parent="."]
441462
custom_minimum_size = Vector2(2000, 230)
442463
layout_mode = 3
@@ -513,5 +534,6 @@ autowrap_mode = 0
513534
shortcut_keys_enabled = false
514535

515536
[connection signal="pressed" from="BtnNewGame" to="." method="_on_btn_newgame_pressed"]
516-
[connection signal="pressed" from="BtnQuitGame" to="." method="_on_btn_quit_game"]
537+
[connection signal="pressed" from="BtnDebug" to="." method="_on_btn_debug_pressed"]
517538
[connection signal="pressed" from="BtnCheckerboard" to="." method="_on_btn_checkerboard"]
539+
[connection signal="pressed" from="BtnQuitGame" to="." method="_on_btn_quit_game"]

0 commit comments

Comments
 (0)