Columns

Just like the row of blocks you created in last lesson, you can also create columns or rows in the z-direction by looping through y and z values.

Column:

for j in range(10):
    game.set_block(Position(10, j, -10), 20)

j indicates each item in the number sequence, 0,1,2,...,9 generated by range(10).

for j in range(10) will iterate through the number list and each time read the code under the for loop header line; that is, call the function game.set_block() to lay a block at Position (10, j, -10).

After the loop is over, there will be 10 blocks total at locations:
(10,0,-10), (10,1,-10), (10,2,-10),..., (10,9,-10)

Together, they make up a column of 10 blocks high at the horizontal location(x=10, z=-10). (This column is actually 10 blocks tall. We can only see 9 blocks above the ground because the first block at y=0 is buried in the ground).

It's easy to shift the column up to show all the blocks by adding a number to j so each block is shifted upwards:

for j in range(10):
    game.set_block(Position(12,j+2,-10), 20)

results matching ""

    No results matching ""