def render(self): if (utils.sum_points_inside_flat_poly(*self.parent.canvas) <= 4): return color = random.choice(self.colors) for x in utils.iterate_points_inside_flat_poly(*self.parent.canvas): self.parent.parent.setblock(x+self.parent.loc, self.mat) if ((x.x+x.z) & 1 == 1): self.parent.parent.blocks[x+self.parent.loc].data = color[0] else: self.parent.parent.blocks[x+self.parent.loc].data = color[1] # Runined if (self.ruin is False): return pn = perlin.SimplexNoise(256) c = self.parent.canvasCenter() y = self.parent.canvasHeight() r = random.randint(1, 1000) maxd = max(1, self.parent.canvasWidth(), self.parent.canvasLength()) for x in utils.iterate_points_inside_flat_poly(*self.parent.canvas): p = x+self.parent.loc d = ((Vec2f(x.x, x.z) - c).mag()) / maxd n = (pn.noise3((p.x+r) / 4.0, y / 4.0, p.z / 4.0) + 1.0) / 2.0 if (n < d): self.parent.parent.setblock(p, materials._floor) self.parent.parent.blocks[p].data = 0
def render(self): if (utils.sum_points_inside_flat_poly(*self.parent.canvas) <= 4): return for x in utils.iterate_points_inside_flat_poly(*self.parent.canvas): self.parent.parent.setblock(x + self.parent.loc, self.mat) # Ruined if (self.ruin): self.ruinrender()
def render(self): wood = random.sample(self.woodtypes, 2) if (utils.sum_points_inside_flat_poly(*self.parent.canvas) > 4): for x in utils.iterate_points_inside_flat_poly( *self.parent.canvas ): if ((x.x + x.z) & 1 == 1): self.parent.parent.setblock(x + self.parent.loc, wood[0]) else: self.parent.parent.setblock(x + self.parent.loc, wood[1])
def render(self): if (utils.sum_points_inside_flat_poly(*self.parent.canvas) > 4): for x in utils.iterate_points_inside_flat_poly( *self.parent.canvas ): if ((x.x + x.z) & 1 == 1): self.parent.parent.setblock(x + self.parent.loc, materials.Wood) else: self.parent.parent.setblock(x + self.parent.loc, materials.OakWoodPlanks)
def render(self): mat = random.choice(self.stonetypes) if (utils.sum_points_inside_flat_poly(*self.parent.canvas) > 4): for x in utils.iterate_points_inside_flat_poly( *self.parent.canvas ): if ((x.x + x.z) & 1 == 1): self.parent.parent.setblock(x + self.parent.loc, mat[0]) else: self.parent.parent.setblock(x + self.parent.loc, mat[1]) # Ruined if (self.ruin): self.ruinrender()
def render(self): if (utils.sum_points_inside_flat_poly(*self.parent.canvas) > 4): block = random.choice(self.colours) pattern = random.choice(self.patterns) hmax = len(pattern) wmax = len(pattern[0]) for x in utils.iterate_points_inside_flat_poly( *self.parent.canvas): data = pattern[x.x % hmax][x.z % wmax] self.parent.parent.setblock(x + self.parent.loc, block, data) # Ruined if (self.ruin): self.ruinrender(3.0)
def render(self): if (utils.sum_points_inside_flat_poly(*self.parent.canvas) <= 4): return color = random.choice(self.colors) for x in utils.iterate_points_inside_flat_poly(*self.parent.canvas): self.parent.parent.setblock(x + self.parent.loc, self.mat) if ((x.x + x.z) & 1 == 1): self.parent.parent.blocks[x + self.parent.loc].data = color[0] else: self.parent.parent.blocks[x + self.parent.loc].data = color[1] # Runined if (self.ruin): self.ruinrender()
def render(self): if (utils.sum_points_inside_flat_poly(*self.parent.canvas) > 4): block = random.choice(self.colours) pattern = random.choice(self.patterns) hmax = len(pattern) wmax = len(pattern[0]) for x in utils.iterate_points_inside_flat_poly( *self.parent.canvas ): data = pattern[x.x%hmax][x.z%wmax] self.parent.parent.setblock(x + self.parent.loc, block, data) # Ruined if (self.ruin): self.ruinrender(3.0)
def render(self): pn = perlin.SimplexNoise(256) if (utils.sum_points_inside_flat_poly(*self.parent.canvas) <= 4): return c = self.parent.canvasCenter() y = self.parent.canvasHeight() r = random.randint(1, 1000) maxd = max(1, self.parent.canvasWidth(), self.parent.canvasLength()) for x in utils.iterate_points_inside_flat_poly(*self.parent.canvas): p = x + self.parent.loc d = ((Vec2f(x.x, x.z) - c).mag()) / maxd n = (pn.noise3((p.x + r) / 4.0, y / 4.0, p.z / 4.0) + 1.0) / 2.0 if (n >= d + .20): self.parent.parent.setblock(p, materials.Sand) elif (n >= d + .10): self.parent.parent.setblock(p, materials.Sandstone) elif (n >= d): self.parent.parent.setblock(p, materials.Gravel)
def render(self): pn = perlin.SimplexNoise(256) if (utils.sum_points_inside_flat_poly(*self.parent.canvas) <= 4): return c = self.parent.canvasCenter() y = self.parent.canvasHeight() r = random.randint(1, 1000) maxd = max(1, self.parent.canvasWidth(), self.parent.canvasLength()) for x in utils.iterate_points_inside_flat_poly(*self.parent.canvas): p = x + self.parent.loc d = ((Vec2f(x.x, x.z) - c).mag()) / maxd n = (pn.noise3((p.x + r) / 4.0, y / 4.0, p.z / 4.0) + 1.0) / 2.0 if (n >= d + .50): self.parent.parent.setblock(p, materials.Water) elif (n >= d + .30): self.parent.parent.setblock(p, materials.SoulSand) elif (n >= d + .20): self.parent.parent.setblock(p, materials.Farmland) self.parent.parent.blocks[p].data = random.randint(0, 1) elif (n >= d + .10): self.parent.parent.setblock(p, materials.Podzol) self.parent.parent.blocks[p].data = 2 # Podzol data val elif (n >= d): self.parent.parent.setblock(p, materials.Dirt)
def render(self): if (utils.sum_points_inside_flat_poly(*self.parent.canvas) <= 4): return color_profile = random.choice(self.colors) min_x = utils.floor(min([p.x for p in self.parent.canvas])) max_x = utils.ceil(max([p.x for p in self.parent.canvas])) min_z = utils.floor(min([p.z for p in self.parent.canvas])) max_z = utils.ceil(max([p.z for p in self.parent.canvas])) min_y = utils.floor(min([p.y for p in self.parent.canvas])) # Cut the canvas into quarters and fill one quarter with colors. # Then, copy that quarter into the other three quarters. width = utils.floor(((max_x - min_x + 1) + 1) / 2) depth = utils.floor(((max_z - min_z + 1) + 1) / 2) points = [[-1 for j in xrange(depth)] for i in xrange(width)] points_left = [] for i in xrange(width): for j in xrange(depth): points_left.append((i, j)) bounds = utils.Box(Vec(0, 0, 0), width, 1, depth) p = Vec(0, 0, 0) color_num = 0 prev_dir = random.randint(0, 3) next_dir = random.randint(0, 3) while len(points_left) > 0: # pick random starting point and walk around the matrix point_index = random.randint(0, len(points_left) - 1) p = Vec(points_left[point_index][0], 0, points_left[point_index][1]) while (bounds.containsPoint(p) and points[p.x][p.z] == -1 and len(points_left) > 0): points[p.x][p.z] = color_num points_left.remove((p.x, p.z)) # pick random direction to walk, try to keep walking same # direction if random.randint(0, self._walk_weight) != 0: next_dir = prev_dir else: while next_dir == prev_dir: next_dir = random.randint(0, 3) if next_dir == 0: # right p += Vec(1, 0, 0) elif next_dir == 1: # down p += Vec(0, 0, 1) elif next_dir == 2: # left p += Vec(-1, 0, 0) else: # up p += Vec(0, 0, -1) prev_dir = next_dir color_num = (color_num + 1) % len(color_profile) for j in xrange(max_z - min_z + 1): for i in xrange(max_x - min_x + 1): p = self.parent.loc + Vec(min_x + i, min_y, min_z + j) self.parent.parent.setblock(p, self.mat) if i < width: i_adj = i else: i_adj = 2 * width - 1 - i if j < depth: j_adj = j else: j_adj = 2 * depth - 1 - j self.parent.parent.blocks[p].data = \ color_profile[points[i_adj][j_adj]] # Ruined if (self.ruin): self.ruinrender()
def render(self): if (utils.sum_points_inside_flat_poly(*self.parent.canvas) <= 4): return color_profile = random.choice(self.colors) min_x = utils.floor(min([p.x for p in self.parent.canvas])) max_x = utils.ceil(max([p.x for p in self.parent.canvas])) min_z = utils.floor(min([p.z for p in self.parent.canvas])) max_z = utils.ceil(max([p.z for p in self.parent.canvas])) min_y = utils.floor(min([p.y for p in self.parent.canvas])) # Cut the canvas into quarters and fill one quarter with colors. # Then, copy that quarter into the other three quarters. width = utils.floor(((max_x - min_x + 1) + 1) / 2) depth = utils.floor(((max_z - min_z + 1) + 1) / 2) points = [[-1 for j in xrange(depth)] for i in xrange(width)] points_left = [] for i in xrange(width): for j in xrange(depth): points_left.append((i, j)) bounds = utils.Box(Vec(0, 0, 0), width, 1, depth) p = Vec(0, 0, 0) color_num = 0 prev_dir = random.randint(0, 3) next_dir = random.randint(0, 3) while len(points_left) > 0: # pick random starting point and walk around the matrix point_index = random.randint(0, len(points_left)-1) p = Vec(points_left[point_index][0], 0, points_left[point_index][1]) while (bounds.containsPoint(p) and points[p.x][p.z] == -1 and len(points_left) > 0): points[p.x][p.z] = color_num points_left.remove((p.x, p.z)) # pick random direction to walk, try to keep walking same direction if random.randint(0, self._walk_weight) != 0: next_dir = prev_dir else: while next_dir == prev_dir: next_dir = random.randint(0, 3) if next_dir == 0: # right p += Vec(1, 0, 0) elif next_dir == 1: # down p += Vec(0, 0, 1) elif next_dir == 2: # left p += Vec(-1, 0, 0) else: # up p += Vec(0, 0, -1) prev_dir = next_dir color_num = (color_num + 1) % len(color_profile) for j in xrange(max_z - min_z + 1): for i in xrange(max_x - min_x + 1): p = self.parent.loc + Vec(min_x+i, min_y, min_z+j) self.parent.parent.setblock(p, self.mat) if i < width: i_adj = i else: i_adj = 2*width - 1 - i if j < depth: j_adj = j else: j_adj = 2*depth - 1 - j self.parent.parent.blocks[p].data = \ color_profile[points[i_adj][j_adj]] if not self.ruin: return # this chunk of code is copied from CheckerRug's render() method pn = perlin.SimplexNoise(256) c = self.parent.canvasCenter() y = self.parent.canvasHeight() r = random.randint(1, 1000) maxd = max(1, self.parent.canvasWidth(), self.parent.canvasLength()) for x in utils.iterate_points_inside_flat_poly(*self.parent.canvas): p = x+self.parent.loc d = ((Vec2f(x.x, x.z) - c).mag()) / maxd n = (pn.noise3((p.x+r) / 4.0, y / 4.0, p.z / 4.0) + 1.0) / 2.0 if (n < d): self.parent.parent.setblock(p, materials._floor) self.parent.parent.blocks[p].data = 0