Skip to content

Commit 59317e8

Browse files
committed
added game messages for multi-matches
1 parent 884382f commit 59317e8

File tree

3 files changed

+46
-22
lines changed

3 files changed

+46
-22
lines changed

game/game.gd

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ extends Node2D
33
@onready var game_top_h_box:HBoxContainer = $ContTopBar/GameTopHBox
44
@onready var game_stats:VBoxContainer = $ContGameStats/GameStats
55
@onready var game_board:GameBoard = $ContBoard/Board
6-
@onready var animation_player:AnimationPlayer = $AnimationPlayer
6+
@onready var animation_player:AnimationPlayer = $ContMessages/AnimationPlayer
77

88
func _ready():
99
game_board.connect("props_updated_moves", self._on_props_updated_moves)
1010
game_board.connect("props_updated_score", self._on_props_updated_score)
1111
game_board.connect("props_updated_gemsdict", self._on_props_updated_gemsdict)
12+
game_board.connect("board_match_multi", self.on_board_match_multi)
1213

1314
func _on_props_updated_gemsdict(gems_dict:Dictionary):
1415
# EX: `{ "WHITE": 9, "RED": 11, "YELLOW": 14, "BROWN": 9, "GREEN": 9, "PURPLE": 12 }`
@@ -21,11 +22,15 @@ func _on_props_updated_gemsdict(gems_dict:Dictionary):
2122

2223
func _on_props_updated_score(score:int):
2324
game_top_h_box.get_child(0).get_child(1).text = str(score)
24-
animation_player.play("show_msg_amazing")
2525

2626
func _on_props_updated_moves(moves:int):
2727
game_top_h_box.get_child(1).get_child(1).text = str(moves)
2828

29+
func on_board_match_multi(match_cnt:int):
30+
# TODO: add more messages
31+
if match_cnt >= 2:
32+
animation_player.play("show_msg_amazing")
33+
2934
func _on_newgame_button_pressed():
3035
game_board.new_game()
3136

game/game.tscn

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,39 @@ bg_color = Color(0, 0, 0, 0.133333)
2929
resource_name = "show_msg_amazing"
3030
tracks/0/type = "value"
3131
tracks/0/imported = false
32-
tracks/0/enabled = false
33-
tracks/0/path = NodePath("ContMessages/Msg-Amazing:modulate")
32+
tracks/0/enabled = true
33+
tracks/0/path = NodePath("ContMessages/Msg-Amazing:visible")
3434
tracks/0/interp = 1
3535
tracks/0/loop_wrap = true
3636
tracks/0/keys = {
37-
"times": PackedFloat32Array(0),
38-
"transitions": PackedFloat32Array(1),
39-
"update": 0,
40-
"values": [Color(1, 1, 1, 1)]
37+
"times": PackedFloat32Array(0, 1),
38+
"transitions": PackedFloat32Array(1, 1),
39+
"update": 1,
40+
"values": [true, false]
4141
}
4242
tracks/1/type = "value"
4343
tracks/1/imported = false
4444
tracks/1/enabled = true
45-
tracks/1/path = NodePath("ContMessages/Msg-Amazing:visible")
45+
tracks/1/path = NodePath("ContMessages/Msg-Amazing/RTL-Btm-Amazing:theme_override_font_sizes/normal_font_size")
4646
tracks/1/interp = 1
4747
tracks/1/loop_wrap = true
4848
tracks/1/keys = {
49-
"times": PackedFloat32Array(0, 1),
50-
"transitions": PackedFloat32Array(1, 1),
51-
"update": 1,
52-
"values": [true, false]
49+
"times": PackedFloat32Array(0, 0.5, 1),
50+
"transitions": PackedFloat32Array(1, 1, 1),
51+
"update": 0,
52+
"values": [204, 240, 204]
53+
}
54+
tracks/2/type = "value"
55+
tracks/2/imported = false
56+
tracks/2/enabled = true
57+
tracks/2/path = NodePath("ContMessages/Msg-Amazing/RTL-Top-Amazing:theme_override_font_sizes/normal_font_size")
58+
tracks/2/interp = 1
59+
tracks/2/loop_wrap = true
60+
tracks/2/keys = {
61+
"times": PackedFloat32Array(0, 0.5, 1),
62+
"transitions": PackedFloat32Array(1, 1, 1),
63+
"update": 0,
64+
"values": [204, 240, 204]
5365
}
5466

