commit 45122b517568fb3d584de395a4ff680da08fff45 Author: CatAClock Date: Tue Apr 15 11:52:21 2025 -0700 codeberg copy diff --git a/Chess.png b/Chess.png new file mode 100644 index 0000000..d7ad79e Binary files /dev/null and b/Chess.png differ diff --git a/Chess.png.import b/Chess.png.import new file mode 100644 index 0000000..648d333 --- /dev/null +++ b/Chess.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bphl4a8t8l0h7" +path="res://.godot/imported/Chess.png-5aa5e1cd7f41db7e12bcda3ac0b5924e.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Chess.png" +dest_files=["res://.godot/imported/Chess.png-5aa5e1cd7f41db7e12bcda3ac0b5924e.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/ChessScenes/bishop.tscn b/ChessScenes/bishop.tscn new file mode 100644 index 0000000..543e497 --- /dev/null +++ b/ChessScenes/bishop.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=4 format=3 uid="uid://cu208w2aj6qnh"] + +[ext_resource type="Script" path="res://ChessScripts/bishop.gd" id="1_b0tyd"] +[ext_resource type="Texture2D" uid="uid://ca8t2shoassp2" path="res://ChessTextures/BBishop.svg" id="2_fvtue"] +[ext_resource type="Texture2D" uid="uid://bal1cx2x7hk7l" path="res://ChessTextures/WBishop.svg" id="3_i6xfw"] + +[node name="Bishop" type="Sprite2D"] +script = ExtResource("1_b0tyd") +Black = ExtResource("2_fvtue") +White = ExtResource("3_i6xfw") diff --git a/ChessScenes/king.tscn b/ChessScenes/king.tscn new file mode 100644 index 0000000..8842e3c --- /dev/null +++ b/ChessScenes/king.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=4 format=3 uid="uid://yqfgmt234xui"] + +[ext_resource type="Script" path="res://ChessScripts/king.gd" id="1_88uxw"] +[ext_resource type="Texture2D" uid="uid://b8e8353pyae4l" path="res://ChessTextures/BKing.svg" id="2_xat25"] +[ext_resource type="Texture2D" uid="uid://bgeifkewhw83q" path="res://ChessTextures/WKing.svg" id="3_rg8iu"] + +[node name="King" type="Sprite2D"] +script = ExtResource("1_88uxw") +Black = ExtResource("2_xat25") +White = ExtResource("3_rg8iu") diff --git a/ChessScenes/knight.tscn b/ChessScenes/knight.tscn new file mode 100644 index 0000000..bbfaf83 --- /dev/null +++ b/ChessScenes/knight.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=4 format=3 uid="uid://bgd6ldfcm8hie"] + +[ext_resource type="Script" path="res://ChessScripts/knight.gd" id="1_7qao2"] +[ext_resource type="Texture2D" uid="uid://bjneg3fh7mu2e" path="res://ChessTextures/BKnight.svg" id="2_2w5jy"] +[ext_resource type="Texture2D" uid="uid://dnp45xyp0eesa" path="res://ChessTextures/WKnight.svg" id="3_jfjqj"] + +[node name="Knight" type="Sprite2D"] +script = ExtResource("1_7qao2") +Black = ExtResource("2_2w5jy") +White = ExtResource("3_jfjqj") diff --git a/ChessScenes/pawn.tscn b/ChessScenes/pawn.tscn new file mode 100644 index 0000000..a1600f2 --- /dev/null +++ b/ChessScenes/pawn.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=4 format=3 uid="uid://dl8ctpb4nx5b4"] + +[ext_resource type="Script" path="res://ChessScripts/pawn.gd" id="1_2dlbf"] +[ext_resource type="Texture2D" uid="uid://1sql4pmy32c8" path="res://ChessTextures/BPawn.svg" id="2_ucadg"] +[ext_resource type="Texture2D" uid="uid://dl5dp47xg34sb" path="res://ChessTextures/WPawn.svg" id="3_n7bwu"] + +[node name="Pawn" type="Sprite2D"] +script = ExtResource("1_2dlbf") +Black = ExtResource("2_ucadg") +White = ExtResource("3_n7bwu") diff --git a/ChessScenes/queen.tscn b/ChessScenes/queen.tscn new file mode 100644 index 0000000..02a2596 --- /dev/null +++ b/ChessScenes/queen.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=4 format=3 uid="uid://1sle88win6dm"] + +[ext_resource type="Script" path="res://ChessScripts/queen.gd" id="1_djmia"] +[ext_resource type="Texture2D" uid="uid://cla2mshxp0elx" path="res://ChessTextures/BQueen.svg" id="2_grtjk"] +[ext_resource type="Texture2D" uid="uid://cr1lku07l36wb" path="res://ChessTextures/WQueen.svg" id="3_fvleu"] + +[node name="Queen" type="Sprite2D"] +script = ExtResource("1_djmia") +Black = ExtResource("2_grtjk") +White = ExtResource("3_fvleu") diff --git a/ChessScenes/rook.tscn b/ChessScenes/rook.tscn new file mode 100644 index 0000000..7c07946 --- /dev/null +++ b/ChessScenes/rook.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=4 format=3 uid="uid://cl7imfd1umhvu"] + +[ext_resource type="Script" path="res://ChessScripts/rook.gd" id="1_cx1v1"] +[ext_resource type="Texture2D" uid="uid://2an2oqh0ks1y" path="res://ChessTextures/BRook.svg" id="2_yjf4y"] +[ext_resource type="Texture2D" uid="uid://qisaumos7b53" path="res://ChessTextures/WRook.svg" id="3_vp7br"] + +[node name="Rook" type="Sprite2D"] +script = ExtResource("1_cx1v1") +Black = ExtResource("2_yjf4y") +White = ExtResource("3_vp7br") diff --git a/ChessScripts/bishop.gd b/ChessScripts/bishop.gd new file mode 100644 index 0000000..01c2219 --- /dev/null +++ b/ChessScripts/bishop.gd @@ -0,0 +1,14 @@ +extends Sprite2D + +# Standard +var PieceColor: int +@export var Black: CompressedTexture2D +@export var White: CompressedTexture2D + +func Spawned(color: int): + if color == 0: + self.texture = White + PieceColor = 0 + else: + self.texture = Black + PieceColor = 1 diff --git a/ChessScripts/king.gd b/ChessScripts/king.gd new file mode 100644 index 0000000..5145cbc --- /dev/null +++ b/ChessScripts/king.gd @@ -0,0 +1,17 @@ +extends Sprite2D + +# Extra ablilities +var Castling = true + +# Standard +var PieceColor: int +@export var Black: CompressedTexture2D +@export var White: CompressedTexture2D + +func Spawned(color: int): + if color == 0: + self.texture = White + PieceColor = 0 + else: + self.texture = Black + PieceColor = 1 diff --git a/ChessScripts/knight.gd b/ChessScripts/knight.gd new file mode 100644 index 0000000..01c2219 --- /dev/null +++ b/ChessScripts/knight.gd @@ -0,0 +1,14 @@ +extends Sprite2D + +# Standard +var PieceColor: int +@export var Black: CompressedTexture2D +@export var White: CompressedTexture2D + +func Spawned(color: int): + if color == 0: + self.texture = White + PieceColor = 0 + else: + self.texture = Black + PieceColor = 1 diff --git a/ChessScripts/pawn.gd b/ChessScripts/pawn.gd new file mode 100644 index 0000000..a8a92a6 --- /dev/null +++ b/ChessScripts/pawn.gd @@ -0,0 +1,18 @@ +extends Sprite2D + +# Extra ablilities +var DoubleStart = true +var EnPassant = false + +# Standard +var PieceColor: int +@export var Black: CompressedTexture2D +@export var White: CompressedTexture2D + +func Spawned(color: int): + if color == 0: + self.texture = White + PieceColor = 0 + else: + self.texture = Black + PieceColor = 1 diff --git a/ChessScripts/queen.gd b/ChessScripts/queen.gd new file mode 100644 index 0000000..01c2219 --- /dev/null +++ b/ChessScripts/queen.gd @@ -0,0 +1,14 @@ +extends Sprite2D + +# Standard +var PieceColor: int +@export var Black: CompressedTexture2D +@export var White: CompressedTexture2D + +func Spawned(color: int): + if color == 0: + self.texture = White + PieceColor = 0 + else: + self.texture = Black + PieceColor = 1 diff --git a/ChessScripts/rook.gd b/ChessScripts/rook.gd new file mode 100644 index 0000000..5145cbc --- /dev/null +++ b/ChessScripts/rook.gd @@ -0,0 +1,17 @@ +extends Sprite2D + +# Extra ablilities +var Castling = true + +# Standard +var PieceColor: int +@export var Black: CompressedTexture2D +@export var White: CompressedTexture2D + +func Spawned(color: int): + if color == 0: + self.texture = White + PieceColor = 0 + else: + self.texture = Black + PieceColor = 1 diff --git a/ChessTextures/BBishop.svg b/ChessTextures/BBishop.svg new file mode 100644 index 0000000..e88c406 --- /dev/null +++ b/ChessTextures/BBishop.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/ChessTextures/BBishop.svg.import b/ChessTextures/BBishop.svg.import new file mode 100644 index 0000000..bcf0cae --- /dev/null +++ b/ChessTextures/BBishop.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ca8t2shoassp2" +path="res://.godot/imported/BBishop.svg-32bac95d5ec3d4b5dc48860fe70db198.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ChessTextures/BBishop.svg" +dest_files=["res://.godot/imported/BBishop.svg-32bac95d5ec3d4b5dc48860fe70db198.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/ChessTextures/BKing.svg b/ChessTextures/BKing.svg new file mode 100644 index 0000000..ba2ac9f --- /dev/null +++ b/ChessTextures/BKing.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/ChessTextures/BKing.svg.import b/ChessTextures/BKing.svg.import new file mode 100644 index 0000000..de2fa0b --- /dev/null +++ b/ChessTextures/BKing.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://b8e8353pyae4l" +path="res://.godot/imported/BKing.svg-0e68d73bd48c1cf0da8d58870c0d70fe.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ChessTextures/BKing.svg" +dest_files=["res://.godot/imported/BKing.svg-0e68d73bd48c1cf0da8d58870c0d70fe.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/ChessTextures/BKnight.svg b/ChessTextures/BKnight.svg new file mode 100644 index 0000000..04541a8 --- /dev/null +++ b/ChessTextures/BKnight.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + diff --git a/ChessTextures/BKnight.svg.import b/ChessTextures/BKnight.svg.import new file mode 100644 index 0000000..9b7bad5 --- /dev/null +++ b/ChessTextures/BKnight.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bjneg3fh7mu2e" +path="res://.godot/imported/BKnight.svg-ab901432cba73437ff587bc1c6ca9974.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ChessTextures/BKnight.svg" +dest_files=["res://.godot/imported/BKnight.svg-ab901432cba73437ff587bc1c6ca9974.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/ChessTextures/BPawn.svg b/ChessTextures/BPawn.svg new file mode 100644 index 0000000..b534de8 --- /dev/null +++ b/ChessTextures/BPawn.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/ChessTextures/BPawn.svg.import b/ChessTextures/BPawn.svg.import new file mode 100644 index 0000000..b3df98f --- /dev/null +++ b/ChessTextures/BPawn.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://1sql4pmy32c8" +path="res://.godot/imported/BPawn.svg-89a4238a9f63fa634c3ae4588a7dfe4b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ChessTextures/BPawn.svg" +dest_files=["res://.godot/imported/BPawn.svg-89a4238a9f63fa634c3ae4588a7dfe4b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/ChessTextures/BQueen.svg b/ChessTextures/BQueen.svg new file mode 100644 index 0000000..e557734 --- /dev/null +++ b/ChessTextures/BQueen.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ChessTextures/BQueen.svg.import b/ChessTextures/BQueen.svg.import new file mode 100644 index 0000000..af80285 --- /dev/null +++ b/ChessTextures/BQueen.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cla2mshxp0elx" +path="res://.godot/imported/BQueen.svg-0f0716f66c779cdea1fabbd0a87d627a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ChessTextures/BQueen.svg" +dest_files=["res://.godot/imported/BQueen.svg-0f0716f66c779cdea1fabbd0a87d627a.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/ChessTextures/BRook.svg b/ChessTextures/BRook.svg new file mode 100644 index 0000000..4eec43c --- /dev/null +++ b/ChessTextures/BRook.svg @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + diff --git a/ChessTextures/BRook.svg.import b/ChessTextures/BRook.svg.import new file mode 100644 index 0000000..570df76 --- /dev/null +++ b/ChessTextures/BRook.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://2an2oqh0ks1y" +path="res://.godot/imported/BRook.svg-6b13852aba3b5f99b355465e2aa624fd.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ChessTextures/BRook.svg" +dest_files=["res://.godot/imported/BRook.svg-6b13852aba3b5f99b355465e2aa624fd.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/ChessTextures/WBishop.svg b/ChessTextures/WBishop.svg new file mode 100644 index 0000000..3a8eaa2 --- /dev/null +++ b/ChessTextures/WBishop.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/ChessTextures/WBishop.svg.import b/ChessTextures/WBishop.svg.import new file mode 100644 index 0000000..34887c8 --- /dev/null +++ b/ChessTextures/WBishop.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bal1cx2x7hk7l" +path="res://.godot/imported/WBishop.svg-686706903502a95cd46cd77a78ee9440.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ChessTextures/WBishop.svg" +dest_files=["res://.godot/imported/WBishop.svg-686706903502a95cd46cd77a78ee9440.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/ChessTextures/WKing.svg b/ChessTextures/WKing.svg new file mode 100644 index 0000000..632ca1a --- /dev/null +++ b/ChessTextures/WKing.svg @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/ChessTextures/WKing.svg.import b/ChessTextures/WKing.svg.import new file mode 100644 index 0000000..e2a814b --- /dev/null +++ b/ChessTextures/WKing.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bgeifkewhw83q" +path="res://.godot/imported/WKing.svg-5baf29b7cc0647974c7427255174f754.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ChessTextures/WKing.svg" +dest_files=["res://.godot/imported/WKing.svg-5baf29b7cc0647974c7427255174f754.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/ChessTextures/WKnight.svg b/ChessTextures/WKnight.svg new file mode 100644 index 0000000..a5f31c6 --- /dev/null +++ b/ChessTextures/WKnight.svg @@ -0,0 +1,19 @@ + + + + + + + + + + diff --git a/ChessTextures/WKnight.svg.import b/ChessTextures/WKnight.svg.import new file mode 100644 index 0000000..6fe0808 --- /dev/null +++ b/ChessTextures/WKnight.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dnp45xyp0eesa" +path="res://.godot/imported/WKnight.svg-77361976620fc1216b47056d5a4529b1.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ChessTextures/WKnight.svg" +dest_files=["res://.godot/imported/WKnight.svg-77361976620fc1216b47056d5a4529b1.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/ChessTextures/WPawn.svg b/ChessTextures/WPawn.svg new file mode 100644 index 0000000..b265fe1 --- /dev/null +++ b/ChessTextures/WPawn.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/ChessTextures/WPawn.svg.import b/ChessTextures/WPawn.svg.import new file mode 100644 index 0000000..af0cb6c --- /dev/null +++ b/ChessTextures/WPawn.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dl5dp47xg34sb" +path="res://.godot/imported/WPawn.svg-b837731bbfbbbf8bc72cb8688f8b3a79.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ChessTextures/WPawn.svg" +dest_files=["res://.godot/imported/WPawn.svg-b837731bbfbbbf8bc72cb8688f8b3a79.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/ChessTextures/WQueen.svg b/ChessTextures/WQueen.svg new file mode 100644 index 0000000..8df7c8f --- /dev/null +++ b/ChessTextures/WQueen.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/ChessTextures/WQueen.svg.import b/ChessTextures/WQueen.svg.import new file mode 100644 index 0000000..2eee640 --- /dev/null +++ b/ChessTextures/WQueen.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cr1lku07l36wb" +path="res://.godot/imported/WQueen.svg-0bb76d6b190776365484fd4d31df0913.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ChessTextures/WQueen.svg" +dest_files=["res://.godot/imported/WQueen.svg-0bb76d6b190776365484fd4d31df0913.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/ChessTextures/WRook.svg b/ChessTextures/WRook.svg new file mode 100644 index 0000000..0574ca6 --- /dev/null +++ b/ChessTextures/WRook.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + diff --git a/ChessTextures/WRook.svg.import b/ChessTextures/WRook.svg.import new file mode 100644 index 0000000..2543059 --- /dev/null +++ b/ChessTextures/WRook.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://qisaumos7b53" +path="res://.godot/imported/WRook.svg-39b447f94ad3647c8bc4cff26af8747b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://ChessTextures/WRook.svg" +dest_files=["res://.godot/imported/WRook.svg-39b447f94ad3647c8bc4cff26af8747b.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/board.tscn b/board.tscn new file mode 100644 index 0000000..5415378 --- /dev/null +++ b/board.tscn @@ -0,0 +1,82 @@ +[gd_scene load_steps=10 format=3 uid="uid://d0qyk6v20uief"] + +[ext_resource type="Script" path="res://generator.gd" id="1_ckrtr"] +[ext_resource type="Script" path="res://game.gd" id="1_f1l42"] +[ext_resource type="PackedScene" uid="uid://dl8ctpb4nx5b4" path="res://ChessScenes/pawn.tscn" id="3_871tv"] +[ext_resource type="PackedScene" uid="uid://cu208w2aj6qnh" path="res://ChessScenes/bishop.tscn" id="4_f2vpi"] +[ext_resource type="PackedScene" uid="uid://cl7imfd1umhvu" path="res://ChessScenes/rook.tscn" id="5_lwy4i"] +[ext_resource type="PackedScene" uid="uid://bgd6ldfcm8hie" path="res://ChessScenes/knight.tscn" id="6_ta68t"] +[ext_resource type="PackedScene" uid="uid://1sle88win6dm" path="res://ChessScenes/queen.tscn" id="7_7creb"] +[ext_resource type="PackedScene" uid="uid://yqfgmt234xui" path="res://ChessScenes/king.tscn" id="8_vvr6q"] +[ext_resource type="Script" path="res://game_win.gd" id="9_ww6wk"] + +[node name="Board" type="Control"] +layout_mode = 3 +anchors_preset = 0 +offset_right = 40.0 +offset_bottom = 40.0 +script = ExtResource("1_f1l42") +BoardPath = NodePath("Flow") + +[node name="Flow" type="FlowContainer" parent="."] +layout_mode = 0 +script = ExtResource("1_ckrtr") +Pawn = ExtResource("3_871tv") +Bishop = ExtResource("4_f2vpi") +Rook = ExtResource("5_lwy4i") +Knight = ExtResource("6_ta68t") +Queen = ExtResource("7_7creb") +King = ExtResource("8_vvr6q") + +[node name="GameWin" type="Control" parent="."] +anchors_preset = 0 +offset_right = 40.0 +offset_bottom = 40.0 +script = ExtResource("9_ww6wk") + +[node name="Promotion" type="Panel" parent="."] +visible = false +layout_mode = 0 +offset_left = 531.0 +offset_top = 130.0 +offset_right = 731.0 +offset_bottom = 330.0 + +[node name="Rook" type="Button" parent="Promotion"] +layout_mode = 0 +offset_left = 8.0 +offset_top = 10.0 +offset_right = 55.0 +offset_bottom = 41.0 +text = "Rook" + +[node name="Bishop" type="Button" parent="Promotion"] +layout_mode = 0 +offset_left = 68.0 +offset_top = 10.0 +offset_right = 115.0 +offset_bottom = 41.0 +text = "Bishop" + +[node name="Knight" type="Button" parent="Promotion"] +layout_mode = 0 +offset_left = 9.0 +offset_top = 50.0 +offset_right = 56.0 +offset_bottom = 81.0 +text = "Knight" + +[node name="Queen" type="Button" parent="Promotion"] +layout_mode = 0 +offset_left = 79.0 +offset_top = 52.0 +offset_right = 140.0 +offset_bottom = 83.0 +text = "Queen" + +[connection signal="GameWin" from="." to="GameWin" method="_on_board_game_win"] +[connection signal="SendLocation" from="Flow" to="." method="_on_flow_send_location"] +[connection signal="pressed" from="Promotion/Rook" to="." method="FinalizePromotion" binds= ["Rook"]] +[connection signal="pressed" from="Promotion/Bishop" to="." method="FinalizePromotion" binds= ["Bishop"]] +[connection signal="pressed" from="Promotion/Knight" to="." method="FinalizePromotion" binds= ["Knight"]] +[connection signal="pressed" from="Promotion/Queen" to="." method="FinalizePromotion" binds= ["Queen"]] diff --git a/game.gd b/game.gd new file mode 100644 index 0000000..6e4bf98 --- /dev/null +++ b/game.gd @@ -0,0 +1,381 @@ +extends Control + +signal GameWin + +# Selected node is the button pressed before the one you just pressed. +var SelectedNode = "" +# If you don't have a good solution, do your promotions with another variable~ +var SavedNode = "" +var Turn = 0 + +# Location on which node was clicked. +# Ints are here to reduce the size of some lines. +var LocationX: String +var LocationY: String +var LocationXInt: int +var LocationYInt: int + +# This is the board buttons. +@export_node_path("FlowContainer") var BoardPath +@onready var Flow = get_node(BoardPath) + +@onready var pos: Vector2 = Vector2(self.get_child(0).TileXSize / 2, self.get_child(0).TileYSize / 2) +# Areas where the player can move +var Areas: PackedStringArray +# this is seperate the Areas for special circumstances, like castling. +var SpecialArea: PackedStringArray + +func _on_flow_send_location(Location: String): + # Don't update ANYTHING if you still need to promote! + if get_node("Promotion").visible == true: + return + + # variables for later + var number = 0 + var cell = Flow.get_node(Location) + # This is to try and grab the X and Y coordinates from the board + LocationX = "" + LocationY = "" + while Location.substr(number, 1) != "-": + LocationX += Location.substr(number, 1) + number += 1 + LocationY = Location.substr(number + 1) + LocationXInt = int(LocationX) + LocationYInt = int(LocationY) + # Now... we need to figure out how to select the pieces. If there is a valid move, do stuff. + # If we re-select, just go to that other piece + if SelectedNode == "" && cell.get_child_count() != 0 && cell.get_child(0).PieceColor == Turn: + SelectedNode = Location + GetMovableAreas() + # Castling + elif SelectedNode != "" && cell.get_child_count() != 0 && cell.get_child(0).PieceColor == Turn && cell.get_child(0).name == "Rook": + for i in Areas: + if i == cell.name: + var king = Flow.get_node(SelectedNode).get_child(0) + var rook = cell.get_child(0) + # Using a seperate array because Areas wouldn't be really consistant... + king.reparent(Flow.get_node(SpecialArea[1])) + rook.reparent(Flow.get_node(SpecialArea[0])) + king.position = pos + rook.position = pos + # We have to get the parent because it will break lmao. + UpdateGame(cell) + # En Passant + elif SelectedNode != "" && cell.get_child_count() != 0 && cell.get_child(0).PieceColor != Turn && cell.get_child(0).name == "Pawn" && SpecialArea.size() != 0 && SpecialArea[0] == cell.name && cell.get_child(0).EnPassant == true: + for i in SpecialArea: + if i == cell.name: + var pawn = Flow.get_node(SelectedNode).get_child(0) + cell.get_child(0).free() + pawn.reparent(Flow.get_node(SpecialArea[1])) + pawn.position = pos + UpdateGame(cell) + # Re-select + elif SelectedNode != "" && cell.get_child_count() != 0 && cell.get_child(0).PieceColor == Turn: + SelectedNode = Location + GetMovableAreas() + # Taking over a piece + elif SelectedNode != "" && cell.get_child_count() != 0 && cell.get_child(0).PieceColor != Turn: + for i in Areas: + if i == cell.name: + var Piece = Flow.get_node(SelectedNode).get_child(0) + # Win conditions + if cell.get_child(0).name == "King": + GameWin.emit() + cell.get_child(0).free() + SavedNode = Location + Piece.reparent(cell) + Piece.position = pos + UpdateGame(cell) + # Moving a piece + elif SelectedNode != "" && cell.get_child_count() == 0: + for i in Areas: + if i == cell.name: + var Piece = Flow.get_node(SelectedNode).get_child(0) + SavedNode = Location + Piece.reparent(cell) + Piece.position = pos + UpdateGame(cell) + +func UpdateGame(cell): + SelectedNode = "" + if Turn == 0: + Turn = 1 + else: + Turn = 0 + + # get the en-passantable pieces and undo them + var things = Flow.get_children() + for i in things: + if i.get_child_count() != 0 && i.get_child(0).name == "Pawn" && i.get_child(0).PieceColor == Turn && i.get_child(0).EnPassant == true: + i.get_child(0).EnPassant = false + + # Remove and add the abilities once they are either used or not used + if cell.get_child(0).name == "Pawn": + PawnPromotion(cell.get_child(0)) + if cell.get_child(0).DoubleStart == true: + cell.get_child(0).EnPassant = true + cell.get_child(0).DoubleStart = false + if cell.get_child(0).name == "King": + cell.get_child(0).Castling = false + if cell.get_child(0).name == "Rook": + cell.get_child(0).Castling = false + +# Below is the movement that is used for the pieces +func GetMovableAreas(): + # Clearing the arrays + Areas.clear() + SpecialArea.clear() + var Piece = Flow.get_node(SelectedNode).get_child(0) + # For the selected piece that we have, we can get the movement that we need here. + if Piece.name == "Pawn": + GetPawn(Piece) + elif Piece.name == "Bishop": + GetDiagonals() + elif Piece.name == "King": + GetAround(Piece) + elif Piece.name == "Queen": + GetDiagonals() + GetRows() + elif Piece.name == "Rook": + GetRows() + elif Piece.name == "Knight": + GetHorse() + +func PawnPromotion(Piece): + # This is for going from the bottom to the top, also known as the white pawns. + if IsNull(LocationX + "-" + str(LocationYInt - 1)) && Piece.PieceColor == 0: + get_node("Promotion").visible = true + elif IsNull(LocationX + "-" + str(LocationYInt + 1)) && Piece.PieceColor == 1: + get_node("Promotion").visible = true + +# TODO: Make this less crap +func FinalizePromotion(Selection): + var Piece = Flow.get_node(SavedNode).get_child(0) + var NewPiece + if Selection == "Bishop": + var thing = ResourceLoader.load("res://ChessScenes/bishop.tscn") + NewPiece = thing.instantiate() + if Piece.PieceColor == 0: + NewPiece.Spawned(0) + else: + NewPiece.Spawned(1) + NewPiece.position = pos + Flow.get_node(SavedNode).add_child(NewPiece) + elif Selection == "Queen": + var thing = ResourceLoader.load("res://ChessScenes/queen.tscn") + NewPiece = thing.instantiate() + if Piece.PieceColor == 0: + NewPiece.Spawned(0) + else: + NewPiece.Spawned(1) + NewPiece.position = pos + Flow.get_node(SavedNode).add_child(NewPiece) + elif Selection == "Rook": + var thing = ResourceLoader.load("res://ChessScenes/rook.tscn") + NewPiece = thing.instantiate() + if Piece.PieceColor == 0: + NewPiece.Spawned(0) + else: + NewPiece.Spawned(1) + NewPiece.position = pos + Flow.get_node(SavedNode).add_child(NewPiece) + elif Selection == "Knight": + var thing = ResourceLoader.load("res://ChessScenes/knight.tscn") + NewPiece = thing.instantiate() + if Piece.PieceColor == 0: + NewPiece.Spawned(0) + else: + NewPiece.Spawned(1) + NewPiece.position = pos + Flow.get_node(SavedNode).add_child(NewPiece) + Piece.free() + get_node("Promotion").visible = false + +func GetPawn(Piece): + # This is for going from the bottom to the top, also known as the white pawns. + if Piece.PieceColor == 0: + if not IsNull(LocationX + "-" + str(LocationYInt - 1)) && Flow.get_node(LocationX + "-" + str(LocationYInt - 1)).get_child_count() == 0: + Areas.append(LocationX + "-" + str(LocationYInt - 1)) + if not IsNull(LocationX + "-" + str(LocationYInt - 2)) && Piece.DoubleStart == true && Flow.get_node(LocationX + "-" + str(LocationYInt - 2)).get_child_count() == 0: + Areas.append(LocationX + "-" + str(LocationYInt - 2)) + # Attacking squares + if not IsNull(str(LocationXInt - 1) + "-" + str(LocationYInt - 1)) && Flow.get_node(str(LocationXInt - 1) + "-" + str(LocationYInt - 1)).get_child_count() == 1: + Areas.append(str(LocationXInt - 1) + "-" + str(LocationYInt - 1)) + if not IsNull(str(LocationXInt + 1) + "-" + str(LocationYInt - 1)) && Flow.get_node(str(LocationXInt + 1) + "-" + str(LocationYInt - 1)).get_child_count() == 1: + Areas.append(str(LocationXInt + 1) + "-" + str(LocationYInt - 1)) + # En passant + if not IsNull(str(LocationXInt - 1) + "-" + LocationY) && not IsNull(str(LocationXInt - 1) + "-" + str(LocationYInt - 1)): + if Flow.get_node(str(LocationXInt - 1) + "-" + LocationY).get_child_count() == 1 && Flow.get_node(str(LocationXInt - 1) + "-" + str(LocationYInt - 1)).get_child_count() != 1: + SpecialArea.append(str(LocationXInt - 1) + "-" + LocationY) + SpecialArea.append(str(LocationXInt - 1) + "-" + str(LocationYInt - 1)) + if not IsNull(str(LocationXInt + 1) + "-" + LocationY) && not IsNull(str(LocationXInt + 1) + "-" + str(LocationYInt - 1)): + if Flow.get_node(str(LocationXInt + 1) + "-" + LocationY).get_child_count() == 1 && Flow.get_node(str(LocationXInt + 1) + "-" + str(LocationYInt - 1)).get_child_count() != 1: + SpecialArea.append(str(LocationXInt + 1) + "-" + LocationY) + SpecialArea.append(str(LocationXInt + 1) + "-" + str(LocationYInt - 1)) + # Black pawns + else: + if not IsNull(LocationX + "-" + str(LocationYInt + 1)) && Flow.get_node(LocationX + "-" + str(LocationYInt + 1)).get_child_count() == 0: + Areas.append(LocationX + "-" + str(LocationYInt + 1)) + if not IsNull(LocationX + "-" + str(LocationYInt + 2)) && Piece.DoubleStart == true && Flow.get_node(LocationX + "-" + str(LocationYInt + 2)).get_child_count() == 0: + Areas.append(LocationX + "-" + str(LocationYInt + 2)) + # Attacking squares + if not IsNull(str(LocationXInt - 1) + "-" + str(LocationYInt + 1)) && Flow.get_node(str(LocationXInt - 1) + "-" + str(LocationYInt + 1)).get_child_count() == 1: + Areas.append(str(LocationXInt - 1) + "-" + str(LocationYInt + 1)) + if not IsNull(str(LocationXInt + 1) + "-" + str(LocationYInt + 1)) && Flow.get_node(str(LocationXInt + 1) + "-" + str(LocationYInt + 1)).get_child_count() == 1: + Areas.append(str(LocationXInt + 1) + "-" + str(LocationYInt + 1)) + # En passant + if not IsNull(str(LocationXInt - 1) + "-" + LocationY) && not IsNull(str(LocationXInt - 1) + "-" + str(LocationYInt + 1)): + if Flow.get_node(str(LocationXInt - 1) + "-" + LocationY).get_child_count() == 1 && Flow.get_node(str(LocationXInt - 1) + "-" + str(LocationYInt + 1)).get_child_count() != 1: + SpecialArea.append(str(LocationXInt - 1) + "-" + LocationY) + SpecialArea.append(str(LocationXInt - 1) + "-" + str(LocationYInt + 1)) + if not IsNull(str(LocationXInt + 1) + "-" + LocationY) && not IsNull(str(LocationXInt + 1) + "-" + str(LocationYInt + 1)): + if Flow.get_node(str(LocationXInt + 1) + "-" + LocationY).get_child_count() == 1 && Flow.get_node(str(LocationXInt + 1) + "-" + str(LocationYInt+ 1)).get_child_count() != 1: + SpecialArea.append(str(LocationXInt + 1) + "-" + LocationY) + SpecialArea.append(str(LocationXInt + 1) + "-" + str(LocationYInt + 1)) + +func GetAround(Piece): + # Single Rows + if not IsNull(LocationX + "-" + str(LocationYInt + 1)): + Areas.append(LocationX + "-" + str(LocationYInt + 1)) + if not IsNull(LocationX + "-" + str(LocationYInt - 1)): + Areas.append(LocationX + "-" + str(LocationYInt - 1)) + if not IsNull(str(LocationXInt + 1) + "-" + LocationY): + Areas.append(str(LocationXInt + 1) + "-" + LocationY) + if not IsNull(str(LocationXInt - 1) + "-" + LocationY): + Areas.append(str(LocationXInt - 1) + "-" + LocationY) + # Diagonal + if not IsNull(str(LocationXInt + 1) + "-" + str(LocationYInt + 1)): + Areas.append(str(LocationXInt + 1) + "-" + str(LocationYInt + 1)) + if not IsNull(str(LocationXInt - 1) + "-" + str(LocationYInt + 1)): + Areas.append(str(LocationXInt - 1) + "-" + str(LocationYInt + 1)) + if not IsNull(str(LocationXInt + 1) + "-" + str(LocationYInt - 1)): + Areas.append(str(LocationXInt + 1) + "-" + str(LocationYInt - 1)) + if not IsNull(str(LocationXInt - 1) + "-" + str(LocationYInt - 1)): + Areas.append(str(LocationXInt - 1) + "-" + str(LocationYInt - 1)) + # Castling, if that is the case + if Piece.Castling == true: + Castle() + +func GetRows(): + var AddX = 1 + # Getting the horizontal rows first. + while not IsNull(str(LocationXInt + AddX) + "-" + LocationY): + Areas.append(str(LocationXInt + AddX) + "-" + LocationY) + if Flow.get_node(str(LocationXInt + AddX) + "-" + LocationY).get_child_count() != 0: + break + AddX += 1 + AddX = 1 + while not IsNull(str(LocationXInt - AddX) + "-" + LocationY): + Areas.append(str(LocationXInt - AddX) + "-" + LocationY) + if Flow.get_node(str(LocationXInt - AddX) + "-" + LocationY).get_child_count() != 0: + break + AddX += 1 + var AddY = 1 + # Now we are getting the vertical rows. + while not IsNull(LocationX + "-" + str(LocationYInt + AddY)): + Areas.append(LocationX + "-" + str(LocationYInt + AddY)) + if Flow.get_node(LocationX + "-" + str(LocationYInt + AddY)).get_child_count() != 0: + break + AddY += 1 + AddY = 1 + while not IsNull(LocationX + "-" + str(LocationYInt - AddY)): + Areas.append(LocationX + "-" + str(LocationYInt - AddY)) + if Flow.get_node(LocationX + "-" + str(LocationYInt - AddY)).get_child_count() != 0: + break + AddY += 1 + +func GetDiagonals(): + var AddX = 1 + var AddY = 1 + while not IsNull(str(LocationXInt + AddX) + "-" + str(LocationYInt + AddY)): + Areas.append(str(LocationXInt + AddX) + "-" + str(LocationYInt + AddY)) + if Flow.get_node(str(LocationXInt + AddX) + "-" + str(LocationYInt + AddY)).get_child_count() != 0: + break + AddX += 1 + AddY += 1 + AddX = 1 + AddY = 1 + while not IsNull(str(LocationXInt - AddX) + "-" + str(LocationYInt + AddY)): + Areas.append(str(LocationXInt - AddX) + "-" + str(LocationYInt + AddY)) + if Flow.get_node(str(LocationXInt - AddX) + "-" + str(LocationYInt + AddY)).get_child_count() != 0: + break + AddX += 1 + AddY += 1 + AddX = 1 + AddY = 1 + while not IsNull(str(LocationXInt + AddX) + "-" + str(LocationYInt - AddY)): + Areas.append(str(LocationXInt + AddX) + "-" + str(LocationYInt - AddY)) + if Flow.get_node(str(LocationXInt + AddX) + "-" + str(LocationYInt - AddY)).get_child_count() != 0: + break + AddX += 1 + AddY += 1 + AddX = 1 + AddY = 1 + while not IsNull(str(LocationXInt - AddX) + "-" + str(LocationYInt - AddY)): + Areas.append(str(LocationXInt - AddX) + "-" + str(LocationYInt - AddY)) + if Flow.get_node(str(LocationXInt - AddX) + "-" + str(LocationYInt - AddY)).get_child_count() != 0: + break + AddX += 1 + AddY += 1 + +func GetHorse(): + var TheX = 2 + var TheY = 1 + var number = 0 + while number != 8: + # So this one is interesting. This is most likely the cleanest code here. + # Get the numbers, replace the numbers, and loop until it stops. + if not IsNull(str(LocationXInt + TheX) + "-" + str(LocationYInt + TheY)): + Areas.append(str(LocationXInt + TheX) + "-" + str(LocationYInt + TheY)) + number += 1 + match number: + 1: + TheX = 1 + TheY = 2 + 2: + TheX = -2 + TheY = 1 + 3: + TheX = -1 + TheY = 2 + 4: + TheX = 2 + TheY = -1 + 5: + TheX = 1 + TheY = -2 + 6: + TheX = -2 + TheY = -1 + 7: + TheX = -1 + TheY = -2 + +func Castle(): + # This is the castling section right here, used if a person wants to castle. + var CounterX = 1 + # These are very similar to gathering a row, except we want free tiles and a rook + # Counting up + while not IsNull(str(LocationXInt + CounterX) + "-" + LocationY) && Flow.get_node(str(LocationXInt + CounterX) + "-" + LocationY).get_child_count() == 0: + CounterX += 1 + if not IsNull(str(LocationXInt + CounterX) + "-" + LocationY) && Flow.get_node(str(LocationXInt + CounterX) + "-" + LocationY).get_child(0).name == "Rook": + if Flow.get_node(str(LocationXInt + CounterX) + "-" + LocationY).get_child(0).Castling == true: + Areas.append(str(LocationXInt + CounterX) + "-" + LocationY) + SpecialArea.append(str(LocationXInt + 1) + "-" + LocationY) + SpecialArea.append(str(LocationXInt + 2) + "-" + LocationY) + # Counting down + CounterX = -1 + while not IsNull(str(LocationXInt + CounterX) + "-" + LocationY) && Flow.get_node(str(LocationXInt + CounterX) + "-" + LocationY).get_child_count() == 0: + CounterX -= 1 + if not IsNull(str(LocationXInt + CounterX) + "-" + LocationY) && Flow.get_node(str(LocationXInt + CounterX) + "-" + LocationY).get_child(0).name == "Rook": + if Flow.get_node(str(LocationXInt + CounterX) + "-" + LocationY).get_child(0).Castling == true: + Areas.append(str(LocationXInt + CounterX) + "-" + LocationY) + SpecialArea.append(str(LocationXInt - 1) + "-" + LocationY) + SpecialArea.append(str(LocationXInt - 2) + "-" + LocationY) + +# One function that shortens everything. Its also a pretty good way to see if we went off the board or not. +func IsNull(Location): + if Flow.get_node_or_null(Location) == null: + return true + else: + return false diff --git a/game_win.gd b/game_win.gd new file mode 100644 index 0000000..c4f1149 --- /dev/null +++ b/game_win.gd @@ -0,0 +1,4 @@ +extends Control + +func _on_board_game_win() -> void: + print("Damn, you win!") diff --git a/generator.gd b/generator.gd new file mode 100644 index 0000000..407a384 --- /dev/null +++ b/generator.gd @@ -0,0 +1,87 @@ +extends FlowContainer + +@export var BoardXSize = 8 +@export var BoardYSize = 8 + +@export var TileXSize: float = 50 +@export var TileYSize: float = 50 + +@export var PlayRegularGame: bool = true + +signal SendLocation(Location: String) + +@export var Pawn: PackedScene +@export var Bishop: PackedScene +@export var Rook: PackedScene +@export var Knight: PackedScene +@export var Queen: PackedScene +@export var King: PackedScene + +func _ready(): + # stop negative numbers from happening + if BoardXSize < 0 || BoardYSize < 0: + return + var NumberX: int = 0 + var NumberY: int = 0 + # Set up the board + while NumberY != BoardYSize: + self.size.y += TileYSize + 5 + self.size.x += TileXSize + 5 + while NumberX != BoardXSize: + var temp = Button.new() + temp.set_custom_minimum_size(Vector2(TileXSize, TileYSize)) + temp.connect("pressed", func(): + SendLocation.emit(temp.name)) + temp.set_name(str(NumberX) + "-" + str(NumberY)) + add_child(temp) + NumberX += 1 + NumberY += 1 + NumberX = 0 + if PlayRegularGame == true: + RegularGame() + +# 1 = black +# 0 = white +func RegularGame(): + get_node("0-0").add_child(Summon(Rook, 1)) + get_node("1-0").add_child(Summon(Knight, 1)) + get_node("2-0").add_child(Summon(Bishop, 1)) + get_node("3-0").add_child(Summon(Queen, 1)) + get_node("4-0").add_child(Summon(King, 1)) + get_node("5-0").add_child(Summon(Bishop, 1)) + get_node("6-0").add_child(Summon(Knight, 1)) + get_node("7-0").add_child(Summon(Rook, 1)) + + get_node("0-1").add_child(Summon(Pawn, 1)) + get_node("1-1").add_child(Summon(Pawn, 1)) + get_node("2-1").add_child(Summon(Pawn, 1)) + get_node("3-1").add_child(Summon(Pawn, 1)) + get_node("4-1").add_child(Summon(Pawn, 1)) + get_node("5-1").add_child(Summon(Pawn, 1)) + get_node("6-1").add_child(Summon(Pawn, 1)) + get_node("7-1").add_child(Summon(Pawn, 1)) + + get_node("0-6").add_child(Summon(Pawn, 0)) + get_node("1-6").add_child(Summon(Pawn, 0)) + get_node("2-6").add_child(Summon(Pawn, 0)) + get_node("3-6").add_child(Summon(Pawn, 0)) + get_node("4-6").add_child(Summon(Pawn, 0)) + get_node("5-6").add_child(Summon(Pawn, 0)) + get_node("6-6").add_child(Summon(Pawn, 0)) + get_node("7-6").add_child(Summon(Pawn, 0)) + + get_node("0-7").add_child(Summon(Rook, 0)) + get_node("1-7").add_child(Summon(Knight, 0)) + get_node("2-7").add_child(Summon(Bishop, 0)) + get_node("3-7").add_child(Summon(Queen, 0)) + get_node("4-7").add_child(Summon(King, 0)) + get_node("5-7").add_child(Summon(Bishop, 0)) + get_node("6-7").add_child(Summon(Knight, 0)) + get_node("7-7").add_child(Summon(Rook, 0)) + +func Summon(Scene: PackedScene, color: int): + var Piece = Scene.instantiate() + Piece.Spawned(color) + # This is the point, ignore the warning + Piece.position = Vector2(TileXSize / 2, TileYSize / 2) + return Piece diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..b142325 --- /dev/null +++ b/project.godot @@ -0,0 +1,25 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="Godot Chess" +config/description="The classic game of Chess in Godot Engine" +run/main_scene="res://board.tscn" +config/features=PackedStringArray("4.3", "Forward Plus") +config/icon="res://Chess.png" + +[editor_plugins] + +enabled=PackedStringArray() + +[filesystem] + +import/blender/enabled=false