Basic animator and assetmanager using it.
This commit is contained in:
+18
-6
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user