Kill Time Grid

Jianqi Li
Data Mining the City
1 min readSep 18, 2018

Rules:

1. Create a grid.

2. Fill the rect when the mouse move above it.

3. When all the rects are filled , change another random color and than go back to 2.

from random import randint
grid = [[1]*4 for n in range(4)]
colour= randint(0,255)
w=100
colourR=255
colourG=0
colourB=0
oldR,oldG,oldB=255,255,255
def setup():
size(400,400)

def draw():
global grid,colourR,colourG,colourB,oldR,oldG,oldB
x,y=0,0
sum=0
for row in grid:
for col in row:
if col ==-1:
fill(colourR,colourG,colourB)
sum=sum+1
else:
fill(oldR,oldG,oldB)
rect(x, y, w, w)
x=x+w
y=y+w
x=0
grid[mouseY/w][ mouseX/w]=-1
if sum ==16:
a,b=0,0
oldR=colourR
oldG=colourG
oldB=colourB
colourR=randint(0,255)
colourG=randint(0,255)
colourB=randint(0,255)
fill(colour,0,0)
grid = [[1]*4 for n in range(4)]

--

--