def gen(width, height, screen): xs = list(range(width)) random.shuffle(xs) for x in xs: for y in range(height): value = Generate.terrain((x, y), (50, 150))[0] w = 128 + 127 * value color = (w, w, w) if value > -0.5: color = (255, w, w) else: color = (w, w, 255) #screen.set_at((x, y), color) pygame.draw.rect(screen, color, (x*2, y*2, 2, 2)) pygame.display.update() print("Generation complete")
def populate(self): #Fill in blocks of this chunk for y in range(len(self.foreground_blocks)): for x in range(len(self.foreground_blocks[y])): #surface_depth = self.heights[x] + 2 + random.randrange(4) if y < World.SEA_LEVEL: self.set_blocks_at(x, y, World.get_block("air")) else: world_x = Convert.chunk_to_world(x, self) noise = Generate.terrain((world_x, y), (self.biome["maxelevation"], self.biome["minelevation"])) self.set_blocks_from_noise(x, y, noise[0], False) self.set_blocks_from_noise(x, y, noise[1], True) """elif y < self.heights[x]: self.set_blocks_at(x, y, World.get_block("water")) elif y < surface_depth: self.set_blocks_at(x, y, World.get_block(self.biome["surface"])) else: self.set_blocks_at(x, y, World.get_block(self.biome["base"]))""" self.decorate()