Method: Worldgen::PlateMap#to_height_map

Defined in:
lib/worldgen/platemap.rb

#to_height_map(sea_gap) ⇒ Object

Convert to a height map - very simple, just give the continents one height and the oceans another height. This is controlled by a single parameter, ((sea_gap)), which will be the difference between the continents height and oceans height.



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/worldgen/platemap.rb', line 102

def to_height_map sea_gap
  raise "Sea gap should be between 0 and 1" if sea_gap < 0 or sea_gap > 1

  plate_heights = @plates.map do |plate|
    if plate.type == :continent
      0.5 + sea_gap / 2
    else
      0.5 - sea_gap / 2
    end
  end

  map = HeightMap.new @size
  
  each_plate_point do |x, y, id|
    map[x, y] = plate_heights[id]
  end

  map
end