From 7f52c68aa7ab3f22ab5a5889aecaaf1d24a74b0c Mon Sep 17 00:00:00 2001 From: Alan <alanjfogel@gmail.com> Date: Fri, 31 Jan 2025 17:45:05 -0600 Subject: [PATCH] Added Pawn to Queen promotion, Bool for turns, Special check for Assassin capturing pieces --- .godot/editor/editor_layout.cfg | 12 +- .godot/editor/filesystem_cache8 | 162 +++++++++--------- .godot/editor/filesystem_update4 | 6 + ...state-c2a7af834e91ff64325daddf58e45dc0.cfg | 6 +- ...lding-c2a7af834e91ff64325daddf58e45dc0.cfg | 2 +- .godot/editor/project_metadata.cfg | 6 +- .godot/editor/script_editor_cache.cfg | 26 ++- .godot/global_script_class_cache.cfg | 6 + .godot/uid_cache.bin | Bin 3145 -> 3232 bytes Assets/temp_assets/assassin.png | Bin 0 -> 311 bytes Assets/temp_assets/assassin.png.import | 34 ++++ scenes/Assassin.tscn | 10 ++ scenes/game.tscn | 6 + scripts/Assassin.gd | 58 +++++++ scripts/Pawn.gd | 15 ++ scripts/game.gd | 82 +++++++-- 16 files changed, 315 insertions(+), 116 deletions(-) create mode 100644 Assets/temp_assets/assassin.png create mode 100644 Assets/temp_assets/assassin.png.import create mode 100644 scenes/Assassin.tscn create mode 100644 scripts/Assassin.gd diff --git a/.godot/editor/editor_layout.cfg b/.godot/editor/editor_layout.cfg index ed7016a..d618a04 100644 --- a/.godot/editor/editor_layout.cfg +++ b/.godot/editor/editor_layout.cfg @@ -25,17 +25,17 @@ dock_5="Inspector,Node,History" [EditorNode] -open_scenes=PackedStringArray("res://scenes/game.tscn", "res://scenes/explosion.tscn", "res://scenes/Pawn.tscn", "res://scenes/Rook.tscn", "res://scenes/Bishop.tscn", "res://scenes/Queen.tscn", "res://scenes/King.tscn", "res://scenes/Knight.tscn") +open_scenes=PackedStringArray("res://scenes/game.tscn", "res://scenes/explosion.tscn", "res://scenes/Pawn.tscn", "res://scenes/Rook.tscn", "res://scenes/Bishop.tscn", "res://scenes/Queen.tscn", "res://scenes/King.tscn", "res://scenes/Knight.tscn", "res://scenes/Assassin.tscn") current_scene="res://scenes/Pawn.tscn" -center_split_offset=-313 +center_split_offset=-343 selected_default_debugger_tab_idx=0 -selected_main_editor_idx=0 -selected_bottom_panel_item=0 +selected_main_editor_idx=2 +selected_bottom_panel_item=1 [ScriptEditor] -open_scripts=["res://scripts/Bishop.gd", "res://scripts/game.gd", "res://scripts/King.gd", "res://scripts/Knight.gd", "res://scripts/Pawn.gd", "res://scripts/Piece.gd", "res://scripts/Queen.gd", "res://scripts/Rook.gd"] -selected_script="res://scripts/King.gd" +open_scripts=["res://scripts/Assassin.gd", "res://scripts/Bishop.gd", "res://scripts/game.gd", "res://scripts/King.gd", "res://scripts/Knight.gd", "res://scripts/Pawn.gd", "res://scripts/Piece.gd", "res://scripts/Queen.gd", "res://scripts/Rook.gd"] +selected_script="res://scripts/Pawn.gd" open_help=[] script_split_offset=70 list_split_offset=0 diff --git a/.godot/editor/filesystem_cache8 b/.godot/editor/filesystem_cache8 index 40c2b50..ecfb357 100644 --- a/.godot/editor/filesystem_cache8 +++ b/.godot/editor/filesystem_cache8 @@ -1,83 +1,85 @@ ea4bc82a6ad023ab7ee23ee620429895 -::res://::1738358084 -game.tscn::PackedScene::5692118487183161714::1738337608::0::1::::<><>::uid://cfao716v0t1jw::::res://scenes/board.tscn +::res://::1738360214 +game.tscn::PackedScene::5692118487183161714::1738358720::0::1::::<><>::uid://cfao716v0t1jw::::res://scenes/board.tscn icon.svg::CompressedTexture2D::6378281210119878262::1737912187::1738338716::1::::<><>:: README.md::TextFile::-1::1737912187::0::1::::<><>:: -::res://assets/::1738337658 -::res://assets/noise/::1738340898 -noise2.tres::NoiseTexture2D::5054739835828921764::1738340898::0::1::::<><>:: -noise3.tres::NoiseTexture2D::906885015046579772::1738340898::0::1::::<><>:: -noise.tres::NoiseTexture2D::1693764769519573005::1738340898::0::1::::<><>:: -::res://assets/Original size Chess pieces/::1738338716 -Black king piece 2.png::CompressedTexture2D::7820367427145083060::1738337658::1738338716::1::::<><>:: -Black knight piece.png::CompressedTexture2D::4196515762256027844::1738337658::1738338716::1::::<><>:: -Black Pawn Piece 2.png::CompressedTexture2D::2167440687080906934::1738337658::1738338716::1::::<><>:: -Black Queen Piece 2.png::CompressedTexture2D::6638986330393441989::1738337658::1738338716::1::::<><>:: -Black rook piece.png::CompressedTexture2D::1872655759582013005::1738337658::1738338716::1::::<><>:: -White king piece 2.png::CompressedTexture2D::7139286146806283259::1738337658::1738338716::1::::<><>:: -White knight piece.png::CompressedTexture2D::8293368904171920332::1738337658::1738338716::1::::<><>:: -White Pawn Piece 2.png::CompressedTexture2D::8915038826611091975::1738337658::1738338716::1::::<><>:: -White Queen Piece 2.png::CompressedTexture2D::339041922548181320::1738337658::1738338716::1::::<><>:: -White rook piece.png::CompressedTexture2D::6272641373813891014::1738337658::1738338716::1::::<><>:: -::res://assets/Resized Chess Piece Assets/::1738358077 -Black_king.png::CompressedTexture2D::3691390456247856410::1738337658::1738338716::1::::<><>:: -Black_knight.png::CompressedTexture2D::3569790831830215405::1738337658::1738338716::1::::<><>:: -Black_Pawn.png::CompressedTexture2D::4947090234957464596::1738337658::1738338716::1::::<><>:: -Black_Queen.png::CompressedTexture2D::9042903626319350434::1738337658::1738338716::1::::<><>:: -Black_rook.png::CompressedTexture2D::5637903285567075872::1738337658::1738338716::1::::<><>:: -White_king.png::CompressedTexture2D::5012688985517926395::1738358013::1738358077::1::::<><>:: -White_knight.png::CompressedTexture2D::854350289879594279::1738337658::1738338716::1::::<><>:: -White_Pawn.png::CompressedTexture2D::919180529085242722::1738337658::1738338716::1::::<><>:: -White_Queen.png::CompressedTexture2D::4902137832695542513::1738337658::1738338716::1::::<><>:: -White_rook.png::CompressedTexture2D::4194129281780453908::1738337658::1738338716::1::::<><>:: -::res://assets/shaders/::1738358080 -bg.gdshader::Shader::-1::1738358080::0::1::::<><>:: -color.gdshader::Shader::-1::1738358080::0::1::::<><>:: -shadow.gdshader::Shader::-1::1738358080::0::1::::<><>:: -::res://assets/sprites/::1738338716 -bishop.png::CompressedTexture2D::4631301773944929250::1738337658::1738338716::1::::<><>:: -knight.png::CompressedTexture2D::3545640967717948854::1738337658::1738338716::1::::<><>:: -pawn.png::CompressedTexture2D::1338760335342038528::1738337658::1738338716::1::::<><>:: -rook.png::CompressedTexture2D::6790909281007670776::1738337658::1738338715::1::::<><>:: -tile.png::CompressedTexture2D::8704336058451696509::1738337658::1738338715::1::::<><>:: -::res://assets/temp_assets/::1738338716 -black_bishop.png::CompressedTexture2D::7509881182472568151::1738103868::1738338715::1::::<><>:: -black_king.png::CompressedTexture2D::3646032776351028361::1738103868::1738338715::1::::<><>:: -black_knight.png::CompressedTexture2D::4591257172048987833::1738103868::1738338715::1::::<><>:: -black_pawn.png::CompressedTexture2D::3912668014183198267::1738103868::1738338715::1::::<><>:: -black_queen.png::CompressedTexture2D::7989886812523566234::1738103868::1738338715::1::::<><>:: -black_rook.png::CompressedTexture2D::8767708966549765967::1738103868::1738338715::1::::<><>:: -Piece_move.png::CompressedTexture2D::260618725614842917::1738103868::1738338715::1::::<><>:: -temp_chess_board.png::CompressedTexture2D::4173558678901569366::1738337608::1738338715::1::::<><>:: -turn-black.png::CompressedTexture2D::7112033964315790810::1738103868::1738338715::1::::<><>:: -turn-white.png::CompressedTexture2D::7344907768700758025::1738103868::1738338715::1::::<><>:: -white_bishop.png::CompressedTexture2D::8093744356261485644::1738103868::1738338715::1::::<><>:: -white_king.png::CompressedTexture2D::5901183203660598461::1738103868::1738338716::1::::<><>:: -white_knight.png::CompressedTexture2D::7533630084821562912::1738103868::1738338716::1::::<><>:: -white_pawn.png::CompressedTexture2D::8196778834906249875::1738103868::1738338716::1::::<><>:: -white_queen.png::CompressedTexture2D::1957958042777204643::1738103868::1738338716::1::::<><>:: -white_rook.png::CompressedTexture2D::3317152307554436932::1738103868::1738338716::1::::<><>:: -::res://assets/ui/::1738338716 -Go_Save_The_King_Menu.jpg::CompressedTexture2D::7252735845995868232::1738337658::1738338716::1::::<><>:: -Mockup Gameplay Design.jpg::CompressedTexture2D::4859609684236806088::1738337658::1738338716::1::::<><>:: -Mockup Shop Design.jpg::CompressedTexture2D::8043055154093708922::1738337658::1738338716::1::::<><>:: -::res://scenes/::1738356720 -Bishop.tscn::PackedScene::2789588702038144760::1738356720::0::1::::<><>::res://scripts/Bishop.gd<>uid://b68o4mj7wcwvq::::res://assets/sprites/bishop.png -board.tscn::PackedScene::5124694183364421304::1738103868::0::1::::<><>::uid://b0px5wlrm0mb3::::res://assets/temp_assets/temp_chess_board.png<>res://scripts/board.gd -explosion.tscn::PackedScene::69466253159940830::1738356720::0::1::::<><>:: -game.tscn::PackedScene::8577524005707705072::1738356720::0::1::::<><>::res://scripts/game.gd<>res://assets/shaders/bg.gdshader<>uid://yeqb8ndri7xp::::res://assets/noise/noise.tres<>uid://ceas3dsjeq4ge::::res://assets/noise/noise2.tres<>uid://m6ki73qfbp2s::::res://assets/noise/noise3.tres -King.tscn::PackedScene::8277830396459966414::1738356720::0::1::::<><>::res://scripts/King.gd<>uid://cdogixbq8ay3t::::res://assets/Resized Chess Piece Assets/White_king.png -Knight.tscn::PackedScene::5270730075267457303::1738356720::0::1::::<><>::res://scripts/Knight.gd<>uid://mf4a3jclbwih::::res://assets/Resized Chess Piece Assets/White_knight.png -Pawn.tscn::PackedScene::3675784333675896641::1738356720::0::1::::<><>::res://scripts/Pawn.gd<>uid://ndi1e8thkonq::::res://assets/Resized Chess Piece Assets/White_Pawn.png -Queen.tscn::PackedScene::7495869360053814603::1738356720::0::1::::<><>::res://scripts/Queen.gd<>uid://cb3vq168iyomb::::res://assets/Resized Chess Piece Assets/White_Queen.png -Rook.tscn::PackedScene::9162401199636684468::1738356720::0::1::::<><>::uid://b00wxxfjk04ke::::res://assets/Resized Chess Piece Assets/White_rook.png -texture_holder.tscn::PackedScene::594714386286134588::1738103868::0::1::::<><>:: -::res://scripts/::1738356268 -Bishop.gd::GDScript::-1::1738352962::0::1::::Bishop<>Piece<>:: -game.gd::GDScript::-1::1738356456::0::1::::game<>Node<>:: -King.gd::GDScript::-1::1738353811::0::1::::King<>Piece<>:: -Knight.gd::GDScript::-1::1738356268::0::1::::Knight<>Piece<>:: -Pawn.gd::GDScript::-1::1738356769::0::1::::Pawn<>Piece<>:: -Piece.gd::GDScript::-1::1738355601::0::1::::Piece<>Node2D<>:: -Queen.gd::GDScript::-1::1738353504::0::1::::Queen<>Piece<>:: -Rook.gd::GDScript::-1::1738352122::0::1::::Rook<>Piece<>:: +::res://assets/::1738358720 +::res://assets/noise/::1738360218 +noise2.tres::NoiseTexture2D::5054739835828921764::1738360218::0::1::::<><>:: +noise3.tres::NoiseTexture2D::906885015046579772::1738360218::0::1::::<><>:: +noise.tres::NoiseTexture2D::1693764769519573005::1738360218::0::1::::<><>:: +::res://assets/Original size Chess pieces/::1738360196 +Black king piece 2.png::CompressedTexture2D::7820367427145083060::1738358720::1738360196::1::::<><>:: +Black knight piece.png::CompressedTexture2D::4196515762256027844::1738358720::1738360196::1::::<><>:: +Black Pawn Piece 2.png::CompressedTexture2D::2167440687080906934::1738358720::1738360196::1::::<><>:: +Black Queen Piece 2.png::CompressedTexture2D::6638986330393441989::1738358720::1738360196::1::::<><>:: +Black rook piece.png::CompressedTexture2D::1872655759582013005::1738358720::1738360196::1::::<><>:: +White king piece 2.png::CompressedTexture2D::7139286146806283259::1738358720::1738360196::1::::<><>:: +White knight piece.png::CompressedTexture2D::8293368904171920332::1738358720::1738360196::1::::<><>:: +White Pawn Piece 2.png::CompressedTexture2D::8915038826611091975::1738358720::1738360196::1::::<><>:: +White Queen Piece 2.png::CompressedTexture2D::339041922548181320::1738358720::1738360196::1::::<><>:: +White rook piece.png::CompressedTexture2D::6272641373813891014::1738358720::1738360196::1::::<><>:: +::res://assets/Resized Chess Piece Assets/::1738360196 +Black_king.png::CompressedTexture2D::3691390456247856410::1738358720::1738360196::1::::<><>:: +Black_knight.png::CompressedTexture2D::3569790831830215405::1738358720::1738360196::1::::<><>:: +Black_Pawn.png::CompressedTexture2D::4947090234957464596::1738358720::1738360196::1::::<><>:: +Black_Queen.png::CompressedTexture2D::9042903626319350434::1738358720::1738360196::1::::<><>:: +Black_rook.png::CompressedTexture2D::5637903285567075872::1738358720::1738360196::1::::<><>:: +White_king.png::CompressedTexture2D::5012688985517926395::1738358720::1738360196::1::::<><>:: +White_knight.png::CompressedTexture2D::854350289879594279::1738358720::1738360196::1::::<><>:: +White_Pawn.png::CompressedTexture2D::919180529085242722::1738358720::1738360196::1::::<><>:: +White_Queen.png::CompressedTexture2D::4902137832695542513::1738358720::1738360196::1::::<><>:: +White_rook.png::CompressedTexture2D::4194129281780453908::1738358720::1738360196::1::::<><>:: +::res://assets/shaders/::1738360772 +bg.gdshader::Shader::-1::1738360772::0::1::::<><>:: +color.gdshader::Shader::-1::1738360772::0::1::::<><>:: +shadow.gdshader::Shader::-1::1738360772::0::1::::<><>:: +::res://assets/sprites/::1738360196 +bishop.png::CompressedTexture2D::4631301773944929250::1738358798::1738360196::1::::<><>:: +knight.png::CompressedTexture2D::3545640967717948854::1738358798::1738360196::1::::<><>:: +pawn.png::CompressedTexture2D::1338760335342038528::1738358798::1738360195::1::::<><>:: +rook.png::CompressedTexture2D::6790909281007670776::1738358798::1738360195::1::::<><>:: +tile.png::CompressedTexture2D::8704336058451696509::1738358570::1738360195::1::::<><>:: +::res://assets/temp_assets/::1738360998 +assassin.png::CompressedTexture2D::2309680507621369322::1738360966::1738361001::1::::<><>:: +black_bishop.png::CompressedTexture2D::7509881182472568151::1738358720::1738360195::1::::<><>:: +black_king.png::CompressedTexture2D::3646032776351028361::1738358720::1738360195::1::::<><>:: +black_knight.png::CompressedTexture2D::4591257172048987833::1738358720::1738360195::1::::<><>:: +black_pawn.png::CompressedTexture2D::3912668014183198267::1738358720::1738360195::1::::<><>:: +black_queen.png::CompressedTexture2D::7989886812523566234::1738358720::1738360195::1::::<><>:: +black_rook.png::CompressedTexture2D::8767708966549765967::1738358720::1738360195::1::::<><>:: +Piece_move.png::CompressedTexture2D::260618725614842917::1738358720::1738360195::1::::<><>:: +temp_chess_board.png::CompressedTexture2D::4173558678901569366::1738358720::1738360195::1::::<><>:: +turn-black.png::CompressedTexture2D::7112033964315790810::1738358720::1738360195::1::::<><>:: +turn-white.png::CompressedTexture2D::7344907768700758025::1738358720::1738360196::1::::<><>:: +white_bishop.png::CompressedTexture2D::8093744356261485644::1738358720::1738360196::1::::<><>:: +white_king.png::CompressedTexture2D::5901183203660598461::1738358720::1738360196::1::::<><>:: +white_knight.png::CompressedTexture2D::7533630084821562912::1738358720::1738360196::1::::<><>:: +white_pawn.png::CompressedTexture2D::8196778834906249875::1738358720::1738360196::1::::<><>:: +white_queen.png::CompressedTexture2D::1957958042777204643::1738358720::1738360196::1::::<><>:: +white_rook.png::CompressedTexture2D::3317152307554436932::1738358720::1738360196::1::::<><>:: +::res://assets/ui/::1738360196 +Go_Save_The_King_Menu.jpg::CompressedTexture2D::7252735845995868232::1738358720::1738360196::1::::<><>:: +Mockup Gameplay Design.jpg::CompressedTexture2D::4859609684236806088::1738358720::1738360196::1::::<><>:: +Mockup Shop Design.jpg::CompressedTexture2D::8043055154093708922::1738358720::1738360196::1::::<><>:: +::res://scenes/::1738360772 +Bishop.tscn::PackedScene::2789588702038144760::1738360361::0::1::::<><>::res://scripts/Bishop.gd<>uid://b68o4mj7wcwvq::::res://assets/sprites/bishop.png +board.tscn::PackedScene::5124694183364421304::1738358720::0::1::::<><>::uid://b0px5wlrm0mb3::::res://assets/temp_assets/temp_chess_board.png<>res://scripts/board.gd +explosion.tscn::PackedScene::69466253159940830::1738360361::0::1::::<><>:: +game.tscn::PackedScene::8577524005707705072::1738360772::0::1::::<><>::res://scripts/game.gd<>res://assets/shaders/bg.gdshader<>uid://yeqb8ndri7xp::::res://assets/noise/noise.tres<>uid://ceas3dsjeq4ge::::res://assets/noise/noise2.tres<>uid://m6ki73qfbp2s::::res://assets/noise/noise3.tres +King.tscn::PackedScene::8277830396459966414::1738360361::0::1::::<><>::res://scripts/King.gd<>uid://cdogixbq8ay3t::::res://assets/Resized Chess Piece Assets/White_king.png +Knight.tscn::PackedScene::5270730075267457303::1738360361::0::1::::<><>::res://scripts/Knight.gd<>uid://mf4a3jclbwih::::res://assets/Resized Chess Piece Assets/White_knight.png +Pawn.tscn::PackedScene::3675784333675896641::1738360361::0::1::::<><>::res://scripts/Pawn.gd<>uid://ndi1e8thkonq::::res://assets/Resized Chess Piece Assets/White_Pawn.png +Queen.tscn::PackedScene::7495869360053814603::1738360361::0::1::::<><>::res://scripts/Queen.gd<>uid://cb3vq168iyomb::::res://assets/Resized Chess Piece Assets/White_Queen.png +Rook.tscn::PackedScene::9162401199636684468::1738360361::0::1::::<><>::uid://b00wxxfjk04ke::::res://assets/Resized Chess Piece Assets/White_rook.png +texture_holder.tscn::PackedScene::594714386286134588::1738358720::0::1::::<><>:: +::res://scripts/::1738360772 +Bishop.gd::GDScript::-1::1738358720::0::1::::Bishop<>Piece<>:: +game.gd::GDScript::-1::1738360892::0::1::::game<>Node<>:: +King.gd::GDScript::-1::1738358720::0::1::::King<>Piece<>:: +Knight.gd::GDScript::-1::1738358802::0::1::::Knight<>Piece<>:: +Pawn.gd::GDScript::-1::1738358802::0::1::::Pawn<>Piece<>:: +Piece.gd::GDScript::-1::1738358720::0::1::::Piece<>Node2D<>:: +Queen.gd::GDScript::-1::1738358720::0::1::::Queen<>Piece<>:: +Assassin.gd::GDScript::-1::1738360861::0::1::::Assassin<>Piece<>:: +Rook.gd::GDScript::-1::1738358720::0::1::::Rook<>Piece<>:: diff --git a/.godot/editor/filesystem_update4 b/.godot/editor/filesystem_update4 index 145afe9..1dd8b09 100644 --- a/.godot/editor/filesystem_update4 +++ b/.godot/editor/filesystem_update4 @@ -12,3 +12,9 @@ res://scenes/Bishop.tscn res://scenes/Queen.tscn res://scenes/King.tscn res://scenes/Knight.tscn +res://scripts/Rook.gd +res://scripts/Bishop.gd +res://scripts/Assassin.gd +res://scripts/game.gd +res://scenes/Assassin.tscn +res://scripts/Pawn.gd diff --git a/.godot/editor/game.tscn-editstate-c2a7af834e91ff64325daddf58e45dc0.cfg b/.godot/editor/game.tscn-editstate-c2a7af834e91ff64325daddf58e45dc0.cfg index beea376..2309a88 100644 --- a/.godot/editor/game.tscn-editstate-c2a7af834e91ff64325daddf58e45dc0.cfg +++ b/.godot/editor/game.tscn-editstate-c2a7af834e91ff64325daddf58e45dc0.cfg @@ -8,7 +8,7 @@ Anim={ "grid_snap_active": false, "grid_step": Vector2(8, 8), "grid_visibility": 1, -"ofs": Vector2(-1180.52, -464.792), +"ofs": Vector2(-1092.7, -448.319), "primary_grid_step": Vector2i(8, 8), "show_group_gizmos": true, "show_guides": true, @@ -34,7 +34,7 @@ Anim={ "snap_rotation_step": 0.261799, "snap_scale": false, "snap_scale_step": 0.1, -"zoom": 0.529732 +"zoom": 0.471937 } 3D={ "fov": 70.01, @@ -175,4 +175,4 @@ Anim={ "zfar": 4000.01, "znear": 0.05 } -selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@16886/@Panel@13/@VBoxContainer@14/DockHSplitLeftL/DockHSplitLeftR/DockHSplitMain/@VBoxContainer@25/DockVSplitCenter/@VSplitContainer@52/@VBoxContainer@53/@PanelContainer@98/MainScreen/@CanvasItemEditor@9272/@VSplitContainer@9094/@HSplitContainer@9096/@HSplitContainer@9098/@Control@9099/@SubViewportContainer@9100/@SubViewport@9101/Node2D")]) +selected_nodes=Array[NodePath]([]) diff --git a/.godot/editor/game.tscn-folding-c2a7af834e91ff64325daddf58e45dc0.cfg b/.godot/editor/game.tscn-folding-c2a7af834e91ff64325daddf58e45dc0.cfg index 892d185..07cfab6 100644 --- a/.godot/editor/game.tscn-folding-c2a7af834e91ff64325daddf58e45dc0.cfg +++ b/.godot/editor/game.tscn-folding-c2a7af834e91ff64325daddf58e45dc0.cfg @@ -1,5 +1,5 @@ [folding] -node_unfolds=[NodePath("."), PackedStringArray("opponent_shader", "Editor Description"), NodePath("ShadowContainer"), PackedStringArray("Ordering"), NodePath("TileContainer"), PackedStringArray("Transform", "Ordering"), NodePath("PieceContainer"), PackedStringArray("Ordering", "Process", "Texture"), NodePath("Background"), PackedStringArray("Layout", "material", "Ordering", "Layout/Transform", "Layout/Grow Direction", "Layout/Container Sizing", "Layout/Anchor Points", "Layout/Anchor Offsets", "Texture"), NodePath("Explosion"), PackedStringArray("Ordering", "Transform", "Scale", "Time")] +node_unfolds=[NodePath("."), PackedStringArray("opponent_shader", "Editor Description"), NodePath("ShadowContainer"), PackedStringArray("Ordering"), NodePath("TileContainer"), PackedStringArray("Transform", "Ordering"), NodePath("PieceContainer"), PackedStringArray("Ordering", "Process", "Texture"), NodePath("Background"), PackedStringArray("Layout", "material", "Ordering", "Layout/Transform", "Layout/Grow Direction", "Layout/Container Sizing", "Layout/Anchor Points", "Layout/Anchor Offsets", "Texture"), NodePath("Explosion"), PackedStringArray("Ordering", "Transform", "Scale", "Time"), NodePath("PlayerPieces"), PackedStringArray("Transform"), NodePath("OpponentPieces"), PackedStringArray("Visibility", "Transform")] resource_unfolds=["res://scenes/game.tscn::ShaderMaterial_gdbwp", PackedStringArray("Shader Parameters", "Resource")] nodes_folded=[] diff --git a/.godot/editor/project_metadata.cfg b/.godot/editor/project_metadata.cfg index 234bcac..0d8854a 100644 --- a/.godot/editor/project_metadata.cfg +++ b/.godot/editor/project_metadata.cfg @@ -4,7 +4,7 @@ executable_path="c:/Users/Alan/Downloads/Godot_v4.3-stable_win64.exe/Godot_v4.3- [dialog_bounds] -create_new_node=Rect2(510, 190, 900, 700) +create_new_node=Rect2(2371, 126, 900, 700) project_settings=Rect2(360, 190, 1200, 700) [script_setup] @@ -13,8 +13,8 @@ last_selected_language="GDScript" [recent_files] -scripts=["res://scripts/Knight.gd", "res://scripts/King.gd", "res://scripts/Queen.gd", "res://scripts/Bishop.gd", "res://scripts/Rook.gd", "res://scripts/Pawn.gd", "res://scripts/Piece.gd", "@GDScript", "int", "res://background.gd"] -scenes=["res://scenes/Knight.tscn", "res://scenes/King.tscn", "res://scenes/Queen.tscn", "res://scenes/Bishop.tscn", "res://scenes/Rook.tscn", "res://scenes/Pawn.tscn", "res://scenes/explosion.tscn", "res://scenes/game.tscn", "res://scenes/chess_board.tscn", "res://chess_board.tscn"] +scripts=["res://scripts/Assassin.gd", "res://scripts/Knight.gd", "res://scripts/King.gd", "res://scripts/Queen.gd", "res://scripts/Bishop.gd", "res://scripts/Rook.gd", "res://scripts/Pawn.gd", "res://scripts/Piece.gd", "@GDScript", "int"] +scenes=["res://scenes/Assassin.tscn", "res://scenes/Knight.tscn", "res://scenes/King.tscn", "res://scenes/Queen.tscn", "res://scenes/Bishop.tscn", "res://scenes/Rook.tscn", "res://scenes/Pawn.tscn", "res://scenes/explosion.tscn", "res://scenes/game.tscn", "res://scenes/chess_board.tscn"] [color_picker] diff --git a/.godot/editor/script_editor_cache.cfg b/.godot/editor/script_editor_cache.cfg index fc83f20..95fc328 100644 --- a/.godot/editor/script_editor_cache.cfg +++ b/.godot/editor/script_editor_cache.cfg @@ -3,11 +3,11 @@ state={ "bookmarks": PackedInt32Array(), "breakpoints": PackedInt32Array(), -"column": 20, +"column": 53, "folded_lines": Array[int]([]), "h_scroll_position": 0, -"row": 121, -"scroll_position": 111.0, +"row": 294, +"scroll_position": 284.0, "selection": false, "syntax_highlighter": "GDScript" } @@ -31,11 +31,11 @@ state={ state={ "bookmarks": PackedInt32Array(), "breakpoints": PackedInt32Array(), -"column": 0, +"column": 13, "folded_lines": Array[int]([]), "h_scroll_position": 0, -"row": 17, -"scroll_position": 0.0, +"row": 89, +"scroll_position": 70.0, "selection": false, "syntax_highlighter": "GDScript" } @@ -109,3 +109,17 @@ state={ "selection": false, "syntax_highlighter": "GDScript" } + +[res://scripts/Assassin.gd] + +state={ +"bookmarks": PackedInt32Array(), +"breakpoints": PackedInt32Array(), +"column": 0, +"folded_lines": Array[int]([]), +"h_scroll_position": 0, +"row": 49, +"scroll_position": 26.0, +"selection": false, +"syntax_highlighter": "GDScript" +} diff --git a/.godot/global_script_class_cache.cfg b/.godot/global_script_class_cache.cfg index 8a3d533..b12ce8f 100644 --- a/.godot/global_script_class_cache.cfg +++ b/.godot/global_script_class_cache.cfg @@ -1,5 +1,11 @@ list=Array[Dictionary]([{ "base": &"Piece", +"class": &"Assassin", +"icon": "", +"language": &"GDScript", +"path": "res://scripts/Assassin.gd" +}, { +"base": &"Piece", "class": &"Bishop", "icon": "", "language": &"GDScript", diff --git a/.godot/uid_cache.bin b/.godot/uid_cache.bin index 1159a1950906399ec3f6bdebdd47a1113b0cfd5c..6e170e6b50b7f284327ca43d87a9f1cb4100c68a 100644 GIT binary patch delta 75 zcmX>pu|Sg1b|a$)59h1YEKB`Gyb7w59XVu-5{rw0C^Jv5ATM3|#T(NIace;-1_p+r X)M6`r{o>@*ywqZSN0_3L;^aI4jC&Zh delta 10 RcmZ1=c~XMWdLyF;4*(LY0^I-r diff --git a/Assets/temp_assets/assassin.png b/Assets/temp_assets/assassin.png new file mode 100644 index 0000000000000000000000000000000000000000..3423cee0877ee9bae0d5426aef0ee9d8328caa14 GIT binary patch literal 311 zcmV-70m%M|P)<h;3K|Lk000e1NJLTq001BW001Be1^@s6b9#F800001b5ch_0Itp) z=>Px#@kvBMR9J=WmC+4@FbqVGsuLo0h{6u7=nf4#P=yU5Mst5^6(Uk%CsBpOeS+e9 zJ~<9>=+K@;AEnf&Qp^{Hs!CN$btu%e2I7=r{u)O#ZMzAU4Zt^Nr9g-i@XgmCiUO>e zr$DF@$SE<vrLKej%=1|mfa70-U~}y(L~F2?Lb^7M_!_Df(O~VuXmSn!&>JJJCqA%s z&!yXNe+jU1Jw|7(`FtTw&Vh(X3n9{9Zvn^duVbD8-UUUHAR_wJ{X7N9ix^EB>K^ze z02E9irh9J|x|q5W%5Jds=6{@b&+3hN0J!G{03y4JH9vF+0N(R?3L;tIY6k!S002ov JPDHLkV1jS`eN_Me literal 0 HcmV?d00001 diff --git a/Assets/temp_assets/assassin.png.import b/Assets/temp_assets/assassin.png.import new file mode 100644 index 0000000..2153ed5 --- /dev/null +++ b/Assets/temp_assets/assassin.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://753dogr1moxe" +path="res://.godot/imported/assassin.png-7bbbc406e2629bde9613c01b865eff89.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/temp_assets/assassin.png" +dest_files=["res://.godot/imported/assassin.png-7bbbc406e2629bde9613c01b865eff89.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/scenes/Assassin.tscn b/scenes/Assassin.tscn new file mode 100644 index 0000000..078f6c5 --- /dev/null +++ b/scenes/Assassin.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=3 format=3 uid="uid://rxpfuqov0sdv"] + +[ext_resource type="Script" path="res://scripts/Assassin.gd" id="1_g33mq"] +[ext_resource type="Texture2D" uid="uid://753dogr1moxe" path="res://assets/temp_assets/assassin.png" id="2_wrp2r"] + +[node name="Node2D" type="Node2D"] +script = ExtResource("1_g33mq") + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("2_wrp2r") diff --git a/scenes/game.tscn b/scenes/game.tscn index 50acfb4..e590e42 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -59,3 +59,9 @@ radial_accel_max = 70.25 scale_amount_min = 2.0 scale_amount_max = 3.0 color = Color(0, 0, 0, 1) + +[node name="PlayerPieces" type="Node2D" parent="."] +position = Vector2(100, 400) + +[node name="OpponentPieces" type="Node2D" parent="."] +position = Vector2(100, 100) diff --git a/scripts/Assassin.gd b/scripts/Assassin.gd new file mode 100644 index 0000000..4217b3f --- /dev/null +++ b/scripts/Assassin.gd @@ -0,0 +1,58 @@ +extends Piece + +class_name Assassin + +enum Upgrade { + # Add any specific upgrades for Assassin here +} + +var board_state: Array + +func _init(is_white: bool, position: Vector2): + super._init(is_white, position) + +# Capturing is handled in main game.gd +func get_valid_moves(board_state: Array, pos: Vector2) -> Array[Vector2]: + var valid_moves: Array[Vector2] = [] + var sel_x = pos.x + var sel_y = pos.y + + # Add moves based on the provided logic + for x in range(board_state.size()): + for y in range(board_state.size()): + if int((x + y)) % 2 == int((sel_x + sel_y)) % 2 and is_empty(board_state, x, y): + valid_moves.append(Vector2(x, y)) + + if is_opponent(board_state, sel_x, sel_y): + if sel_y - 1 >= 0: + if is_opposite(board_state, sel_x, sel_y - 1): + valid_moves.append(Vector2(sel_x, sel_y - 1)) + if sel_x + 1 < board_state.size(): + if is_opposite(board_state, sel_x + 1, sel_y - 1): + valid_moves.append(Vector2(sel_x + 1, sel_y - 1)) + if sel_x - 1 >= 0: + if is_opposite(board_state, sel_x - 1, sel_y - 1): + valid_moves.append(Vector2(sel_x - 1, sel_y - 1)) + else: + if sel_y + 1 < board_state.size(): + if is_opposite(board_state, sel_x, sel_y + 1): + valid_moves.append(Vector2(sel_x, sel_y + 1)) + if sel_x + 1 < board_state.size(): + if is_opposite(board_state, sel_x + 1, sel_y + 1): + valid_moves.append(Vector2(sel_x + 1, sel_y + 1)) + if sel_x - 1 >= 0: + if is_opposite(board_state, sel_x - 1, sel_y + 1): + valid_moves.append(Vector2(sel_x - 1, sel_y + 1)) + + return valid_moves + + + +func is_empty(board_state: Array, x: int, y: int) -> bool: + return board_state[x][y] == null + +func is_opponent(board_state: Array, x: int, y: int) -> bool: + return board_state[x][y] != null and board_state[x][y].is_white != is_white + +func is_opposite(board_state: Array, x: int, y: int) -> bool: + return board_state[x][y] != null and board_state[x][y].is_white == is_white diff --git a/scripts/Pawn.gd b/scripts/Pawn.gd index 7d8a053..3b1346f 100644 --- a/scripts/Pawn.gd +++ b/scripts/Pawn.gd @@ -2,8 +2,13 @@ extends Piece class_name Pawn +var Game = preload("res://scripts/game.gd") + enum Upgrade { DOUBLE_MOVE, DIAGONAL_MOVE } +var tile_size = 64 # Make this global?... +@onready var opponent_shader = load("res://shaders/BlackShader.shader") + func _init(is_white: bool, position: Vector2): super._init(is_white, position) # Testing upgrades @@ -40,6 +45,12 @@ func get_valid_moves(board_state: Array, pos: Vector2) -> Array[Vector2]: if x < 7 and y > 0 and board_state[x + 1][y - 1] == null: valid_moves.append(Vector2(x + 1, y - 1)) + # Check for promotion + if y == 0: + board_state[x][y] = Queen.new(is_white, Vector2(x, y)) + + + else: if y < 1 and board_state[x][y + 1] == null: valid_moves.append(Vector2(x, y + 1)) @@ -53,4 +64,8 @@ func get_valid_moves(board_state: Array, pos: Vector2) -> Array[Vector2]: if x < 7 and y < 7 and board_state[x + 1][y + 1] != null and board_state[x + 1][y + 1].is_white: valid_moves.append(Vector2(x + 1, y + 1)) + # Check for promotion + # if y == 7: + # board_state[x][y] = Queen.new(is_white, Vector2(x, y)) + return valid_moves diff --git a/scripts/game.gd b/scripts/game.gd index 06aa3a7..a8f0912 100644 --- a/scripts/game.gd +++ b/scripts/game.gd @@ -18,6 +18,10 @@ class_name game @onready var piece_container = $PieceContainer @onready var board = [] +@onready var player_pieces = $PlayerPieces +@onready var player_piece_count = 0 +@onready var opponent_pieces = $OpponentPieces +@onready var opponent_piece_count = 0 var selected_piece var selected_piece_value @@ -29,6 +33,8 @@ var target_position var moving: bool var sprite: Sprite2D +var player_turn : bool = true + @onready var explosion_effect = $Explosion @@ -47,16 +53,16 @@ func _ready() -> void: board[1][7] = Bishop.new(true, Vector2(1, 7)) board[2][7] = King.new(true, Vector2(2, 7)) board[3][6] = Queen.new(true, Vector2(3, 6)) - board[4][7] = Pawn.new(true, Vector2(4, 7)) + board[4][2] = Pawn.new(true, Vector2(4, 7)) board[5][7] = Knight.new(true, Vector2(5, 7)) - board[6][7] = Pawn.new(true, Vector2(6, 7)) + board[6][7] = Assassin.new(true, Vector2(6, 7)) board[7][7] = Rook.new(true, Vector2(7, 7)) board[0][4] = Rook.new(false, Vector2(0, 4)) board[1][5] = Bishop.new(false, Vector2(1, 5)) board[3][2] = Queen.new(false, Vector2(3, 2)) board[3][5] = Pawn.new(false, Vector2(3, 5)) - board[4][4] = Pawn.new(false, Vector2(4, 4)) + board[4][4] = Assassin.new(false, Vector2(4, 4)) board[3][4] = Pawn.new(false, Vector2(3, 4)) board[4][3] = Pawn.new(false, Vector2(4, 3)) board[7][5] = Rook.new(false, Vector2(7, 5)) @@ -104,6 +110,13 @@ func _process(delta: float) -> void: else: moving = false unselect_piece() + if selected_piece != null: + # If the selected piece is a pawn and it reaches the end of the board, promote it to a queen + if selected_piece_position.y == 0: + if selected_piece_value is Pawn: + if selected_piece_value.is_white: + draw_pieces() + remove_piece(selected_piece_position.x, selected_piece_position.y) func draw_pieces(): @@ -125,6 +138,8 @@ func draw_pieces(): piece_scene = preload("res://scenes/King.tscn") elif board[x][y] is Knight: piece_scene = preload("res://scenes/Knight.tscn") + elif board[x][y] is Assassin: + piece_scene = preload("res://scenes/Assassin.tscn") if piece_scene: var piece_instance = piece_scene.instantiate() @@ -248,20 +263,34 @@ func _input(event): #if mouse click is a left click, proceed if event.button_index == MOUSE_BUTTON_LEFT: - #if the tile is a player's piece, select or deselect it - if !is_empty(x,y) && !(is_opponent(x,y)): - #if there is a currently selected piece that is on the selected tile, deselect that piece - if selected_piece != null: - if board[x][y] == selected_piece_value: - unselect_piece() + if player_turn: + #if the tile is a player's piece, select or deselect it + if !is_empty(x,y) && !(is_opponent(x,y)): + #if there is a currently selected piece that is on the selected tile, deselect that piece + if selected_piece != null: + if board[x][y] == selected_piece_value: + unselect_piece() + else: + select_piece(x,y) + #otherwise, select the piece else: select_piece(x,y) - #otherwise, select the piece + #if the tile is empty or an opponents piece, move the selected piece to that tile else: - select_piece(x,y) - #if the tile is empty or an opponents piece, move the selected piece to that tile + move_selected_piece(x,y) else: - move_selected_piece(x,y) + print("It's not your turn!") + if !is_empty(x,y) && is_opponent(x,y): + if selected_piece!=null: + if board[x][y] == selected_piece_value: + unselect_piece() + else: + select_piece(x,y) + else: + select_piece(x,y) + else: + move_selected_piece(x,y) + func is_opponent(x,y): @@ -274,6 +303,14 @@ func is_opponent(x,y): else: return !board[x][y].is_white +func is_opposite(x,y): + if board[x][y] == null: + return false + else: + if selected_piece != null: + return board[x][y].is_white == selected_piece_value.is_white + else: + return board[x][y].is_white func is_empty(x, y): @@ -291,6 +328,7 @@ func is_empty(x, y): func remove_piece(x,y): #iterate through the pieces in piece_container, if that piece is at location x,y, remove it + # TODO: Fix bug with promoted Queen, when capturing other pieces, they are not visually removed. for child in piece_container.get_children(): #translate x,y index values to screen coordinates if child.position == Vector2(x*tile_size + 32, y*tile_size + 32): @@ -351,16 +389,26 @@ func move_selected_piece(x,y): if Vector2(x,y) in valid_moves: #if tile has opponent piece, remove piece if is_opponent(x,y): - print("Capturing opponent piece") remove_piece(x,y) - + + # check for if assassin is moving behind the opponent's pieces + if selected_piece_value is Assassin: + if selected_piece_value.is_white: + if is_opponent(x, y + 1): + remove_piece(x, y + 1) + else: + if is_opponent(x, y - 1): + remove_piece(x, y - 1) + + #clear the selected_piece's previous position board[selected_piece_position.x][selected_piece_position.y] = null + board[x][y] = selected_piece_value + + #update selected_piece's screen coordinate position selected_piece_position = Vector2((x*tile_size)+ tile_size/2, (y*tile_size) + tile_size/2) - - board[x][y] = selected_piece_value target_position = selected_piece_position moving = true -- GitLab