online multiplayer chess game (note server currently down)
add check red blob (via GradientTexture2D)
bendn 2022-07-30
parent 6c60143 · commit 56ee3d6
-rw-r--r--Log.gd4
-rw-r--r--frame.pngbin519 -> 0 bytes
-rw-r--r--frame.png.import35
-rw-r--r--piece/Piece.gd18
-rw-r--r--piece/Piece.tscn27
-rw-r--r--piece/check-circle.tres14
-rw-r--r--piece/takeable-circle.tres13
-rw-r--r--ui/board/Board.gd7
-rw-r--r--ui/board/Board.tscn24
-rw-r--r--ui/menus/tests/test_runner.tscn34
-rw-r--r--ui/menus/tests/tests.gd2
11 files changed, 106 insertions, 72 deletions
diff --git a/Log.gd b/Log.gd
index 6a155b8..8090a6c 100644
--- a/Log.gd
+++ b/Log.gd
@@ -25,9 +25,7 @@ static func net(args) -> void:
static func file(path: String, args) -> void:
- var arg_string := to_str(args)
- debug(arg_string)
- SaveLoad.append_string(path, "(%s)%s" % [now(), arg_string])
+ SaveLoad.append_string(path, "(%s)%s" % [now(), to_str(args)])
static func now():
diff --git a/frame.png b/frame.png
deleted file mode 100644
index 3622499..0000000
--- a/frame.png
+++ /dev/null
Binary files differ
diff --git a/frame.png.import b/frame.png.import
deleted file mode 100644
index 92cdb3b..0000000
--- a/frame.png.import
+++ /dev/null
@@ -1,35 +0,0 @@
-[remap]
-
-importer="texture"
-type="StreamTexture"
-path="res://.import/frame.png-3ac25dcfa39cb943440d117e36cbfa2f.stex"
-metadata={
-"vram_texture": false
-}
-
-[deps]
-
-source_file="res://frame.png"
-dest_files=[ "res://.import/frame.png-3ac25dcfa39cb943440d117e36cbfa2f.stex" ]
-
-[params]
-
-compress/mode=0
-compress/lossy_quality=0.7
-compress/hdr_mode=0
-compress/bptc_ldr=0
-compress/normal_map=0
-flags/repeat=0
-flags/filter=false
-flags/mipmaps=false
-flags/anisotropic=false
-flags/srgb=2
-process/fix_alpha_border=true
-process/premult_alpha=false
-process/HDR_as_SRGB=false
-process/invert_color=false
-process/normal_map_invert_y=false
-stream=false
-size_limit=0
-detect_3d=false
-svg/scale=1.0
diff --git a/piece/Piece.gd b/piece/Piece.gd
index 0492414..8eaaaf0 100644
--- a/piece/Piece.gd
+++ b/piece/Piece.gd
@@ -1,14 +1,15 @@
extends Control
class_name Piece
-var position := ""
-var color := "w"
-var type := ""
+var position: String
+var color: String
+var type: String
var tween := Tween.new()
onready var sprite = $Sprite
-onready var frame = $Sprite/Frame
-onready var background = $ColorRect
+onready var frame = $"%Frame"
+onready var background = $"%Background"
+onready var check = $"%Check"
onready var anim = $AnimationPlayer
onready var rotate = $RotatePlayer
@@ -30,6 +31,7 @@ func _ready():
add_child(tween)
load_texture()
size()
+
frame.modulate = Globals.grid.overlay_color
background.color = Globals.grid.overlay_color
@@ -49,6 +51,12 @@ func _ready():
newsprite.name = p
newsprite.connect("pressed", self, "_pressed", [p])
previews.add_child(newsprite)
+ elif type == Chess.KING:
+ Events.connect("turn_over", self, "check_in_check")
+
+
+func check_in_check():
+ check.visible = Globals.grid.chess.__king_attacked(color)
func _pressed(p: String) -> void:
diff --git a/piece/Piece.tscn b/piece/Piece.tscn
index c9daea2..8bd1839 100644
--- a/piece/Piece.tscn
+++ b/piece/Piece.tscn
@@ -1,8 +1,9 @@
-[gd_scene load_steps=8 format=2]
+[gd_scene load_steps=9 format=2]
[ext_resource path="res://assets/pieces/california/wP.png" type="Texture" id=1]
-[ext_resource path="res://frame.png" type="Texture" id=2]
+[ext_resource path="res://piece/takeable-circle.tres" type="Texture" id=2]
[ext_resource path="res://piece/Piece.gd" type="Script" id=3]
+[ext_resource path="res://piece/check-circle.tres" type="Texture" id=4]
[sub_resource type="Animation" id=1]
resource_name = "Move"
@@ -110,27 +111,41 @@ rect_pivot_offset = Vector2( 40, 40 )
mouse_filter = 2
script = ExtResource( 3 )
-[node name="ColorRect" type="ColorRect" parent="."]
+[node name="Background" type="ColorRect" parent="."]
+unique_name_in_owner = true
visible = false
margin_right = 80.0
margin_bottom = 80.0
mouse_filter = 2
color = Color( 0.0784314, 0.333333, 0.117647, 0.498039 )
+[node name="Check" type="TextureRect" parent="."]
+unique_name_in_owner = true
+visible = false
+margin_right = 80.0
+margin_bottom = 80.0
+mouse_filter = 2
+texture = ExtResource( 4 )
+expand = true
+stretch_mode = 6
+
[node name="Sprite" type="TextureRect" parent="."]
margin_right = 80.0
margin_bottom = 80.0
mouse_filter = 2
texture = ExtResource( 1 )
expand = true
+stretch_mode = 6
-[node name="Frame" type="TextureRect" parent="Sprite"]
+[node name="Frame" type="TextureRect" parent="."]
+unique_name_in_owner = true
visible = false
-anchor_right = 1.0
-anchor_bottom = 1.0
+margin_right = 80.0
+margin_bottom = 80.0
mouse_filter = 2
texture = ExtResource( 2 )
expand = true
+stretch_mode = 6
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/Move = SubResource( 1 )
diff --git a/piece/check-circle.tres b/piece/check-circle.tres
new file mode 100644
index 0000000..f1ec6d7
--- /dev/null
+++ b/piece/check-circle.tres
@@ -0,0 +1,14 @@
+[gd_resource type="GradientTexture2D" load_steps=2 format=2]
+
+[sub_resource type="Gradient" id=1]
+offsets = PoolRealArray( 0, 0.3, 0.9, 1 )
+colors = PoolColorArray( 0.941176, 0, 0, 1, 0.905882, 0, 0, 1, 0.662745, 0, 0, 0, 0.619608, 0, 0, 0 )
+
+[resource]
+flags = 28
+gradient = SubResource( 1 )
+width = 80
+height = 80
+fill = 1
+fill_from = Vector2( 0.5, 0.5 )
+fill_to = Vector2( 0.991667, 0 )
diff --git a/piece/takeable-circle.tres b/piece/takeable-circle.tres
new file mode 100644
index 0000000..fcc0ea6
--- /dev/null
+++ b/piece/takeable-circle.tres
@@ -0,0 +1,13 @@
+[gd_resource type="GradientTexture2D" load_steps=2 format=2]
+
+[sub_resource type="Gradient" id=1]
+offsets = PoolRealArray( 0.7, 0.751515 )
+colors = PoolColorArray( 0, 0, 0, 0, 0.0784314, 0.333333, 0.117647, 1 )
+
+[resource]
+flags = 12
+gradient = SubResource( 1 )
+width = 80
+height = 80
+fill = 1
+fill_from = Vector2( 0.5, 0.5 )
diff --git a/ui/board/Board.gd b/ui/board/Board.gd
index 64cf7a1..4ec6e97 100644
--- a/ui/board/Board.gd
+++ b/ui/board/Board.gd
@@ -36,6 +36,8 @@ var flipped = false
var labels = {numbers = [], letters = []}
var background_array = []
var last_clicked
+var check_circle: GradientTexture2D = load("res://piece/check-circle.tres")
+var take_circle: GradientTexture2D = load("res://piece/takeable-circle.tres")
export(NodePath) var sidebar_path = @""
onready var sidebar := get_node_or_null(sidebar_path)
@@ -63,12 +65,17 @@ func _resized():
piece_size.x = clamp(piece_size.x, 0, piece_size.y)
piece_size.y = clamp(piece_size.y, 0, piece_size.x)
rect_pivot_offset = (piece_size * 8) / 2
+ check_circle.width = piece_size.x
+ check_circle.height = piece_size.y
+ take_circle.width = piece_size.x
+ take_circle.height = piece_size.y
if !(board.empty() && background_array.empty()) and piece_size != old_pc:
resize_board()
Log.debug("Resizing board")
func _ready():
+ take_circle.gradient.colors[1] = Color(overlay_color.r, overlay_color.g, overlay_color.b, 1)
_resized()
Events.connect("turn_over", self, "_on_turn_over")
PacketHandler.connect("move_data", self, "move")
diff --git a/ui/board/Board.tscn b/ui/board/Board.tscn
index e1c029c..1f7de1e 100644
--- a/ui/board/Board.tscn
+++ b/ui/board/Board.tscn
@@ -8,7 +8,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
margin_right = -1122.0
margin_bottom = -500.0
-rect_min_size = Vector2( 300, 300 )
+rect_min_size = Vector2( 600, 600 )
mouse_filter = 2
size_flags_horizontal = 3
size_flags_vertical = 3
@@ -20,27 +20,27 @@ __meta__ = {
}
[node name="Background" type="GridContainer" parent="."]
-margin_right = 300.0
-margin_bottom = 300.0
+margin_right = 600.0
+margin_bottom = 600.0
mouse_filter = 2
custom_constants/vseparation = 0
custom_constants/hseparation = 0
columns = 8
[node name="Pieces" type="Control" parent="."]
-margin_right = 300.0
-margin_bottom = 300.0
+margin_right = 600.0
+margin_bottom = 600.0
mouse_filter = 2
[node name="Canvas" type="ViewportContainer" parent="."]
modulate = Color( 1, 1, 1, 0.588235 )
-margin_right = 300.0
-margin_bottom = 300.0
+margin_right = 600.0
+margin_bottom = 600.0
mouse_filter = 2
stretch = true
[node name="Viewport" type="Viewport" parent="Canvas"]
-size = Vector2( 300, 300 )
+size = Vector2( 600, 600 )
transparent_bg = true
handle_input_locally = false
disable_3d = true
@@ -53,8 +53,8 @@ red_overlay = Color( 0.729412, 0.254902, 0.254902, 1 )
green_overlay = Color( 0.1272, 0.53, 0.18762, 1 )
[node name="Foreground" type="GridContainer" parent="."]
-margin_right = 300.0
-margin_bottom = 300.0
+margin_right = 600.0
+margin_bottom = 600.0
mouse_filter = 2
custom_constants/vseparation = 0
custom_constants/hseparation = 0
@@ -62,8 +62,8 @@ columns = 8
[node name="Darken" type="ColorRect" parent="."]
visible = false
-margin_right = 300.0
-margin_bottom = 300.0
+margin_right = 600.0
+margin_bottom = 600.0
mouse_filter = 2
mouse_default_cursor_shape = 8
color = Color( 0, 0, 0, 0.784314 )
diff --git a/ui/menus/tests/test_runner.tscn b/ui/menus/tests/test_runner.tscn
index f475858..88abb39 100644
--- a/ui/menus/tests/test_runner.tscn
+++ b/ui/menus/tests/test_runner.tscn
@@ -11,7 +11,7 @@ anchor_right = 1.0
anchor_bottom = 1.0
theme = ExtResource( 1 )
script = ExtResource( 2 )
-pgns = PoolStringArray( "1.Nf3 Nf6 2.c4 g6 3.Nc3 Bg7 4.d4 O-O 5.Bf4 d5 6.Qb3 dxc4 7.Qxc4 c6 8.e4 Nbd7 9.Rd1 Nb6 10.Qc5 Bg4 11.Bg5 Na4 12.Qa3 Nxc3 13.bxc3 Nxe4 14.Bxe7 Qb6 15.Bc4 Nxc3 16.Bc5 Rfe8+ 17.Kf1 Be6 18.Bxb6 Bxc4+ 19.Kg1 Ne2+ 20.Kf1 Nxd4+ 21.Kg1 Ne2+ 22.Kf1 Nc3+ 23.Kg1 axb6 24.Qb4 Ra4 25.Qxb6 Nxd1 26.h3 Rxa2 27.Kh2 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nc3+ 41.Kc1 Rc2# 0-1", "1. e4 e5 2. Nf3 Nc6 3. Bb5 Bc5 4. O-O Nf6 5. Nc3 Nb4 6. Nxe5 c6 7. Bc4 d5 8. exd5 cxd5 9. Bb5+ Bd7 10. Bxd7+ Nxd7 11. Nxd7 Qxd7 12. Re1+ Be7 13. a3 Nc6 14. d4 O-O-O 15. h3 Bh4 16. Qh5 Bf6 17. Nb5 Nxd4 18. Nxa7+ Kb8 19. Bg5 Nxc2 20. Bxf6 gxf6 21. a4 Kxa7 22. Qe2 Nxe1 23. Qxe1 Rhe8 24. Qa5+ Kb8 25. Qb4 d4 26. a5 Re6", "1. e4 f5 2. Qh5+", "1. f4 e5 2. e4 Qh4+" )
[node name="gameofthecentury" type="Button" parent="."]
margin_left = 517.0
@@ -40,10 +40,10 @@ custom_styles/disabled = SubResource( 1 )
custom_styles/normal = SubResource( 1 )
text = "ﭧ sign"
-[node name="test mate" type="Button" parent="."]
-margin_left = 637.0
+[node name="test check" type="Button" parent="."]
+margin_left = 563.0
margin_top = 122.0
-margin_right = 784.0
+margin_right = 859.0
margin_bottom = 168.0
focus_mode = 0
size_flags_horizontal = 4
@@ -52,13 +52,26 @@ custom_styles/pressed = SubResource( 1 )
custom_styles/focus = SubResource( 1 )
custom_styles/disabled = SubResource( 1 )
custom_styles/normal = SubResource( 1 )
-text = "ﭧ mate"
+text = "ﭧ check(white)"
+
+[node name="test check2" type="Button" parent="."]
+margin_left = 566.0
+margin_top = 183.0
+margin_right = 856.0
+margin_bottom = 229.0
+size_flags_horizontal = 4
+custom_styles/hover = SubResource( 1 )
+custom_styles/pressed = SubResource( 1 )
+custom_styles/focus = SubResource( 1 )
+custom_styles/disabled = SubResource( 1 )
+custom_styles/normal = SubResource( 1 )
+text = "ﭧ check(black)"
[node name="test chat" type="Button" parent="."]
margin_left = 671.0
-margin_top = 183.0
+margin_top = 244.0
margin_right = 751.0
-margin_bottom = 229.0
+margin_bottom = 290.0
size_flags_horizontal = 4
custom_styles/hover = SubResource( 1 )
custom_styles/pressed = SubResource( 1 )
@@ -69,9 +82,9 @@ text = "ﭧ"
[node name="engine tests" type="Button" parent="."]
margin_left = 555.0
-margin_top = 244.0
+margin_top = 305.0
margin_right = 867.0
-margin_bottom = 290.0
+margin_bottom = 351.0
size_flags_horizontal = 4
custom_styles/hover = SubResource( 1 )
custom_styles/pressed = SubResource( 1 )
@@ -83,5 +96,6 @@ script = ExtResource( 3 )
[connection signal="pressed" from="gameofthecentury" to="." method="_load" binds= [ 0 ]]
[connection signal="pressed" from="test sign" to="." method="_load" binds= [ 1 ]]
-[connection signal="pressed" from="test mate" to="." method="_load" binds= [ 2 ]]
+[connection signal="pressed" from="test check" to="." method="_load" binds= [ 2 ]]
+[connection signal="pressed" from="test check2" to="." method="_load" binds= [ 3 ]]
[connection signal="pressed" from="test chat" to="." method="_on_test_chat_pressed"]
diff --git a/ui/menus/tests/tests.gd b/ui/menus/tests/tests.gd
index d465d6e..247da6d 100644
--- a/ui/menus/tests/tests.gd
+++ b/ui/menus/tests/tests.gd
@@ -1,6 +1,6 @@
extends VBoxContainer
-export(PoolStringArray) var pgns = []
+export(PoolStringArray) var pgns
var in_sim = false