Volume 3: Complex Constructions

In this volume we will explore more applications of for loop and fundamental functions like block, column, as well as other basic Python knowledge in CodeCraft. We can design many structures using what we've learned so far, practice makes perfect. Things covered in this volume are are starting to show the fun side of CodeCraft. Just for your inspiration, a picture speaks a thousand words:

(pic of all the stuff in this volume, complex, complex2, complexHigh5

((Knowledge used: for loop, range() function, user defined functions, list, dictionary, random module, get and set player's position))

Contents:

14 - Bars & Flats 15 - Photographer's Flat 16 - A Few Things 17 - Doors and Windows 18 - Cubes, Colorful Cubes 19 - House 20 - Build Trees

==

((save somewhere))

All code for image complexHigh5

# golden gate bridge
def HiLowColC(n,m,z):
    for i in range(1, 2*n, 3):
        column((i+m*40), z, (2*n-i), 36)
        column((i+2*n+m*40), z, i , 36)

for t in range(3):
    HiLowColC(10,t,-20)
    HiLowColC(10,t,-40)

# Floor board, flat_xz(x,y,z,width,length,material)
flat_xz(1,1, -40, 20, 120,2)

# Pyramid, diamond
for i in range(10):
    flat_xz(i-20,i,i, 20-2*i, 20-2*i, 3)

# Understand nested loops
for j in range(0,10,2):
    for i in range (-j, j+1, 2):
        block(i-20,j+1,-20, 69)

for j in range(0,10,2):
    block(0, j+1, -20, 71)

for j in range(0,10,3):
    for i in range (-j, j+1, 3):
        for k in range(-j, j+1, 3):
            block(i-20,j+1,k+40, 76)

for n in range(20):
    hollowCube(-n*5, 50-2*n, 5,4 , 76-n)

for n in range(20):
    hollowCube(n*5, 50-2*n, 5,4  , 76-n)

# house
cube(1,1,-20, 30, 67)    # light blue house
door(13,9, 50)           # red door
door(20,-20,50)

window(3,5,9,16,8, 62)    # blue window
window(20,5,9,16,8, 62)
window(3,5,-20, 20,14, 62)

# roof
flat_xz(-1,31,-22 ,34,34, 73)   # red roof

# door steps
flat_xz(12,1,9,2,8, 2)
flat_xz(10,0,10, 5, 12, 2)


# photographer's flat:
print( game.get_player_position() )

flat_xz(-18,20,84, 10,10,1)
game.set_player_position(Position(-18,21,84))

# forest, tree(x,z,h,w)

for n in range(1,20):
  tree(randint(-60,80), randint(-80, -40), randint(10,20), randint(2,4))

results matching ""

    No results matching ""