-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayChess.py
62 lines (61 loc) · 2.28 KB
/
playChess.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import pygame
from board.chessBoard import Board
pygame.init()
gameDisplay=pygame.display.set_mode((800,800))
pygame.display.set_caption("The PY Chess")
clock=pygame.time.Clock()
chessBoard=Board()
chessBoard.createBoard()
chessBoard.printBoard()
allTiles=[]
allPieces=[]
############
def squares(x,y,w,h,color):
pygame.draw.rect(gameDispaly,color,[x,y,w,h])
allTiles.apend([color,[x,y,w,h]])
def DrawChessPiece():
xpos=0
ypos=0
color=None
width=100
height=100
black=(66,134,244)
white=(143,155,175)
for i in range(8):
for i in range(8):
if color%2==0:
squares(xpos,ypos,width,height,white)
if not chessBoard.gameTiles[number].pieceOnTile.toString()=='_':
img=pygame.image.load("./ChessArt/"
+chessBoard.gameTiles[number].pieceOnTile.alliance[0].upper()
+chessBoard.gameTiles[number].pieceOnTile.toString().upper()
+".png")
img=pygame.transform.scale(img,(100,100))
allPieces.append([img,[xpos,ypos], chessBoard.gameTiles[number].pieceOnTile])
xpos+=1
else:
squares(xpos, ypos, width, height, black)
if not chessBoard.gameTiles[number].pieceOnTile.toString() == '_':
img = pygame.image.load("./ChessArt/"
+ chessBoard.gameTiles[number].pieceOnTile.alliance[0].upper()
+ chessBoard.gameTiles[number].pieceOnTile.toString().upper()
+ ".png")
img = pygame.transform.scale(img, (100, 100))
allPieces.append([img, [xpos, ypos], chessBoard.gameTiles[number].pieceOnTile])
xpos += 1
color+=1
number+=1
color+=1
xpos=0
ypos+=100
############
drawChessPieces()
quitGame=False
while not quitGame:
for event in pygame.event.get():
if event.type == pygame.QUIT:
quitGame=True
pygame.quit()
quit()
pygame.display.update()
clock.tick(60)