online multiplayer chess game (note server currently down)
cleanup + status label
| -rw-r--r-- | Grid.gd | 14 | ||||
| -rw-r--r-- | sounds/SoundFX.gd | 1 | ||||
| -rw-r--r-- | ui/GameUI.tscn | 28 | ||||
| -rw-r--r-- | ui/Timer.gd | 4 |
4 files changed, 28 insertions, 19 deletions
@@ -33,6 +33,7 @@ onready var background := $Background onready var ASSETS_PATH := "res://assets/pieces/" + PIECE_SET + "/" onready var foreground := $Foreground onready var pieces := $Pieces +onready var status_label := $"../UI/Holder/Back/VBox/Status" func _ready(): @@ -98,7 +99,6 @@ func mat2str(mat = matrix): func _on_turn_over(): var matstr: String = mat2str() - # print(matstr) if !history_matrixes.has(matstr): history_matrixes[matstr] = 1 else: @@ -109,21 +109,21 @@ func _on_turn_over(): matrix[8].turn = Globals.turn check_in_check(true) # check if in_check if !can_move(): - print("what") if Globals.in_check: - win("black" if Globals.turn else "white") + var winner := "black" if Globals.turn else "white" + status_label.text = "%s won the game by checkmate" % winner + win(winner) else: - print("stalemate") + status_label.text = "stalemate" drawed() elif threefoldrepetition(): - print("draw by threefold repetition") + status_label.text = "draw by threefold repetition" drawed() func drawed(): Events.emit_signal("game_over") SoundFx.play("Draw") - print_matrix_pretty() yield(get_tree().create_timer(5), "timeout") get_tree().reload_current_scene() SoundFx.play("Victory") @@ -133,7 +133,6 @@ func win(winner): Events.emit_signal("game_over") print(winner, " won the game in ", Globals.turns(winner), " turns!") SoundFx.play("Victory") - print_matrix_pretty() yield(get_tree().create_timer(5), "timeout") get_tree().reload_current_scene() SoundFx.play("Victory") @@ -322,7 +321,6 @@ func handle_move(position): turn_over() return if last_clicked is Pawn and last_clicked.enpassant: - print(last_clicked.enpassant) for i in range(len(last_clicked.enpassant)): var en_passant_data = last_clicked.enpassant[i] if en_passant_data[0] == position: diff --git a/sounds/SoundFX.gd b/sounds/SoundFX.gd index 09a71be..a0aace5 100644 --- a/sounds/SoundFX.gd +++ b/sounds/SoundFX.gd @@ -23,4 +23,3 @@ func play(sound_string, pitch_scale = 1, volume_db = 0): soundPlayer.stream = sounds[sound_string] soundPlayer.play() return - print("Too many sounds playing at once") diff --git a/ui/GameUI.tscn b/ui/GameUI.tscn index 59f223d..f54003e 100644 --- a/ui/GameUI.tscn +++ b/ui/GameUI.tscn @@ -1,11 +1,15 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://ui/main.tres" type="Theme" id=1] [ext_resource path="res://ui/roboto.tres" type="DynamicFont" id=2] -[ext_resource path="res://ui/TimerLabels.gd" type="Script" id=3] +[ext_resource path="res://assets/ui/Roboto-Medium.ttf" type="DynamicFontData" id=3] [ext_resource path="res://ui/TimerLabels.gd" type="Script" id=4] [ext_resource path="res://ui/Timer.gd" type="Script" id=5] +[sub_resource type="DynamicFont" id=1] +size = 25 +font_data = ExtResource( 3 ) + [node name="UI" type="CanvasLayer"] [node name="Holder" type="Control" parent="."] @@ -23,13 +27,13 @@ color = Color( 0.141176, 0.141176, 0.141176, 1 ) [node name="VBox" type="VBoxContainer" parent="Holder/Back"] anchor_right = 1.0 anchor_bottom = 1.0 -custom_constants/separation = 100 +custom_constants/separation = 50 alignment = 1 [node name="BlackTime" type="Label" parent="Holder/Back/VBox"] -margin_top = 267.0 +margin_top = 251.0 margin_right = 400.0 -margin_bottom = 350.0 +margin_bottom = 334.0 custom_fonts/font = ExtResource( 2 ) text = "00:00.0" align = 1 @@ -44,15 +48,23 @@ margin_left = 72.0 margin_right = -72.0 color = Color( 0, 0, 0, 1 ) +[node name="Status" type="Label" parent="Holder/Back/VBox"] +margin_top = 384.0 +margin_right = 400.0 +margin_bottom = 415.0 +custom_fonts/font = SubResource( 1 ) +align = 1 +autowrap = true + [node name="WhiteTime" type="Label" parent="Holder/Back/VBox"] -margin_top = 450.0 +margin_top = 465.0 margin_right = 400.0 -margin_bottom = 533.0 +margin_bottom = 548.0 custom_fonts/font = ExtResource( 2 ) text = "00:00.0" align = 1 valign = 1 -script = ExtResource( 3 ) +script = ExtResource( 4 ) white = true [node name="ColorRect" type="ColorRect" parent="Holder/Back/VBox/WhiteTime"] diff --git a/ui/Timer.gd b/ui/Timer.gd index ad937ba..b34cc25 100644 --- a/ui/Timer.gd +++ b/ui/Timer.gd @@ -21,8 +21,8 @@ func _process(delta): func _ready(): - whitelabel.time = 10 - blacklabel.time = 10 + whitelabel.time = 300 + blacklabel.time = 300 Events.connect("turn_over", self, "turn_over") |