From bfde354760877e299c93e965141b8003585cae7f Mon Sep 17 00:00:00 2001 From: CJSatnarine Date: Fri, 29 Dec 2023 21:36:58 -0500 Subject: [PATCH] Impliment block that appears on top of existing cubes --- GenerateTerrain.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/GenerateTerrain.py b/GenerateTerrain.py index c9f36a1..497efc3 100644 --- a/GenerateTerrain.py +++ b/GenerateTerrain.py @@ -5,7 +5,7 @@ import random # Size of each cube. size = 1 # Setting the x, y, and z positions. -x = y = z = size / 2 +x = y = z = size # Setting the number of cubes in each coordinate. xNum = 10 yNum = 10 @@ -61,11 +61,17 @@ def createMaterial(red, blue, green, alpha): # Function to create the tree. def buildTree(): - print("tree") + # Getting a random position on top of the row of cubes. + treeXPos = random.randint(0, xNum - 1) + treeYPos = random.randint(0, yNum - 1) + treeZPos = z + 0.5 + + bpy.ops.mesh.primitive_cube_add(size = size, location = (treeXPos, treeYPos, treeZPos), scale = (size, size, size)) + # Calling the functions: cleanScene() -# spawnGround() +spawnGround() buildTree() # Shows that the code ran.