Fixed animation now being the same when flipped

This commit is contained in:
2026-02-15 17:32:35 -06:00
parent 7b19fbcf53
commit cc479131d8

View File

@@ -48,40 +48,24 @@ draw_sprite_frame :: proc(
widthf := f32(sprite.width)
heightf := f32(sprite.height)
src_width := widthf
src_height := heightf
src_x := frame_pos.x * widthf
src_y := frame_pos.y * heightf
if flipX {
src_width = -src_width
src_x += widthf
}
if flipY {
src_height = -src_height
src_y += heightf
}
source_rect := raylib.Rectangle {
x = src_x,
y = src_y,
width = src_width,
height = src_height,
}
dest_rect := raylib.Rectangle {
x = draw_pos.x,
y = draw_pos.y,
x = frame_pos.x * widthf,
y = frame_pos.y * heightf,
width = widthf,
height = heightf,
}
// origin := raylib.Vector2{widthf * 0.5, heightf * 0.5}
// dest_rect.x = draw_pos.x + widthf * 0.5
// dest_rect.y = draw_pos.y + heightf * 0.5
if flipX do source_rect.width *= -1
if flipY do source_rect.height *= -1
origin := raylib.Vector2{0, 0}
origin := raylib.Vector2{widthf / 2, heightf / 2}
dest_rect := raylib.Rectangle {
x = draw_pos.x + origin.x,
y = draw_pos.y + origin.y,
width = widthf,
height = heightf,
}
raylib.DrawTexturePro(sprite.texture, source_rect, dest_rect, origin, 0.0, color)
}