Fixed animation now being the same when flipped
This commit is contained in:
@@ -48,40 +48,24 @@ draw_sprite_frame :: proc(
|
|||||||
widthf := f32(sprite.width)
|
widthf := f32(sprite.width)
|
||||||
heightf := f32(sprite.height)
|
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 {
|
source_rect := raylib.Rectangle {
|
||||||
x = src_x,
|
x = frame_pos.x * widthf,
|
||||||
y = src_y,
|
y = frame_pos.y * heightf,
|
||||||
width = src_width,
|
|
||||||
height = src_height,
|
|
||||||
}
|
|
||||||
|
|
||||||
dest_rect := raylib.Rectangle {
|
|
||||||
x = draw_pos.x,
|
|
||||||
y = draw_pos.y,
|
|
||||||
width = widthf,
|
width = widthf,
|
||||||
height = heightf,
|
height = heightf,
|
||||||
}
|
}
|
||||||
|
|
||||||
// origin := raylib.Vector2{widthf * 0.5, heightf * 0.5}
|
if flipX do source_rect.width *= -1
|
||||||
// dest_rect.x = draw_pos.x + widthf * 0.5
|
if flipY do source_rect.height *= -1
|
||||||
// dest_rect.y = draw_pos.y + heightf * 0.5
|
|
||||||
|
|
||||||
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)
|
raylib.DrawTexturePro(sprite.texture, source_rect, dest_rect, origin, 0.0, color)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user