summaryrefslogtreecommitdiff
path: root/cameltris.py
diff options
context:
space:
mode:
authorOlivier Gayot <olivier.gayot@sigexec.com>2020-12-21 19:29:28 +0100
committerOlivier Gayot <olivier.gayot@sigexec.com>2020-12-21 19:29:28 +0100
commit64363205f7d93e845a7579c503039501e6d7778a (patch)
treeb9a1db13c7434f7b38a76432617fba3431ef6855 /cameltris.py
parent4e62c77aaaa1cc861123048fc10fecac3f85063f (diff)
Allow to display pieces on the grid
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'cameltris.py')
-rwxr-xr-xcameltris.py23
1 files changed, 21 insertions, 2 deletions
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()