no style but entrance and roof added
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
class Point:
|
||||
def __init__(self, x : int = 0, y : int = 0, z : int = 0, p : tuple[int] = None):
|
||||
def __init__(self, x : int = 0, y : int = 0, z : int = 0, p : tuple[int,int,int] = None):
|
||||
if p != None: x,y,z = p
|
||||
self.x = x
|
||||
self.y = y
|
||||
self.z = z
|
||||
self.position = (x,y,z)
|
||||
|
||||
def set_position(self, x : int = 0, y : int = 0, z : int = 0, p : tuple[int] = None):
|
||||
def set_position(self, x : int = None, y : int = None, z : int = None, p : tuple[int,int,int] = None):
|
||||
if p != None: x,y,z = p
|
||||
self.x = x if x != None else self.x
|
||||
self.y = y if y != None else self.y
|
||||
@@ -14,4 +14,7 @@ class Point:
|
||||
self.position = (self.x,self.y,self.z)
|
||||
|
||||
def __repr__(self):
|
||||
return f"Point({self.position})"
|
||||
return f"Point({self.position})"
|
||||
|
||||
def copy(self) -> 'Point':
|
||||
return Point(self.x, self.y, self.z)
|
||||
@@ -18,9 +18,10 @@ class Polygon:
|
||||
rect.fill(editor, material, y2)
|
||||
|
||||
def fill_vertice(self, editor : Editor, material : str, y : int, y2 : int = None):
|
||||
if y2 == None: y2 = y
|
||||
if y2 == None: y2 = 0
|
||||
for vertice in self.vertices:
|
||||
vertice.fill(editor, Block(material), y, y2)
|
||||
with editor.pushTransform(Transform((0,y,0))):
|
||||
vertice.fill(editor, material, y2)
|
||||
|
||||
def compress(self, tiles : list[Tile], vertices : list[Vertice]):
|
||||
remaining_tiles = tiles.copy()
|
||||
@@ -58,9 +59,9 @@ class Polygon:
|
||||
has_next2 = self._has_next(neighbors[1], current.facing, remaining_vertices)
|
||||
|
||||
if has_next1:
|
||||
current = Vertice(has_next1.point1, current.point2, current.facing)
|
||||
current = Vertice(has_next1.point1.copy(), current.point2.copy(), current.facing)
|
||||
elif has_next2:
|
||||
current = Vertice(current.point1, has_next2.point2, current.facing)
|
||||
current = Vertice(current.point1.copy(), has_next2.point2.copy(), current.facing)
|
||||
else:
|
||||
self.vertices.append(current)
|
||||
current = remaining_vertices.pop()
|
||||
@@ -89,7 +90,7 @@ class Polygon:
|
||||
for tile in new_line: remaining_tiles.remove(tile)
|
||||
line = new_line
|
||||
|
||||
def _has_neighbor(self, target : tuple[int], tiles : list[Tile]) -> bool|Tile:
|
||||
def _has_neighbor(self, target : Point, tiles : list[Tile]) -> bool|Tile:
|
||||
for tile in tiles:
|
||||
if tile.pos.position == target.position:
|
||||
return tile
|
||||
|
||||
@@ -64,13 +64,13 @@ class Tile:
|
||||
# 0 = north, 1 = east, 2 = south, 3 = west
|
||||
match(vertice):
|
||||
case 0 :
|
||||
return Vertice(self.north_west, self.north_east, DIRECTION.NORTH)
|
||||
return Vertice(self.north_west.copy(), self.north_east.copy(), DIRECTION.NORTH)
|
||||
case 1 :
|
||||
return Vertice(self.north_east, self.south_east, DIRECTION.EAST)
|
||||
return Vertice(self.north_east.copy(), self.south_east.copy(), DIRECTION.EAST)
|
||||
case 2 :
|
||||
return Vertice(self.south_west, self.south_east, DIRECTION.SOUTH)
|
||||
return Vertice(self.south_west.copy(), self.south_east.copy(), DIRECTION.SOUTH)
|
||||
case 3 :
|
||||
return Vertice(self.north_west, self.south_west, DIRECTION.WEST)
|
||||
return Vertice(self.north_west.copy(), self.south_west.copy(), DIRECTION.WEST)
|
||||
case DIRECTION.WEST :
|
||||
return self.west_vertice
|
||||
case DIRECTION.EAST :
|
||||
@@ -82,7 +82,7 @@ class Tile:
|
||||
|
||||
def set_vertice(self, direction : DIRECTION, vertice : Vertice, height : int):
|
||||
self.has_vertice = True
|
||||
vertice.point2.y = height
|
||||
vertice.point2.set_position(y = height)
|
||||
match(direction):
|
||||
case DIRECTION.WEST :
|
||||
self.west_vertice = vertice
|
||||
|
||||
Reference in New Issue
Block a user