I used the example from the lecture to start off my project 2. The "Random bugs", I tried to understand the codes though.
Comment : simple but really effective. Furthermore, the random source comes from the center.
CODE
---------------------------------------------------------------------------------------------------------------
import math
import random
def rnd11():
return 2.*random.random()-1.
SIZE = 600
xpos = SIZE/2.
ypos = SIZE/2.
def setup():
global xpos,ypos
size(SIZE, SIZE)
smooth()
fill(0,0,0,1)
background(255)
def draw():
global xpos, ypos
rect(xpos,ypos,1,1)
xpos = xpos + rnd11()
ypos = ypos + rnd11()
---------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment