Skip to content

Commit 31dc751

Browse files
committed
Fixed a bug with the pawn were it could not start jump if there was a piece infront of where it would land. Also added a blue border around selected piece to move.
1 parent bf8ce76 commit 31dc751

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

GUI.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ def place_board(boardyy):
6868
win.blit(bKing, find_loc(y, x))
6969
pygame.display.update()
7070

71+
def draw_cursor(x,y):
72+
fx, fy = find_loc(x, y)
73+
fx -= 5
74+
fy -= 5
75+
pygame.draw.line(win, pygame.Color(39, 235, 242), (fx, fy), (fx+110, fy), 5)
76+
pygame.draw.line(win, pygame.Color(39, 235, 242), (fx+110, fy), (fx + 110, fy+110), 5)
77+
pygame.draw.line(win, pygame.Color(39, 235, 242), (fx + 110, fy+110), (fx, fy + 110), 5)
78+
pygame.draw.line(win, pygame.Color(39, 235, 242), (fx, fy + 110), (fx, fy), 5)
79+
7180
def show_text(text):
7281
green = (0, 255, 0)
7382
blue = (0, 0, 128)

main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ def main_gui(self):
6262
start = pygame.mouse.get_pos()
6363
sx = start[0]//111
6464
sy = start[1]//111
65-
clicks += 1
65+
if not isinstance(self.boardy.board[sy][sx], EmptySpace):
66+
clicks += 1
67+
draw_cursor(sx, sy)
68+
pygame.display.update()
6669
else:
6770
end = pygame.mouse.get_pos()
6871
ex = end[0] // 111

pieces.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,16 @@ def isMoveValid(self, board, start, end):
5757
# Check for start move
5858
if bStart.side < 0:
5959
if sy + 2 == ey and sx == ex and sy == 1:
60-
if isinstance(board[ey + 1][ex], EmptySpace):
60+
if isinstance(board[sy + 1][sx], EmptySpace):
6161
return True
6262
if bStart.side > 0:
6363
if sy - 2 == ey and sx == ex and sy == 6:
64-
if isinstance(board[ey - 1][ex], EmptySpace):
64+
if isinstance(board[sy - 1][sx], EmptySpace):
6565
return True
6666
# Check for normal move
6767
if sx == ex and ey == sy - bStart.side and bEnd.side == 0:
6868
return True
69-
raise MoveException(None, "The pawn had an invalid move.")
69+
raise MoveException(None, "The pawn had an invalid start move.")
7070
# Check for attack
7171
elif bStart.side * bEnd.side < 0:
7272
if bStart.side < 0 and sy + 1 == ey and abs(ex - sx) == 1:

0 commit comments

Comments
 (0)