From 10457b037d7d6635b730810f1119a67e01615c0f Mon Sep 17 00:00:00 2001 From: Stefan Stefanov Date: Sat, 8 Aug 2026 17:50:11 +0300 Subject: [PATCH] refactor --- src/animation.odin | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/animation.odin b/src/animation.odin index b4f8c8f..1f5d5ad 100644 --- a/src/animation.odin +++ b/src/animation.odin @@ -14,45 +14,45 @@ Animation :: struct { offset: rl.Vector2, } -update_animation :: proc(a: ^Animation) { - a.frame_timer += rl.GetFrameTime() +update_animation :: proc(animation: ^Animation) { + animation.frame_timer += rl.GetFrameTime() - if a.frame_timer > a.frame_length && !a.done { - a.current_frame += 1 - a.frame_timer = 0 + if animation.frame_timer > animation.frame_length && !animation.done { + animation.current_frame += 1 + animation.frame_timer = 0 - if a.current_frame == a.num_frames { - if a.loop { - a.current_frame = 0 + if animation.current_frame == animation.num_frames { + if animation.loop { + animation.current_frame = 0 } else { - a.current_frame += -1 - a.done = true + animation.current_frame += -1 + animation.done = true } } } } -draw_animation :: proc(a: Animation, pos: rl.Vector2) { - width := f32(a.texture.width) - height := f32(a.texture.height) +draw_animation :: proc(animation: Animation, position: rl.Vector2) { + width := f32(animation.texture.width) + height := f32(animation.texture.height) source := rl.Rectangle { - x = f32(a.current_frame) * width / f32(a.num_frames), + x = f32(animation.current_frame) * width / f32(animation.num_frames), y = 0, - width = width / f32(a.num_frames), + width = width / f32(animation.num_frames), height = height, } - if a.flip { + if animation.flip { source.width = -source.width } dest := rl.Rectangle { - x = pos.x + a.offset.x, - y = pos.y + a.offset.y, - width = width / f32(a.num_frames), + x = position.x + animation.offset.x, + y = position.y + animation.offset.y, + width = width / f32(animation.num_frames), height = height, } - rl.DrawTexturePro(a.texture, source, dest, {dest.width / 2, dest.height}, 0, rl.WHITE) + rl.DrawTexturePro(animation.texture, source, dest, {dest.width / 2, dest.height}, 0, rl.WHITE) }