Re-fix map orientation.

This commit is contained in:
Joshua Yanovski 2020-01-12 00:04:15 +01:00
parent 16c24e86b3
commit 14e4dfb53f
3 changed files with 12 additions and 9 deletions

View File

@ -111,12 +111,15 @@ impl Client {
let mut world_map_raw = vec![0u8; 4 * world_map.len()/*map_size.x * map_size.y*/];
LittleEndian::write_u32_into(&world_map, &mut world_map_raw);
log::debug!("Preparing image...");
let world_map = Arc::new(image::DynamicImage::ImageRgba8({
// Should not fail if the dimensions are correct.
let world_map =
image::ImageBuffer::from_raw(map_size.x, map_size.y, world_map_raw);
world_map.ok_or(Error::Other("Server sent a bad world map image".into()))?
}));
let world_map = Arc::new(
image::DynamicImage::ImageRgba8({
// Should not fail if the dimensions are correct.
let world_map =
image::ImageBuffer::from_raw(map_size.x, map_size.y, world_map_raw);
world_map.ok_or(Error::Other("Server sent a bad world map image".into()))?
})
.flipv(),
);
log::debug!("Done preparing image...");
(state, entity, server_info, (world_map, map_size))

View File

@ -177,8 +177,8 @@ impl<'a> Widget for Map<'a> {
.get(self.client.entity())
.map_or(Vec3::zero(), |pos| pos.0);
let x = player_pos.x as f64 / worldsize.x * 700.0;
let y = (1.0 - player_pos.y as f64 / worldsize.y) * 700.0;
let x = player_pos.x as f64 / worldsize.x * 700.0/*= x-Size of the map image*/;
let y = player_pos.y as f64 / worldsize.y * 700.0;
let indic_ani = (self.pulse * 6.0/*animation speed*/).cos()/*starts at 1.0*/ * 0.5 + 0.50; // changes the animation frame
let indic_scale = 1.2;
// Indicator

View File

@ -152,7 +152,7 @@ impl<'a> Widget for MiniMap<'a> {
.map_or(Vec3::zero(), |pos| pos.0);
let x = player_pos.x as f64 / worldsize.x * 92.0 * 4.0;
let y = (1.0 - player_pos.y as f64 / worldsize.y) * 82.0 * 4.0;
let y = player_pos.y as f64 / worldsize.y * 82.0 * 4.0;
let indic_ani = (self.pulse * 6.0).cos() * 0.5 + 0.5; //Animation timer
let indic_scale = 0.8;
// Indicator