From 64363205f7d93e845a7579c503039501e6d7778a Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Mon, 21 Dec 2020 19:29:28 +0100 Subject: Allow to display pieces on the grid Signed-off-by: Olivier Gayot --- cameltris.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'cameltris.py') diff --git a/cameltris.py b/cameltris.py index ea97fd5..fc9672f 100755 --- a/cameltris.py +++ b/cameltris.py @@ -1,15 +1,34 @@ #!/usr/bin/env python3 +import sys +import time + import pygame +def refresh_screen(): + for row_idx, row in enumerate(grid): + for col_idx, element in enumerate(row): + if element is not None: + screen.blit(white_piece, (col_idx * 50 + 1, row_idx * 50 + 1)) + pygame.init() +black = (0, 0, 0) +white = (0xff, 0xff, 0xff) + +white_piece = pygame.Surface((48, 48)) +white_piece.fill(white) + screen = pygame.display.set_mode((500, 1000)) +grid = [[True for _ in range(10)] for _ in range(20)] + while True: for event in pygame.event.get(): if event.type == pygame.QUIT: - break + sys.exit() - pygame.display.flip() + time.sleep(.1) + refresh_screen() + pygame.display.flip() -- cgit v1.2.3