mapgen2 icon indicating copy to clipboard operation
mapgen2 copied to clipboard

Hello please guide me

Open heart opened this issue 3 years ago • 1 comments

I follow from Readme

at the step

let triangles = [];
for (let s = 0; s < map.mesh.numSolidSides; s++) {
    let r = map.mesh.s_begin_r(s),
        t1 = map.mesh.s_inner_t(s),
        t2 = map.mesh.s_outer_t(s);
    triangles.push({
       biome: map.r_biome[r],
       indices: [
          map.r_pos([], r),
          map.t_pos([], t1),
          map.t_pos([], t2),
       ]
    });
}

I don't know how to draw or use the triangle coordinate that I get from here please give me some keyword to search or example code

heart avatar Nov 06 '21 10:11 heart

I think the indices array will be [[x1, y1], [x2, y2], [x3, y3]] and you can draw a triangle with those three vertices with whatever graphics library you are using. The biome will be one of the strings from biomes.js ('BEACH', 'GRASSLAND', etc.).

You'll want to loop over all the triangles and then draw each triangle in a color you choose for that biome.

I also have a tutorial at https://www.redblobgames.com/x/2022-voronoi-maps-tutorial/ that has a basic working example using voronoi (but not all the features of mapgen2.js).

redblobgames avatar Nov 07 '21 03:11 redblobgames