Merge pull request #17 from Eclairsombre/main

Fix house roof
This commit is contained in:
Xeon0X
2024-06-21 18:50:01 +02:00
committed by GitHub
7 changed files with 39 additions and 41 deletions

View File

@@ -260,7 +260,7 @@ class House:
n = 3 n = 3
else: else:
if width < depth: if width > depth:
n = width // 4 n = width // 4
else: else:
n = depth // 4 n = depth // 4
@@ -273,11 +273,11 @@ class House:
if width < depth: if width < depth:
if n > 1 : if n > 1 :
for k in range(n-1): for k in range(n):
for i in range(-1, depth + 1): for i in range(-1, depth + 1):
for y in range(-1, width // 2 + 1 - k): for y in range(-1, width // 2 + 1 - k):
self.editor.placeBlock((x + y + k, self.coordinates_max[1] + k , z + i), self.roof) self.editor.placeBlock((x + y + k + 2, self.coordinates_max[1] + k , z + i), self.roof)
self.editor.placeBlock((x + width - y - 1 - k, self.coordinates_max[1] + k, z + i), self.roof) self.editor.placeBlock((x + width - y - 1 - k - 2, self.coordinates_max[1] + k, z + i), self.roof)
else: else:
if width % 2 == 0: if width % 2 == 0:
for i in range(-1, depth + 1): for i in range(-1, depth + 1):
@@ -291,8 +291,8 @@ class House:
for k in range(n ): for k in range(n ):
for i in range(-1, width + 1): for i in range(-1, width + 1):
for y in range(-1, depth // 2 + 1 - k): for y in range(-1, depth // 2 + 1 - k):
self.editor.placeBlock((x + i, self.coordinates_max[1] + k, z + y + k ), self.roof) self.editor.placeBlock((x + i, self.coordinates_max[1] + k, z + y + k + 2 ), self.roof)
self.editor.placeBlock((x + i, self.coordinates_max[1] + k, z + depth - y -1- k),self.roof) self.editor.placeBlock((x + i, self.coordinates_max[1] + k, z + depth - y -1- k - 2),self.roof)
else: else:
if depth % 2 == 0: if depth % 2 == 0:
for i in range(-1, width + 1): for i in range(-1, width + 1):
@@ -483,7 +483,6 @@ class House:
h = 0 h = 0
for i in range(-1, depth // 2): for i in range(-1, depth // 2):
for j in range(-1, width + 1): for j in range(-1, width + 1):
print( self.coordinates_max[1] + h)
if i != -1: if i != -1:
if h % 1 == 0: if h % 1 == 0:
self.editor.placeBlock((x + j, math.ceil(self.coordinates_max[1] + h), z + i), self.editor.placeBlock((x + j, math.ceil(self.coordinates_max[1] + h), z + i),
@@ -520,10 +519,10 @@ class House:
self.editor.placeBlock((x + j, math.ceil(self.coordinates_max[1] + h - 0.5), z + depth - 1 - i), self.editor.placeBlock((x + j, math.ceil(self.coordinates_max[1] + h - 0.5), z + depth - 1 - i),
self.roof) self.roof)
self.grid3d[j, round(height + h + 0.5), i] = True self.grid3d[x_plan3d+j, round(height + h + 0.5),z_plan3d+ i] = True
self.grid3d[j, round(height + h + 0.5), depth - 1 - i] = True self.grid3d[x_plan3d+j, round(height + h + 0.5),z_plan3d+ depth - 1 - i] = True
self.grid3d[j, round(height + h - 0.5), i] = True self.grid3d[x_plan3d+j, round(height + h - 0.5),z_plan3d+ i] = True
self.grid3d[j, round(height + h - 0.5), depth - 1 - i] = True self.grid3d[x_plan3d+j, round(height + h - 0.5), z_plan3d+depth - 1 - i] = True
if j == -1: if j == -1:
self.editor.placeBlock((x + j - 1, math.ceil(self.coordinates_max[1] + h), z + i), self.editor.placeBlock((x + j - 1, math.ceil(self.coordinates_max[1] + h), z + i),
@@ -536,10 +535,10 @@ class House:
(x + j - 1, math.ceil(self.coordinates_max[1] + h-1), z + depth - 1 - i), (x + j - 1, math.ceil(self.coordinates_max[1] + h-1), z + depth - 1 - i),
Block(self.blocks["celling_slab"], {"type": "top"})) Block(self.blocks["celling_slab"], {"type": "top"}))
self.grid3d[j, round(height + h), i] = True self.grid3d[x_plan3d+j-1, round(height + h),z_plan3d+ i] = True
self.grid3d[j, round(height + h), depth - 1 - i] = True self.grid3d[x_plan3d+j-1, round(height + h), z_plan3d+depth - 1 - i] = True
self.grid3d[j, round(height + h - 1), i] = True self.grid3d[x_plan3d+j-1, round(height + h - 1),z_plan3d+ i] = True
self.grid3d[j, round(height + h - 1), depth - 1 - i] = True self.grid3d[x_plan3d+j-1, round(height + h - 1), z_plan3d+depth - 1 - i] = True
elif j == width: elif j == width:
self.editor.placeBlock((x + j + 1, math.ceil(self.coordinates_max[1] + h), z + i), self.editor.placeBlock((x + j + 1, math.ceil(self.coordinates_max[1] + h), z + i),
Block(self.blocks["celling_slab"], {"type": "bottom"})) Block(self.blocks["celling_slab"], {"type": "bottom"}))
@@ -551,56 +550,56 @@ class House:
(x + j + 1, math.ceil(self.coordinates_max[1] + h-1), z + depth - 1 - i), (x + j + 1, math.ceil(self.coordinates_max[1] + h-1), z + depth - 1 - i),
Block(self.blocks["celling_slab"], {"type": "top"})) Block(self.blocks["celling_slab"], {"type": "top"}))
self.grid3d[j, round(height + h), i] = True self.grid3d[x_plan3d+j+1, round(height + h),z_plan3d+ i] = True
self.grid3d[j, round(height + h), depth - 1 - i] = True self.grid3d[x_plan3d+j+1, round(height + h),z_plan3d+ depth - 1 - i] = True
self.grid3d[j, round(height + h - 1), i] = True self.grid3d[x_plan3d+j+1, round(height + h - 1), z_plan3d+i] = True
self.grid3d[j, round(height + h - 1), depth - 1 - i] = True self.grid3d[x_plan3d+j+1, round(height + h - 1),z_plan3d+ depth - 1 - i] = True
else: else:
self.editor.placeBlock((x + j, math.ceil(self.coordinates_max[1] + h), z + i), self.editor.placeBlock((x + j, math.ceil(self.coordinates_max[1] + h), z + i),
Block(self.blocks["roof_slab"], {"type": "bottom"})) Block(self.blocks["roof_slab"], {"type": "bottom"}))
self.editor.placeBlock((x + j, math.ceil(self.coordinates_max[1] + h), z + depth - 1 - i), self.editor.placeBlock((x + j, math.ceil(self.coordinates_max[1] + h), z + depth - 1 - i),
Block(self.blocks["roof_slab"], {"type": "bottom"})) Block(self.blocks["roof_slab"], {"type": "bottom"}))
self.grid3d[j, round(height + h), i] = True self.grid3d[x_plan3d+j, round(height + h), z_plan3d+i] = True
self.grid3d[j, round(height + h), depth - 1 - i] = True self.grid3d[x_plan3d+j, round(height + h), z_plan3d+depth - 1 - i] = True
if j == -1: if j == -1:
self.editor.placeBlock((x + j - 1, math.ceil(self.coordinates_max[1] + h), z + i), self.editor.placeBlock((x + j - 1, math.ceil(self.coordinates_max[1] + h), z + i),
Block(self.blocks["celling_slab"], {"type": "bottom"})) Block(self.blocks["celling_slab"], {"type": "bottom"}))
self.editor.placeBlock((x + j - 1, math.ceil(self.coordinates_max[1] + h), z + depth - 1 - i), self.editor.placeBlock((x + j - 1, math.ceil(self.coordinates_max[1] + h), z + depth - 1 - i),
Block(self.blocks["celling_slab"], {"type": "bottom"})) Block(self.blocks["celling_slab"], {"type": "bottom"}))
if not self.grid3d[j, height + h - 1, i]: if not self.grid3d[x_plan3d+j-1, height + h - 1, z_plan3d+i]:
self.editor.placeBlock((x + j - 1, math.ceil(self.coordinates_max[1] + h-1) , z + i), self.editor.placeBlock((x + j - 1, math.ceil(self.coordinates_max[1] + h-1) , z + i),
Block(self.blocks["celling_slab"], {"type": "top"})) Block(self.blocks["celling_slab"], {"type": "top"}))
self.grid3d[j, height + h - 1, i] = True self.grid3d[x_plan3d+j-1, height + h - 1, z_plan3d+i] = True
if not self.grid3d[j, height + h - 1, depth - 1 - i]: if not self.grid3d[x_plan3d+j-1, height + h - 1, z_plan3d+depth - 1 - i]:
self.editor.placeBlock( self.editor.placeBlock(
(x + j - 1, math.ceil(self.coordinates_max[1] + h-1) , z + depth - 1 - i), (x + j - 1, math.ceil(self.coordinates_max[1] + h-1) , z + depth - 1 - i),
Block(self.blocks["celling_slab"], {"type": "top"})) Block(self.blocks["celling_slab"], {"type": "top"}))
self.grid3d[j, height + h - 1, depth - 1 - i] = True self.grid3d[x_plan3d+j-1, height + h - 1, z_plan3d+depth - 1 - i] = True
self.grid3d[j, round(height + h), i] = True self.grid3d[x_plan3d+j-1, round(height + h), z_plan3d+i] = True
self.grid3d[j, round(height + h), depth - 1 - i] = True self.grid3d[x_plan3d+j-1, round(height + h),z_plan3d+ depth - 1 - i] = True
elif j == width: elif j == width:
self.editor.placeBlock((x + j + 1, math.ceil(self.coordinates_max[1] + h), z + i), self.editor.placeBlock((x + j + 1, math.ceil(self.coordinates_max[1] + h), z + i),
Block(self.blocks["celling_slab"], {"type": "bottom"})) Block(self.blocks["celling_slab"], {"type": "bottom"}))
self.editor.placeBlock((x + j + 1, math.ceil(self.coordinates_max[1] + h), z + depth - 1 - i), self.editor.placeBlock((x + j + 1, math.ceil(self.coordinates_max[1] + h), z + depth - 1 - i),
Block(self.blocks["celling_slab"], {"type": "bottom"})) Block(self.blocks["celling_slab"], {"type": "bottom"}))
if not self.grid3d[j, height + h - 1, i]: if not self.grid3d[x_plan3d+j+1, height + h - 1,z_plan3d+ i]:
self.editor.placeBlock((x + j + 1, math.ceil(self.coordinates_max[1] + h-1), z + i), self.editor.placeBlock((x + j + 1, math.ceil(self.coordinates_max[1] + h-1), z + i),
Block(self.blocks["celling_slab"], {"type": "top"})) Block(self.blocks["celling_slab"], {"type": "top"}))
self.grid3d[j, height + h - 1, i] = True self.grid3d[x_plan3d+j+1, height + h - 1, z_plan3d+i] = True
if not self.grid3d[j, height + h - 1, depth - 1 - i]: if not self.grid3d[x_plan3d+j+1, height + h - 1,z_plan3d+ depth - 1 - i]:
self.editor.placeBlock( self.editor.placeBlock(
(x + j + 1, math.ceil(self.coordinates_max[1] + h-1), z + depth - 1 - i), (x + j + 1, math.ceil(self.coordinates_max[1] + h-1), z + depth - 1 - i),
Block(self.blocks["celling_slab"], {"type": "top"})) Block(self.blocks["celling_slab"], {"type": "top"}))
self.grid3d[j, height + h - 1, depth - 1 - i] = True self.grid3d[x_plan3d+j+1, height + h - 1,z_plan3d+ depth - 1 - i] = True
self.grid3d[j, round(height + h), i] = True self.grid3d[x_plan3d+j+1, round(height + h), z_plan3d+i] = True
self.grid3d[j, round(height + h), depth - 1 - i] = True self.grid3d[x_plan3d+j+1, round(height + h), z_plan3d+depth - 1 - i] = True
self.grid3d[j, round(height + h), i] = True self.grid3d[x_plan3d+j, round(height + h), z_plan3d+i] = True
self.grid3d[j, round(height + h), depth - 1 - i] = True self.grid3d[x_plan3d+j, round(height + h),z_plan3d+ depth - 1 - i] = True
if i != -1: if i != -1:
h += 0.5 h += 0.5
@@ -793,7 +792,7 @@ class House:
def placeEntrance(self): def placeEntrance(self):
wall = self.WallFacingDirection() wall = self.WallFacingDirection()
print(wall)
self.entranceWall = wall self.entranceWall = wall
match self.direction: match self.direction:
case "W": case "W":
@@ -1072,8 +1071,7 @@ class House:
self.editor.placeBlock((i, y_min, y), self.gardenOutline) self.editor.placeBlock((i, y_min, y), self.gardenOutline)
self.editor.placeBlock((i, y_min + 1, y), self.gardenOutline) self.editor.placeBlock((i, y_min + 1, y), self.gardenOutline)
self.editor.placeBlock((i, y_min + 2, y), self.gardenOutline) self.editor.placeBlock((i, y_min + 2, y), self.gardenOutline)
else:
print(i, y)
case _: case _:
self.editor.placeBlock((i, y_min - 1, y), self.garden_floor) self.editor.placeBlock((i, y_min - 1, y), self.garden_floor)
@@ -1121,8 +1119,8 @@ if __name__ == "__main__":
house.build() house.build()
new_coordinates_min = (coordinates_max[0] + 10, coordinates_min[1], coordinates_min[2]) new_coordinates_min = (coordinates_max[0] + 20, coordinates_min[1], coordinates_min[2])
new_coordinates_max = (coordinates_max[0] + 10 + 24, coordinates_max[1], coordinates_max[2]) new_coordinates_max = (coordinates_max[0] + 10 + 40, coordinates_max[1], coordinates_max[2])
coordinates_min = new_coordinates_min coordinates_min = new_coordinates_min
coordinates_max = new_coordinates_max coordinates_max = new_coordinates_max

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 99 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 69 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 104 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 KiB

After

Width:  |  Height:  |  Size: 72 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 82 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 914 B

After

Width:  |  Height:  |  Size: 72 B