Exemple #1
0
    def make_puddles(self):
        for y in range(self.height):
            for x in range(self.width):
                ripple = (snoise2(x / 4, y / 4, 1) + 8) / 8
                n = self.heightmap[x][y]
                if n <= 0.2:
                    self.color_array[x][y] = shade_color(
                        (20, 110, 140), light=(ripple + 1) / 2
                    )
                elif n <= 0.5:
                    self.color_array[x][y] = shade_color(
                        (30, 120, 170), light=(ripple + 1) / 2
                    )
                elif n < 0.7:
                    self.color_array[x][y] = shade_color(
                        (100, 165, 205), light=(ripple + 1) / 2
                    )
                elif n < 1:
                    c = alpha_blend_color(
                        self.color_array[x][y],
                        (100, 75, 60), 0.7
                    )
                    self.color_array[x][y] = c

                if n < 0.7:
                    self.blocked_grid[x][y] = True
Exemple #2
0
 def make_rocks(self):
     seed = self.seed * 3
     octaves = 1
     freq = 16.
     for y in range(self.height):
         for x in range(self.width):
             if not self.blocked_grid[x][y]:
                 n = pnoise3(
                     x / freq, y / freq, seed, octaves=octaves
                 ) * 8 + 4
                 if not random.randint(0, 3):
                     ripple = (snoise2(x / 4, y / 4, 1) + 2) / 2
                 else:
                     ripple = 1
                 if n <= 0.1:
                     self.color_array[x][y] = shade_color(
                         (120, 120, 120), ripple
                     )
                 elif n <= 0.3:
                     self.color_array[x][y] = (110, 110, 110)
                 elif n <= 0.5:
                     self.color_array[x][y] = (100, 100, 100)
                 elif n < 0.8:
                     self.color_array[x][y] = (90, 90, 90)
             # elif n < 1:
             #     self.color_array[x][y] = alpha_blend_color(
             #         self.color_array[x][y], (120, 120, 120), 0.7
             #     )
                 if n < 0.8:
                     self.blocked_grid[x][y] = True
Exemple #3
0
 def make_grass(self):
     octaves = random.uniform(0.5, 0.8)
     freq = 4.0 * octaves
     mx, mn = 0, 0
     for y in range(self.height):
         for x in range(self.width):
             value = (snoise2(x / freq, y / freq, 1) + 8) / 8
             self.color_array[x][y] = shade_color(
                 (75, 200, 15), light=value
             )
             n = self.heightmap[x][y]
             if n > mx:
                 mx = n
             c = self.color_array[x][y]
             if n >= 7.:
                 self.color_array[x][y] = shade_color(
                     c, light=1.4
                 )
             elif n >= 6:
                 self.color_array[x][y] = shade_color(
                     c, light=1.3
                 )
             elif n >= 5:
                 self.color_array[x][y] = shade_color(
                     c, light=1.2
                 )
             elif n >= 4:
                 self.color_array[x][y] = shade_color(
                     c, light=1.1
                 )
             elif n >= 3:
                 pass
             elif n >= 2.5:
                 self.color_array[x][y] = shade_color(
                     c, light=0.9
                 )
             elif n >= 2:
                 self.color_array[x][y] = shade_color(
                     c, light=0.8
                 )
             elif n >= 1.5:
                 self.color_array[x][y] = shade_color(
                     c, light=0.7
                 )
             elif n > 1.:
                 self.color_array[x][y] = shade_color(
                     c, light=0.6
                 )
Exemple #4
0
 def draw_path(self):
     c = (100, 85, 50)
     for x, y in self.console:
         if self.path_grid[x][y]:
             if self.path_grid[x][y] > 0.05:
                 if self.check_on_screen(x, y):
                     if self.path_grid[x][y] > 0.95:
                         a = 0.98
                     else:
                         a = self.path_grid[x][y]
                     value = (snoise2(x / 2, y / 2, 1) + 8) / 8
                     new_c = shade_color(
                         c, light=value
                     )
                     new_c = alpha_blend_color(
                         self.color_array[x][y], new_c, a
                     )
                     self.path_console.draw_char(
                         x, y, None, bg=new_c
                     )