Skip to content

Commit 4f2200c

Browse files
committed
Stop user from drawing over goal tile
1 parent 5945eb4 commit 4f2200c

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/application.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,14 @@ def _draw_tiles(self) -> None:
9090
mouse_pos = pygame.mouse.get_pos()
9191
x, y = ((mouse_pos[0] // TILE_SIZE), ((mouse_pos[1] - HEADER_SIZE) // TILE_SIZE))
9292

93-
if 0 <= y < TILES_HEIGHT and 0 <= x < TILES_WIDTH:
94-
if self.grid[y][x] == ' ' and self.mouse_down[0] == 1:
95-
self.grid[y][x] = '#'
96-
if self.grid[y][x] == '#' and self.mouse_down[0] == 3:
97-
self.grid[y][x] = ' '
93+
if 0 > y >= TILES_HEIGHT and 0 > x >= TILES_WIDTH: return
94+
95+
if x == (TILES_WIDTH - 2) and y == (TILES_HEIGHT - 2): return
96+
97+
if self.grid[y][x] == ' ' and self.mouse_down[0] == 1:
98+
self.grid[y][x] = '#'
99+
if self.grid[y][x] == '#' and self.mouse_down[0] == 3:
100+
self.grid[y][x] = ' '
98101

99102
self.renderer.update_walls(self.grid)
100103

0 commit comments

Comments
 (0)