Merge pull request #14 from NichiHachi/main
Fix Alexandre and can spawn house
17
main.py
@@ -1,11 +1,18 @@
|
||||
import random
|
||||
|
||||
import gdpc.exceptions
|
||||
|
||||
from world_maker.world_maker import *
|
||||
from House import *
|
||||
|
||||
def main():
|
||||
|
||||
rectangle_house_mountain, rectangle_building, skeleton_highway, skeleton_mountain = world_maker()
|
||||
|
||||
editor = Editor()
|
||||
|
||||
editor = Editor(buffering=True)
|
||||
buildArea = editor.getBuildArea()
|
||||
|
||||
blocks = {
|
||||
"wall": "blackstone",
|
||||
"roof": "blackstone",
|
||||
@@ -24,14 +31,17 @@ def main():
|
||||
|
||||
entranceDirection = ["N", "S", "E", "W"]
|
||||
|
||||
|
||||
for houses in rectangle_house_mountain:
|
||||
house = House(editor, houses[0], houses[1], entranceDirection[random.randint(0, 3)], blocks)
|
||||
start = (houses[0][0]+buildArea.begin[0], houses[0][1], houses[0][2]+buildArea.begin[2])
|
||||
end = (houses[1][0]+buildArea.begin[0], houses[1][1], houses[1][2]+buildArea.begin[2])
|
||||
house = House(editor, start, end, entranceDirection[random.randint(0, 3)], blocks)
|
||||
house.build()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
||||
"""
|
||||
from gdpc import Editor, Block, geometry, Transform
|
||||
import networks.curve as curve
|
||||
import numpy as np
|
||||
@@ -64,3 +74,4 @@ geometry.placeCuboid(editor, (-5,0,-8), (25,100,25), Block("air"))
|
||||
building = Building(random_data["buildings"], [(0,0,0), (20,30,20)], baseShape, DIRECTION.EAST)
|
||||
# build it with your custom materials
|
||||
building.build(editor, ["stone_bricks","glass_pane","glass","cobblestone_wall","stone_brick_stairs","oak_planks","white_concrete","cobblestone","stone_brick_slab","iron_bars"])
|
||||
"""
|
||||
|
Before Width: | Height: | Size: 597 B After Width: | Height: | Size: 813 B |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 6.1 KiB |
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 9.7 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 46 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.9 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 49 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 47 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 7.0 KiB |
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 1.7 KiB |
@@ -286,7 +286,7 @@ def rectangle_2D_to_3D(rectangle: list[tuple[tuple[int, int], tuple[int, int]]],
|
||||
for x in range(start[0], end[0]):
|
||||
for y in range(start[1], end[1]):
|
||||
avg_height += image.getpixel((x, y))
|
||||
avg_height = int(avg_height / ((end[0] - start[0]) * (end[1] - start[1])))
|
||||
avg_height = int(avg_height / ((end[0] - start[0]) * (end[1] - start[1]))) + 1
|
||||
new_rectangle.append(
|
||||
((start[0], avg_height, start[1]), (end[0], avg_height + randint(height_min, height_max), end[1])))
|
||||
return new_rectangle
|
||||
|
||||
@@ -31,4 +31,5 @@ def world_maker():
|
||||
subtract_map('./world_maker/data/mountain_map.png', './world_maker/data/skeleton_mountain_area.png').save('./world_maker/data/mountain_map.png')
|
||||
subtract_map(smooth_sobel_water_map, filter_negative('./world_maker/data/mountain_map.png')).save('./world_maker/data/mountain_map.png')
|
||||
rectangle_mountain = generate_building('./world_maker/data/mountain_map.png')
|
||||
return rectangle_building, rectangle_mountain, skeleton_highway, skeleton_mountain
|
||||
rectangle_mountain = rectangle_2D_to_3D(rectangle_mountain)
|
||||
return rectangle_mountain, rectangle_building, skeleton_highway, skeleton_mountain
|
||||
|
||||