From 45122b517568fb3d584de395a4ff680da08fff45 Mon Sep 17 00:00:00 2001 From: CatAClock Date: Tue, 15 Apr 2025 11:52:21 -0700 Subject: [PATCH] codeberg copy --- Chess.png | Bin 0 -> 5282 bytes Chess.png.import | 34 +++ ChessScenes/bishop.tscn | 10 + ChessScenes/king.tscn | 10 + ChessScenes/knight.tscn | 10 + ChessScenes/pawn.tscn | 10 + ChessScenes/queen.tscn | 10 + ChessScenes/rook.tscn | 10 + ChessScripts/bishop.gd | 14 ++ ChessScripts/king.gd | 17 ++ ChessScripts/knight.gd | 14 ++ ChessScripts/pawn.gd | 18 ++ ChessScripts/queen.gd | 14 ++ ChessScripts/rook.gd | 17 ++ ChessTextures/BBishop.svg | 12 + ChessTextures/BBishop.svg.import | 37 +++ ChessTextures/BKing.svg | 12 + ChessTextures/BKing.svg.import | 37 +++ ChessTextures/BKnight.svg | 22 ++ ChessTextures/BKnight.svg.import | 37 +++ ChessTextures/BPawn.svg | 5 + ChessTextures/BPawn.svg.import | 37 +++ ChessTextures/BQueen.svg | 27 +++ ChessTextures/BQueen.svg.import | 37 +++ ChessTextures/BRook.svg | 39 ++++ ChessTextures/BRook.svg.import | 37 +++ ChessTextures/WBishop.svg | 12 + ChessTextures/WBishop.svg.import | 37 +++ ChessTextures/WKing.svg | 9 + ChessTextures/WKing.svg.import | 37 +++ ChessTextures/WKnight.svg | 19 ++ ChessTextures/WKnight.svg.import | 37 +++ ChessTextures/WPawn.svg | 5 + ChessTextures/WPawn.svg.import | 37 +++ ChessTextures/WQueen.svg | 15 ++ ChessTextures/WQueen.svg.import | 37 +++ ChessTextures/WRook.svg | 25 ++ ChessTextures/WRook.svg.import | 37 +++ board.tscn | 82 +++++++ game.gd | 381 +++++++++++++++++++++++++++++++ game_win.gd | 4 + generator.gd | 87 +++++++ project.godot | 25 ++ 43 files changed, 1413 insertions(+) create mode 100644 Chess.png create mode 100644 Chess.png.import create mode 100644 ChessScenes/bishop.tscn create mode 100644 ChessScenes/king.tscn create mode 100644 ChessScenes/knight.tscn create mode 100644 ChessScenes/pawn.tscn create mode 100644 ChessScenes/queen.tscn create mode 100644 ChessScenes/rook.tscn create mode 100644 ChessScripts/bishop.gd create mode 100644 ChessScripts/king.gd create mode 100644 ChessScripts/knight.gd create mode 100644 ChessScripts/pawn.gd create mode 100644 ChessScripts/queen.gd create mode 100644 ChessScripts/rook.gd create mode 100644 ChessTextures/BBishop.svg create mode 100644 ChessTextures/BBishop.svg.import create mode 100644 ChessTextures/BKing.svg create mode 100644 ChessTextures/BKing.svg.import create mode 100644 ChessTextures/BKnight.svg create mode 100644 ChessTextures/BKnight.svg.import create mode 100644 ChessTextures/BPawn.svg create mode 100644 ChessTextures/BPawn.svg.import create mode 100644 ChessTextures/BQueen.svg create mode 100644 ChessTextures/BQueen.svg.import create mode 100644 ChessTextures/BRook.svg create mode 100644 ChessTextures/BRook.svg.import create mode 100644 ChessTextures/WBishop.svg create mode 100644 ChessTextures/WBishop.svg.import create mode 100644 ChessTextures/WKing.svg create mode 100644 ChessTextures/WKing.svg.import create mode 100644 ChessTextures/WKnight.svg create mode 100644 ChessTextures/WKnight.svg.import create mode 100644 ChessTextures/WPawn.svg create mode 100644 ChessTextures/WPawn.svg.import create mode 100644 ChessTextures/WQueen.svg create mode 100644 ChessTextures/WQueen.svg.import create mode 100644 ChessTextures/WRook.svg create mode 100644 ChessTextures/WRook.svg.import create mode 100644 board.tscn create mode 100644 game.gd create mode 100644 game_win.gd create mode 100644 generator.gd create mode 100644 project.godot diff --git a/Chess.png b/Chess.png new file mode 100644 index 0000000000000000000000000000000000000000..d7ad79e46679a241093730e8ce89dd6a82a8dc8d GIT binary patch literal 5282 zcmXX~2|QHY`&X6*V~8n3W2vT^7iCEr5=MqbA~8ZGBZMYPBzu;OjF4^YyrwdY>}$!^ zq_OYRB*wnJ60)WEo&KNy`F!rZGv}Ur?|Gi{Jm2U0J(1Up4TJy`84d) z>39LfBRYhE!LeVC?&GPr##{NC@lLjv!59$y*kGD3ei;{9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ZDR;+=Yuo7-REP<-pHXrvwz#_HJAvUFWoUfu&66jl=v#89bK_aCg{0Y?fU>f-7Vy5SD%rn!BB6C + + + + + + + + + + + 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