Diagonals

Other than the basic use of looping through only one direction, we can also loop through two or three directions at the same time to build diagonal lines of blocks in CodeCraft world.

Face Diagonal:

# x-y plane (green)
for i in range(5):
    game.set_block(Position(i+3, i, -20), 6)

# x-z plane (purple)
for i in range(5):
    game.set_block(Position(i, 5, i-20), 12)

# y-z plane (red)
for i in range(5):
    game.set_block(Position(0, i, i-20), 13)

Space Diagonal (pink):

for i in range(5):
    game.set_block(Position(i, i, -20+i), 11)

See, you can also learn geometry!

results matching ""

    No results matching ""