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
|
import pygame
WIDTH = 800
HEIGHT = WIDTH
COLS = 50
ROWS = COLS
SPOT_WIDTH = WIDTH//COLS
SPOT_HEIGHT = HEIGHT//ROWS
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 255, 0)
YELLOW = (255, 255, 0)
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
PURPLE = (128, 0, 128)
ORANGE = (255, 165, 0)
GREY = (128, 128, 128)
TURQUOISE = (64, 224, 208)
win = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption('grid world')
def draw():
win.fill(WHITE)
for i in range(COLS):
pygame.draw.line(win, GREY, (i*SPOT_WIDTH, 0), (i*SPOT_WIDTH, HEIGHT))
for j in range(ROWS):
pygame.draw.line(win, GREY, (0, j*SPOT_HEIGHT), (WIDTH, j*SPOT_HEIGHT))
pygame.display.update()
if __name__ == '__main__':
run = True
while run:
draw()
|