-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisperse.py
More file actions
31 lines (26 loc) · 904 Bytes
/
Disperse.py
File metadata and controls
31 lines (26 loc) · 904 Bytes
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
from Panel import Panel
import random
class Disperse:
def __init__(self, speed, p):
self.coords = []
self.panelRef = p
#self.setBackground()
self.speed = speed
#self.panelRef.setBackground((69,69,69))
def setBackground(self):
#self.panelRef.setBackground((69,69,69))
for x in range(self.panelRef.width):
for y in range(self.panelRef.height):
self.coords.append((x,y))
def reset(self):
self.coords = []
self.setBackground()
def update(self):
for t in range(self.speed):
if (len(self.coords) == 0):
self.setBackground()
else:
i = random.randint(0, len(self.coords)-1)
temp = self.coords[i]
self.panelRef.setPixel(temp[0], temp[1], (0,0,0))
self.coords.remove(temp)