online multiplayer chess game (note server currently down)
| -rw-r--r-- | Globals.gd | 2 | ||||
| -rw-r--r-- | Grid.gd | 3 | ||||
| -rw-r--r-- | networking/Network.gd | 2 | ||||
| -rw-r--r-- | ui/Lobby.gd | 6 | ||||
| -rw-r--r-- | ui/Lobby.tscn | 2 | ||||
| -rw-r--r-- | ui/main.tres | 12 |
6 files changed, 21 insertions, 6 deletions
@@ -1,7 +1,5 @@ extends Node -const pieces = "NKQRBP" - var __nosethalfmove = false var pawns = [] # PoolPawnArray var team = true @@ -164,6 +164,7 @@ func check_in_check(prin = false) -> bool: # check if in_check var spot = matrix[i][j] # get the square if spot and spot.white != Globals.turn: # enemie if spot.can_attack_piece(Globals.white_king if Globals.turn else Globals.black_king): # if it can take the king + # control never flows here if prin: Globals.in_check = true # set in_check Globals.checking_piece = spot # set checking_piece @@ -176,8 +177,6 @@ func can_move() -> bool: for i in range(0, 8): # for each row for j in range(0, 8): # for each column var spot = matrix[i][j] # get the square - if Input.is_action_pressed("ui_down"): - breakpoint if spot and spot.white != Globals.team: # enemie: checking for our enemys if spot.can_move(): return true diff --git a/networking/Network.gd b/networking/Network.gd index 6c8758c..a1398c7 100644 --- a/networking/Network.gd +++ b/networking/Network.gd @@ -28,6 +28,7 @@ signal move_data(data) signal host_result(result) signal join_result(result) signal game_over(problem, isok) +signal connection_established const url := "wss://gd-chess-server.herokuapp.com/" @@ -51,6 +52,7 @@ func ping() -> void: func _connection_established(_protocol) -> void: + emit_signal("connection_established") print("Connection established") diff --git a/ui/Lobby.gd b/ui/Lobby.gd index 15e609f..a7d635b 100644 --- a/ui/Lobby.gd +++ b/ui/Lobby.gd @@ -69,9 +69,15 @@ func _ready() -> void: Globals.network.connect("host_result", self, "_on_host_result") Globals.network.connect("game_over", self, "_handle_game_over") Globals.network.connect("start_game", self, "_start_game") + Globals.network.connect("connection_established", self, "network_ready") add_child(Globals.network) +func network_ready(): + for child in buttons.get_children(): + child.disabled = false + + func end_game() -> void: if get_tree().get_root().has_node("World"): get_tree().get_root().get_node("World").queue_free() diff --git a/ui/Lobby.tscn b/ui/Lobby.tscn index 123bf11..38106d2 100644 --- a/ui/Lobby.tscn +++ b/ui/Lobby.tscn @@ -51,6 +51,7 @@ margin_bottom = 106.0 rect_min_size = Vector2( 150, 0 ) focus_mode = 0 size_flags_horizontal = 4 +disabled = true enabled_focus_mode = 0 text = "join" @@ -60,6 +61,7 @@ margin_right = 350.0 margin_bottom = 106.0 focus_mode = 0 size_flags_horizontal = 3 +disabled = true enabled_focus_mode = 0 text = "host" diff --git a/ui/main.tres b/ui/main.tres index fc4318d..241b240 100644 --- a/ui/main.tres +++ b/ui/main.tres @@ -8,7 +8,14 @@ [ext_resource path="res://assets/ui/checkedbox.png" type="Texture" id=6] [ext_resource path="res://ui/flatblack.tres" type="StyleBox" id=7] -[sub_resource type="StyleBoxEmpty" id=2] +[sub_resource type="StyleBoxTexture" id=6] +texture = ExtResource( 4 ) +region_rect = Rect2( 0, 0, 84, 84 ) +margin_left = 28.0 +margin_right = 28.0 +margin_top = 28.0 +margin_bottom = 28.0 +modulate_color = Color( 0.772549, 0.772549, 0.772549, 0.54902 ) [sub_resource type="StyleBoxEmpty" id=4] @@ -26,10 +33,11 @@ corner_detail = 20 [resource] default_font = ExtResource( 1 ) Button/colors/font_color = Color( 1, 1, 1, 1 ) +Button/colors/font_color_disabled = Color( 1, 1, 1, 0.305882 ) Button/colors/font_color_focus = Color( 1, 1, 1, 1 ) Button/colors/font_color_hover = Color( 0, 0, 0, 1 ) Button/colors/font_color_pressed = Color( 1, 1, 1, 1 ) -Button/styles/disabled = SubResource( 2 ) +Button/styles/disabled = SubResource( 6 ) Button/styles/focus = ExtResource( 2 ) Button/styles/hover = ExtResource( 5 ) Button/styles/normal = ExtResource( 2 ) |