New chess pieces
|  | @ -33,18 +33,18 @@ initial_board = [[ROOKB, KNIGHTB,  BISHOPB, KINGB, QUEENB, BISHOPB, KNIGHTB, ROO | ||||||
|                 [ROOKW, KNIGHTW, BISHOPW, KINGW, QUEENW, BISHOPW, KNIGHTW, ROOKW]] |                 [ROOKW, KNIGHTW, BISHOPW, KINGW, QUEENW, BISHOPW, KNIGHTW, ROOKW]] | ||||||
| 
 | 
 | ||||||
| blank = os.path.join(CHESS_PATH, 'blank.png') | blank = os.path.join(CHESS_PATH, 'blank.png') | ||||||
| bishopB = os.path.join(CHESS_PATH, 'bishopb.png') | bishopB = os.path.join(CHESS_PATH, 'nbishopb.png') | ||||||
| bishopW = os.path.join(CHESS_PATH, 'bishopw.png') | bishopW = os.path.join(CHESS_PATH, 'nbishopw.png') | ||||||
| pawnB = os.path.join(CHESS_PATH, 'pawnb.png') | pawnB = os.path.join(CHESS_PATH, 'npawnb.png') | ||||||
| pawnW = os.path.join(CHESS_PATH, 'pawnw.png') | pawnW = os.path.join(CHESS_PATH, 'npawnw.png') | ||||||
| knightB = os.path.join(CHESS_PATH, 'knightb.png') | knightB = os.path.join(CHESS_PATH, 'nknightb.png') | ||||||
| knightW = os.path.join(CHESS_PATH, 'knightw.png') | knightW = os.path.join(CHESS_PATH, 'nknightw.png') | ||||||
| rookB = os.path.join(CHESS_PATH, 'rookb.png') | rookB = os.path.join(CHESS_PATH, 'nrookb.png') | ||||||
| rookW = os.path.join(CHESS_PATH, 'rookw.png') | rookW = os.path.join(CHESS_PATH, 'nrookw.png') | ||||||
| queenB = os.path.join(CHESS_PATH, 'queenB.png') | queenB = os.path.join(CHESS_PATH, 'nqueenB.png') | ||||||
| queenW = os.path.join(CHESS_PATH, 'queenW.png') | queenW = os.path.join(CHESS_PATH, 'nqueenW.png') | ||||||
| kingB = os.path.join(CHESS_PATH, 'kingb.png') | kingB = os.path.join(CHESS_PATH, 'nkingb.png') | ||||||
| kingW = os.path.join(CHESS_PATH, 'kingw.png') | kingW = os.path.join(CHESS_PATH, 'nkingw.png') | ||||||
| 
 | 
 | ||||||
| images = {BISHOPB: bishopB, BISHOPW: bishopW, PAWNB: pawnB, PAWNW: pawnW, KNIGHTB: knightB, KNIGHTW: knightW, | images = {BISHOPB: bishopB, BISHOPW: bishopW, PAWNB: pawnB, PAWNW: pawnW, KNIGHTB: knightB, KNIGHTW: knightW, | ||||||
|           ROOKB: rookB, ROOKW: rookW, KINGB: kingB, KINGW: kingW, QUEENB: queenB, QUEENW: queenW, BLANK: blank} |           ROOKB: rookB, ROOKW: rookW, KINGB: kingB, KINGW: kingW, QUEENB: queenB, QUEENW: queenW, BLANK: blank} | ||||||
|  | @ -121,10 +121,7 @@ def PlayGame(): | ||||||
|                sg.Column(board_controls)], |                sg.Column(board_controls)], | ||||||
|               [sg.Text('Click anywhere on board for next move', font='_ 14')]] |               [sg.Text('Click anywhere on board for next move', font='_ 14')]] | ||||||
| 
 | 
 | ||||||
|     window = sg.Window('Chess', |     window = sg.Window('Chess', default_button_element_size=(12,1), auto_size_buttons=False, icon='kingb.ico').Layout(layout) | ||||||
|                        default_button_element_size=(12,1), |  | ||||||
|                        auto_size_buttons=False, |  | ||||||
|                        icon='kingb.ico').Layout(layout) |  | ||||||
| 
 | 
 | ||||||
|     # ---===--- Loop taking in user input --- # |     # ---===--- Loop taking in user input --- # | ||||||
|     i = 0 |     i = 0 | ||||||
|  | @ -147,22 +144,15 @@ def PlayGame(): | ||||||
|             window.FindElement('_movelist_').Update(value='{}   {}\n'.format(i+1, str(move)), append=True) |             window.FindElement('_movelist_').Update(value='{}   {}\n'.format(i+1, str(move)), append=True) | ||||||
|             move_from = move.from_square    # parse the move-from and move-to squares |             move_from = move.from_square    # parse the move-from and move-to squares | ||||||
|             move_to = move.to_square |             move_to = move.to_square | ||||||
|             row = move_from // 8 |             row, col = move_from // 8, move_from % 8 | ||||||
|             col = move_from % 8 |  | ||||||
|             piece = board[row][col]         # get the move-from piece |             piece = board[row][col]         # get the move-from piece | ||||||
|             button = window.FindElement(key=(row,col)) |             button = window.FindElement(key=(row,col)) | ||||||
|             button.Update(button_color = ('white', 'red')) |             for x in range(3): | ||||||
|             window.Refresh() |                 button.Update(button_color = ('white' , 'red' if x % 2 else 'white')) | ||||||
|             time.sleep(.05) |  | ||||||
|             button.Update(button_color = ('white', 'white')) |  | ||||||
|             window.Refresh() |  | ||||||
|             time.sleep(.05) |  | ||||||
|             button.Update(button_color = ('white', 'red')) |  | ||||||
|                 window.Refresh() |                 window.Refresh() | ||||||
|                 time.sleep(.05) |                 time.sleep(.05) | ||||||
|             board[row][col] = BLANK         # place blank where piece was |             board[row][col] = BLANK         # place blank where piece was | ||||||
|             row = move_to // 8              # compute move-to square |             row, col = move_to // 8, move_to % 8  # compute move-to square | ||||||
|             col = move_to % 8 |  | ||||||
|             board[row][col] = piece         # place piece in the move-to square |             board[row][col] = piece         # place piece in the move-to square | ||||||
|             redraw_board(window, board) |             redraw_board(window, board) | ||||||
|             i += 1 |             i += 1 | ||||||
|  |  | ||||||
							
								
								
									
										
											BIN
										
									
								
								Chess/nbishopb.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 2.5 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Chess/nbishopw.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 2.6 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Chess/nkingb.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 2.6 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Chess/nkingw.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 2.5 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Chess/nknightb.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 2.6 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Chess/nknightw.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 2.7 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Chess/npawnb.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 2.6 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Chess/npawnw.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 2.6 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Chess/nqueenb.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 2.8 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Chess/nqueenw.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 2.9 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Chess/nrookb.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 2.6 KiB | 
							
								
								
									
										
											BIN
										
									
								
								Chess/nrookw.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						| After Width: | Height: | Size: 2.7 KiB |