-
Notifications
You must be signed in to change notification settings - Fork 1
/
Wall.py
58 lines (53 loc) · 3.48 KB
/
Wall.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import pygame
import random
class wall:
def __init__(self, x, y):
self.pixels =[[[0],[0],[0],[0],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[0],[0],[0],[0]],
[[0],[0],[0],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[0],[0],[0]],
[[0],[0],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[0],[0]],
[[0],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[0]],
[[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1]],
[[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1]],
[[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1]],
[[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1]],
[[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1]],
[[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1]],
[[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1]],
[[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1]],
[[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1],[1]],
[[1],[1],[1],[1],[1],[1],[1],[0],[0],[0],[0],[0],[0],[1],[1],[1],[1],[1],[1],[1]],
[[1],[1],[1],[1],[1],[1],[0],[0],[0],[0],[0],[0],[0],[0],[1],[1],[1],[1],[1],[1]],
[[1],[1],[1],[1],[1],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[1],[1],[1],[1],[1]],
[[1],[1],[1],[1],[1],[0],[0],[0],[0],[0],[0],[0],[0],[0],[0],[1],[1],[1],[1],[1]]]
self.color = (255,0,0)
self.pixel_size = 3
self.x = x
self.y = y
def draw(self, window):
for row in self.pixels:
for pixel in row:
if pixel[0] == 1:
pygame.draw.rect(window, self.color, pixel[1])
def create_pixel_rects(self):
x = self.x
y = self.y
for row in self.pixels:
for pixel in row:
pixel.append([x,y,self.pixel_size,self.pixel_size])
x += self.pixel_size
y += self.pixel_size
x = self.x
def destroy_nearby_pixels(self, pixel_index):
for row in self.pixels:
for pixel in row:
if self.pixels.index(row) > pixel_index[0] - 3 and self.pixels.index(row) < pixel_index[0] + 3:
if row.index(pixel) > pixel_index[1] - 2 and row.index(pixel) < pixel_index[1] + 2:
if random.randint(0,4) in [0,1,2,3]:
self.pixels[self.pixels.index(row)][row.index(pixel)][0] = 0
elif row.index(pixel) > pixel_index[1] - 3 and row.index(pixel) < pixel_index[1] + 3:
if random.randint(0,4) in [0,1]:
self.pixels[self.pixels.index(row)][row.index(pixel)][0] = 0
elif self.pixels.index(row) > pixel_index[0] - 4 and self.pixels.index(row) < pixel_index[0] + 4:
if row.index(pixel) > pixel_index[1] - 3 and row.index(pixel) < pixel_index[1] + 3:
if random.randint(0,4) in [0,1]:
self.pixels[self.pixels.index(row)][row.index(pixel)][0] = 0