Draw terrains within their relevant positions on the hex grid #22
|
@ -201,6 +201,7 @@ impl ObjectImpl for HexGridWindowPrivate {
|
|||
|
||||
context.set_line_width(2.);
|
||||
|
||||
/*
|
||||
deep_water.render_on_context(&context, 0., 0.);
|
||||
shallow_water.render_on_context(&context, 150., 0.);
|
||||
grasslands.render_on_context(&context, 300., 0.);
|
||||
|
@ -208,8 +209,8 @@ impl ObjectImpl for HexGridWindowPrivate {
|
|||
mountain.render_on_context(&context, 0., 100.);
|
||||
badlands.render_on_context(&context, 150., 100.);
|
||||
swamp.render_on_context(&context, 0., 200.);
|
||||
*/
|
||||
|
||||
/*
|
||||
for coordinate in vec![AxialAddr::origin()]
|
||||
.into_iter()
|
||||
.chain(AxialAddr::origin().addresses(MAP_RADIUS))
|
||||
|
@ -220,15 +221,22 @@ impl ObjectImpl for HexGridWindowPrivate {
|
|||
+ HEX_RADIUS
|
||||
* ((3. as f64).sqrt() / 2. * (coordinate.q() as f64)
|
||||
+ (3. as f64).sqrt() * (coordinate.r() as f64));
|
||||
let translate_x = center_x - HEX_RADIUS;
|
||||
let translate_y = center_y - (3. as f64).sqrt() * HEX_RADIUS / 2.;
|
||||
|
||||
let tile = hex_map.get(&coordinate).unwrap();
|
||||
let color = tile.color();
|
||||
context.set_source_rgb(color.0, color.1, color.2);
|
||||
|
||||
draw_hexagon(context, center_x, center_y, HEX_RADIUS);
|
||||
let _ = context.fill();
|
||||
let tile = match hex_map.get(&coordinate).unwrap() {
|
||||
Terrain::Mountain => &mountain,
|
||||
Terrain::Grasslands => &grasslands,
|
||||
Terrain::ShallowWater => &shallow_water,
|
||||
Terrain::DeepWater => &deep_water,
|
||||
Terrain::Badlands => &badlands,
|
||||
Terrain::Desert => &desert,
|
||||
Terrain::Swamp => &swamp,
|
||||
_ => panic!("unhandled terrain type"),
|
||||
};
|
||||
tile.render_on_context(context, translate_x, translate_y);
|
||||
// draw_hexagon(context, center_x, center_y, HEX_RADIUS);
|
||||
}
|
||||
*/
|
||||
});
|
||||
}
|
||||
self.drawing_area.add_controller(&motion_controller);
|
||||
|
|
Loading…
Reference in New Issue