Basic animator and assetmanager using it.

This commit is contained in:
2026-07-14 07:15:03 +02:00
parent e8b8dd2298
commit 7a4c562d6c
2 changed files with 76 additions and 6 deletions
+18 -6
View File
@@ -6,22 +6,34 @@
// -----------------------------------------------------------------------------
package game
// import rl "vendor:raylib"
import rl "vendor:raylib"
Player_Assets :: struct {
clips: [Player_State]AnimationClip,
}
Asset_Manager :: struct {
// Empty for now.
//player: rl.Texture2D,
player: Player_Assets,
}
asset_manager_init :: proc() -> Asset_Manager {
assets := Asset_Manager{}
// assets.player = rl.LoadTexture("assets/sprites/player.png")
idle_tex := rl.LoadTexture("assets/textures/player/player_idle.png")
walk_tex := rl.LoadTexture("assets/textures/player/player_walk.png")
assets.player.clips[.IDLE] = AnimationClip {
texture = idle_tex, frame_count = 6, frame_width = 32, frame_height = 32, frame_time = 0.14, looping = true,
}
assets.player.clips[.WALK] = AnimationClip {
texture = walk_tex, frame_count = 8, frame_width = 32, frame_height = 32, frame_time = 0.14, looping = true,
}
return assets
}
asset_manager_destroy :: proc(assets: ^Asset_Manager) {
// unload textures here later.
//rl.UnloadTexture(assets.player)
for clip in assets.player.clips {
rl.UnloadTexture(clip.texture)
}
}