5567
[sub_resource type="AnimationLibrary" id="AnimationLibrary_htlur"]
@@ -77,6 +89,9 @@ grow_horizontal = 2
7789
grow_vertical = 2
7890
theme_override_styles/panel = SubResource("StyleBoxFlat_103kv")
7991

92+
[node name="AudioGemMove" type="AudioStreamPlayer" parent="."]
93+
stream = ExtResource("8_7jpwb")
94+
8095
[node name="ContTopClouds" type="Control" parent="."]
8196
layout_mode = 3
8297
anchors_preset = 0
@@ -326,9 +341,6 @@ theme_override_styles/panel = SubResource("StyleBoxFlat_103kv")
326341
[node name="Board" parent="ContBoard" instance=ExtResource("2_2ltbx")]
327342
position = Vector2(500, 250)
328343

329-
[node name="AudioGemMove" type="AudioStreamPlayer" parent="."]
330-
stream = ExtResource("8_7jpwb")
331-
332344
[node name="BtnNewGame" type="TextureButton" parent="."]
333345
offset_left = 1600.0
334346
offset_top = 250.0
@@ -390,12 +402,6 @@ text = "CHECKERED"
390402
horizontal_alignment = 1
391403
vertical_alignment = 1
392404

393-
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
394-
libraries = {
395-
"": SubResource("AnimationLibrary_htlur")
396-
}
397-
autoplay = "show_msg_amazing"
398-
399405
[node name="ContMessages" type="Control" parent="."]
400406
custom_minimum_size = Vector2(2000, 230)
401407
layout_mode = 3
@@ -405,6 +411,13 @@ offset_right = 2000.0
405411
offset_bottom = 770.0
406412
mouse_filter = 2
407413

414+
[node name="AnimationPlayer" type="AnimationPlayer" parent="ContMessages"]
415+
root_node = NodePath("../..")
416+
libraries = {
417+
"": SubResource("AnimationLibrary_htlur")
418+
}
419+
autoplay = "show_msg_amazing"
420+
408421
[node name="Msg-Amazing" type="Control" parent="ContMessages"]
409422
visible = false
410423
custom_minimum_size = Vector2(2000, 230)
@@ -435,6 +448,7 @@ offset_bottom = 144.0
435448
grow_horizontal = 2
436449
grow_vertical = 2
437450
theme = ExtResource("18_p5dta")
451+
theme_override_font_sizes/normal_font_size = 204
438452
bbcode_enabled = true
439453
text = "[center]Amazing![/center]"
440454
fit_content = true
@@ -455,6 +469,7 @@ offset_bottom = 144.0
455469
grow_horizontal = 2
456470
grow_vertical = 2
457471
theme = ExtResource("17_j7spk")
472+
theme_override_font_sizes/normal_font_size = 204
458473
bbcode_enabled = true
459474
text = "[center]Amazing![/center]"
460475
fit_content = true

game_board/GameBoard.gd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class_name GameBoard
66
signal props_updated_moves(moves:int)
77
signal props_updated_score(score:int)
88
signal props_updated_gemsdict(gems_dict:Dictionary)
9+
signal board_match_multi(match_cnt:int)
910
# SCENES
1011
@onready var grid_container:GridContainer = $GridContainer
1112
@onready var hbox_container:HBoxContainer = $HBoxContainer
@@ -367,6 +368,9 @@ func explode_refill_gems(matches: Array, match_scores: Dictionary):
367368
var score = match_scores[gem_cell]
368369
gem_cell.explode_gem(gem_cell.gem_color, score)
369370

371+
# B: Show game messages (ex: "Amazing!")
372+
emit_signal("board_match_multi", matches.size())
373+
370374
# TODO: FIXME: gem counts need to update faster (they currently update after the animation completes)!!
371375
# seemingly, this would work fine located here but its not - the UI update requires a frame update i guess?
372376
signal_game_props_count_gems()

0 commit comments

Comments
 (0)