From 7fb83578b99aa224f7545f4118a46e84b58a9295 Mon Sep 17 00:00:00 2001 From: iamcheeseman <[hidden email]> Date: Mon, 12 Jan 2026 20:51:28 -0500 Subject: NEW ASSET SYSTEM WOOOOOOOOHOOOOOOOOOOOOOOOOOOOOOOOOO --- src/resources.odin | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) (limited to 'src/resources.odin') diff --git a/src/resources.odin b/src/resources.odin index 6120812..799ba75 100644 --- a/src/resources.odin +++ b/src/resources.odin @@ -19,9 +19,68 @@ Animation_Resource :: struct { tags: map[string]Tag_Resource, } -Map_Resource :: struct { +Object_Resource :: struct { + pos: Vec2, + parallax: Vec2, + properties: map[string]any, +} + +Room_Resource :: struct { + width: i32, + height: i32, + + tile_width: i32, + tile_height: i32, + + layers: [][]u32, + + objects: []Object_Resource, + + background_image: Maybe(Image_Id), +} + +Tile_Resource :: struct { + tileset: Tileset_Id, + rect: Rect, + + id: u32, + + collisions: []Rect, } Tileset_Resource :: struct { + tiles: []u32, + image: Image_Id, +} + +Room_Position_Resource :: struct { + id: Room_Id, + x: i32, + y: i32, + width: i32, + height: i32, } +get_image :: proc(id: Image_Id) -> rl.Texture2D { + img_res := &images[id] + + if !rl.IsTextureValid(img_res.texture) { + rl_img := rl.LoadImageFromMemory( + ".qoi", + raw_data(img_res.data), + i32(len(img_res.data)), + ) + if !rl.IsImageValid(rl_img) { + die("Could not load asset %v", id) + } + + img_res.texture = rl.LoadTextureFromImage(rl_img); + rl.UnloadImage(rl_img) + } + + return img_res.texture +} + +get_room :: proc(id: Room_Id) -> Room_Resource { + return rooms[id] +} -- cgit v1.3-2-g0d8e