Add House.py
This commit is contained in:
89
House.py
Normal file
89
House.py
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
from gdpc import Editor, Block, geometry
|
||||||
|
import networks.curve as curve
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
class House :
|
||||||
|
def __init__(self, editor,startX, startY, startZ, endX, endY, endZ):
|
||||||
|
self.editor = editor
|
||||||
|
self.startX = startX
|
||||||
|
self.startY = startY
|
||||||
|
self.startZ = startZ
|
||||||
|
self.endX = endX
|
||||||
|
self.endY = endY
|
||||||
|
self.endZ = endZ
|
||||||
|
|
||||||
|
|
||||||
|
def placeGround(self):
|
||||||
|
for x in range(self.startX, self.endX):
|
||||||
|
for z in range(self.startZ, self.endZ):
|
||||||
|
self.editor.placeBlock((x, self.startY, z), Block("stone"))
|
||||||
|
|
||||||
|
def placeWall(self):
|
||||||
|
for x in range(self.startX, self.endX+1):
|
||||||
|
for y in range(self.startY, self.endY):
|
||||||
|
self.editor.placeBlock((x, y, self.startZ), Block("oak_planks"))
|
||||||
|
self.editor.placeBlock((x, y, self.endZ), Block("oak_planks"))
|
||||||
|
for z in range(self.startZ, self.endZ+1):
|
||||||
|
for y in range(self.startY, self.endY):
|
||||||
|
self.editor.placeBlock((self.startX, y, z), Block("oak_planks"))
|
||||||
|
self.editor.placeBlock((self.endX, y, z), Block("oak_planks"))
|
||||||
|
|
||||||
|
def placeRoof(self):
|
||||||
|
for x in range(self.startX, self.endX+1):
|
||||||
|
for z in range(self.startZ, self.endZ+1):
|
||||||
|
self.editor.placeBlock((x, self.endY, z), Block("stone"))
|
||||||
|
|
||||||
|
def placeDoor(self,direction="north"):
|
||||||
|
if direction == "north":
|
||||||
|
x = (self.startX + self.endX) // 2
|
||||||
|
self.editor.placeBlock((x, self.startY, self.startZ), Block("air"))
|
||||||
|
self.editor.placeBlock((x, self.startY+1, self.startZ), Block("air"))
|
||||||
|
self.editor.placeBlock((x, self.startY+2, self.startZ), Block("air"))
|
||||||
|
elif direction == "south":
|
||||||
|
x = (self.startX + self.endX) // 2
|
||||||
|
self.editor.placeBlock((x, self.startY, self.endZ), Block("air"))
|
||||||
|
self.editor.placeBlock((x, self.startY+1, self.endZ), Block("air"))
|
||||||
|
self.editor.placeBlock((x, self.startY+2, self.endZ), Block("air"))
|
||||||
|
elif direction == "west":
|
||||||
|
z = (self.startZ + self.endZ) // 2
|
||||||
|
self.editor.placeBlock((self.startX, self.startY, z), Block("air"))
|
||||||
|
self.editor.placeBlock((self.startX, self.startY+1, z), Block("air"))
|
||||||
|
self.editor.placeBlock((self.startX, self.startY+2, z), Block("air"))
|
||||||
|
elif direction == "east":
|
||||||
|
z = (self.startZ + self.endZ) // 2
|
||||||
|
self.editor.placeBlock((self.endX, self.startY, z), Block("air"))
|
||||||
|
self.editor.placeBlock((self.endX, self.startY+1, z), Block("air"))
|
||||||
|
self.editor.placeBlock((self.endX, self.startY+2, z), Block("air"))
|
||||||
|
|
||||||
|
def placeHouse(self):
|
||||||
|
self.clearInside()
|
||||||
|
self.placeGround()
|
||||||
|
self.placeWall()
|
||||||
|
self.placeRoof()
|
||||||
|
self.placeDoor()
|
||||||
|
|
||||||
|
def clearInside(self):
|
||||||
|
for x in range(self.startX+1, self.endX):
|
||||||
|
for y in range(self.startY+1, self.endY):
|
||||||
|
for z in range(self.startZ+1, self.endZ):
|
||||||
|
self.editor.placeBlock((x, y, z), Block("air"))
|
||||||
|
|
||||||
|
def clear(self):
|
||||||
|
for x in range(self.startX, self.endX+1):
|
||||||
|
for y in range(self.startY, self.endY+1):
|
||||||
|
for z in range(self.startZ, self.endZ+1):
|
||||||
|
self.editor.placeBlock((x, y, z), Block("air"))
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
editor = Editor(buffering=True)
|
||||||
|
house = House(editor, 17, -58, 8, 30, -50, 20)
|
||||||
|
house.placeHouse()
|
||||||
|
#house.clear()
|
||||||
|
editor.flushBuffer()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
8
main.py
8
main.py
@@ -8,7 +8,7 @@ editor = Editor(buffering=True)
|
|||||||
# block = editor.getBlock((0,48,0))
|
# block = editor.getBlock((0,48,0))
|
||||||
|
|
||||||
# # Place a block
|
# # Place a block
|
||||||
# editor.placeBlock((394, 132, 741), Block("stone"))
|
editor.placeBlock((-5, -58, 0), Block("stone"))
|
||||||
|
|
||||||
# # Build a cube
|
# # Build a cube
|
||||||
# geometry.placeCuboid(editor, (458, 92, 488), (468, 99, 471), Block("oak_planks"))
|
# geometry.placeCuboid(editor, (458, 92, 488), (468, 99, 471), Block("oak_planks"))
|
||||||
@@ -17,6 +17,6 @@ curve = curve.Curve([(396, 132, 740), (435, 138, 730),
|
|||||||
(443, 161, 758), (417, 73, 729)])
|
(443, 161, 758), (417, 73, 729)])
|
||||||
curve.compute_curve()
|
curve.compute_curve()
|
||||||
|
|
||||||
for point in curve.computed_points:
|
#for point in curve.computed_points:
|
||||||
print(point)
|
# print(point)
|
||||||
editor.placeBlock(point, Block("stone"))
|
# editor.placeBlock(point, Block("stone"))
|
||||||
|
|||||||
Reference in New Issue
Block a user