Skip to content

Commit f200c9a

Browse files
Correctly mirror shape offsets when flipping
1 parent ad44089 commit f200c9a

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

crates/resource/src/shape_manager.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,16 @@ impl Shape {
109109

110110
let mut dst_rect = Rect::of(0, 0, src_rect.w, src_rect.h);
111111
dst_rect.translate(position.x, position.y);
112-
dst_rect.translate(-center.x, -center.y);
112+
113+
// Need to mirror the center offset if flipping
114+
let (mut offset_x, mut offset_y) = (center.x, center.y);
115+
if flip_horizontal {
116+
offset_x = src_rect.w - offset_x;
117+
}
118+
if flip_vertical {
119+
offset_y = src_rect.h - offset_y;
120+
}
121+
dst_rect.translate(-offset_x, -offset_y);
113122

114123
renderer.render_texture(&self.texture,
115124
Some(src_rect.into()),

src/ecs/system/action/move_to_position.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl System for MoveToPositionActionSystem {
5858
match unit.db(&self.empires).motion_params {
5959
Some(ref params) => {
6060
if params.walking_graphics[0].is_some() &&
61-
unit.graphic_id != params.walking_graphics[0] {
61+
unit.graphic_id != params.walking_graphics[0] {
6262
unit.set_graphic(params.walking_graphics[0])
6363
}
6464
let speed: Fixed = params.speed.into();

0 commit comments

Comments
 (0)