refactor
This commit is contained in:
parent
2e9b930783
commit
848852ac05
1 changed files with 10 additions and 10 deletions
|
|
@ -32,27 +32,27 @@ update_animation :: proc(a: ^Animation) {
|
|||
}
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue