Render the tiles in the correct space

This commit is contained in:
Savanni D'Gerinel 2023-02-11 21:55:58 -05:00
parent 8520b18629
commit ba9313d585
1 changed files with 16 additions and 8 deletions

View File

@ -201,6 +201,7 @@ impl ObjectImpl for HexGridWindowPrivate {
context.set_line_width(2.); context.set_line_width(2.);
/*
deep_water.render_on_context(&context, 0., 0.); deep_water.render_on_context(&context, 0., 0.);
shallow_water.render_on_context(&context, 150., 0.); shallow_water.render_on_context(&context, 150., 0.);
grasslands.render_on_context(&context, 300., 0.); grasslands.render_on_context(&context, 300., 0.);
@ -208,8 +209,8 @@ impl ObjectImpl for HexGridWindowPrivate {
mountain.render_on_context(&context, 0., 100.); mountain.render_on_context(&context, 0., 100.);
badlands.render_on_context(&context, 150., 100.); badlands.render_on_context(&context, 150., 100.);
swamp.render_on_context(&context, 0., 200.); swamp.render_on_context(&context, 0., 200.);
*/
/*
for coordinate in vec![AxialAddr::origin()] for coordinate in vec![AxialAddr::origin()]
.into_iter() .into_iter()
.chain(AxialAddr::origin().addresses(MAP_RADIUS)) .chain(AxialAddr::origin().addresses(MAP_RADIUS))
@ -220,15 +221,22 @@ impl ObjectImpl for HexGridWindowPrivate {
+ HEX_RADIUS + HEX_RADIUS
* ((3. as f64).sqrt() / 2. * (coordinate.q() as f64) * ((3. as f64).sqrt() / 2. * (coordinate.q() as f64)
+ (3. as f64).sqrt() * (coordinate.r() 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 tile = match hex_map.get(&coordinate).unwrap() {
let color = tile.color(); Terrain::Mountain => &mountain,
context.set_source_rgb(color.0, color.1, color.2); Terrain::Grasslands => &grasslands,
Terrain::ShallowWater => &shallow_water,
draw_hexagon(context, center_x, center_y, HEX_RADIUS); Terrain::DeepWater => &deep_water,
let _ = context.fill(); 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); self.drawing_area.add_controller(&motion_controller);