Star
Color bars in many directions
Extend color bars in more directions to see what we can make:
Loop two variables, x and y:
color4()
# color4, use number m block() function
def color4(x,y,z,d,m):
for i in [x-d, x+d]:
for j in [y-d, y+d]:
block(i, j, z, m)
if d<5:
game.set_timer(1, color4, x, y, z, d+1, m+1)
color4(0, 10, -20, 0, 50)
color8()
Add the middle point in the location list: [x-d, x, x+d]
# color8
def color8(x, y, z, d, m):
for i in [x-d, x, x+d]:
for j in [y-d, y, y+d]:
block(i, j, z, m)
if d<5:
game.set_timer(1, color8, x, y, z, d+1, m+1)
color8(15, 10, -20, 0, 50)
Can you figure out why the center block color is different in color4
and color8
?
Star 360
We are ready to make a growing star, see the video:
Surprisingly the code looks quite simple, just loop through x,y,z
to build in all directions.
Star
# Star
def star(x, y, z, d, m):
for i in [x-d, x, x+d]:
for j in [y-d, y, y+d]:
for k in [z-d, z, z+d]:
block(i, j, k, m)
if d < 10:
game.set_timer(1, star, x, y, z, d+1, m+1)
star(30, 30, -20, 0, 50)
((??which one put here, video or this pic??))