Assignment 3-Columbia life

Junyu Cao
Data Mining the City
1 min readOct 17, 2018

150 students randomly go to school everyday from different streets.

def setup():
size(500, 500)
smooth()
global columbia, student, population, speed, imagesize, x, xSpeed, y, ySpeed
population=150
imagesize = 10
columbia = loadImage("columbia.png")
student = loadImage("student.png")
x = []
y = []
xSpeed = []
ySpeed = []
for i in range(population):
x.append(random(0,500))
y.append(random(0,500))
xSpeed.append(random(-5,5))
ySpeed.append(random(-5,5))
def draw():
background(0)
image(columbia,0,0,500,500)
for i in range(population):
x[i] = x[i] + xSpeed[i]
y[i] = y[i] + ySpeed[i]
if (x[i] > width - imagesize) or (x[i] < imagesize):
xSpeed[i] = xSpeed[i] * -1
if (y[i] > height - imagesize) or (y[i] < imagesize):
ySpeed[i] = ySpeed[i] * -1
noStroke()
image(student,x[i],y[i],imagesize,imagesize)

--

--