# Untitled

unknown
plain_text
2 years ago
1.8 kB
1
Indexable
Never
```WHITE = (255, 255, 255)
BLACK = (0, 0, 0)

SCREEN_W = 250
SCREEN_H = 150

SPRITE_W = 5
SPRITE_H = 5

def make_array(w, h):
return [[WHITE for x in range(w)]for y in range(h)]

def fill_sprite_4(sprite):
w = len(sprite[0])
h = len(sprite)
for a in range(h // 2 + 1):
for b in range(w // 2 + 1):
sprite[a][b] = random.choice([BLACK, WHITE])

def fill_sprite(sprite):
w = len(sprite[0])
h = len(sprite)
for a in range(h):
for b in range(w // 2 + 1):
sprite[a][b] = random.choice([BLACK, WHITE])

def mirror_sprite_4(sprite):
w = len(sprite[0])
h = len(sprite)
for a in range(h // 2 + 1):
for b in range(w // 2 + 1):
sprite[-a - 1][-b - 1] = sprite[a][b]
sprite[-b - 1][-a - 1] = sprite[a][b]

def mirror_sprite(sprite):
w = len(sprite[0])
h = len(sprite)
for a in range(h):
for b in range(w // 2 + 1):
sprite[a][-b-1] = sprite[a][b]

def make_sprite_4(w,h):
sprite = make_array(w, h)
fill_sprite_4(sprite)
mirror_sprite_4(sprite)
return sprite

def make_sprite(w,h):
sprite = make_array(w, h)
fill_sprite(sprite)
mirror_sprite(sprite)
return sprite

def copy_sprite(screen, sprite, x0, y0):
for y in range(len(sprite)):
for x in range(len(sprite[0])):
screen[y0 + y][x0 + x] = sprite[y][x]

screen = [[WHITE for x in range(SCREEN_W)] for y in range(SCREEN_H)]

for y in range(0, SCREEN_H - SPRITE_H, SPRITE_H * 2):
for x in range(0, SCREEN_W - SPRITE_W, SPRITE_W * 2):
sprite = make_sprite(SPRITE_W, SPRITE_H)
copy_sprite(screen, sprite, x, y)

plt.figure(figsize=(30, 20))
plt.imshow(screen)```