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/assets.odin | 106 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 72 insertions(+), 34 deletions(-) mode change 100755 => 100644 src/assets.odin (limited to 'src/assets.odin') diff --git a/src/assets.odin b/src/assets.odin old mode 100755 new mode 100644 index e74dcf8..b2222bb --- a/src/assets.odin +++ b/src/assets.odin @@ -15,11 +15,12 @@ Image_Id :: enum { Animation_Id :: enum { PLAYER, + NONE, } -Map_Id :: enum { - ROOM_BEGIN_1, +Room_Id :: enum { ROOM_BEGIN, + ROOM_BEGIN_1, } Tileset_Id :: enum { @@ -29,50 +30,87 @@ Tileset_Id :: enum { Resource_Id :: union { Image_Id, Animation_Id, - Map_Id, + Room_Id, Tileset_Id, } -images: [Image_Id]Image_Resource -animations: [Animation_Id]Animation_Resource -maps: [Map_Id]Map_Resource -tilesets: [Tileset_Id]Tileset_Resource +images: [Image_Id]Image_Resource = { + .TILESETS = {data = #load("../.compiled-res/tilesets.qoi"), anim = .NONE}, + .PLAYER = {data = #load("../.compiled-res/player-sheet.qoi"), anim = .PLAYER}, +} -path_to_id: map[string]Resource_Id +animations: [Animation_Id]Animation_Resource = { + .PLAYER = {frame_count = 23, frame_durations = {100, 100, 100, 100, 100, 100, 75, 75, 75, 75, 75, 75, 75, 75, 100, 100, 100, 100, 100, 100, 100, 100, 100}, tags = {"idle"={from = 0, to = 5}, "jump_trans"={from = 16, to = 16}, "run"={from = 6, to = 13}, "jump_down"={from = 17, to = 18}, "jump_up"={from = 14, to = 15}, "sleep"={from = 19, to = 22}}}, + .NONE = {frame_count=1, frame_durations={100}, tags={}}, +} -load_resources :: proc() { - load_images() - load_anims() - load_maps() - load_tilesets() +rooms: [Room_Id]Room_Resource = { + .ROOM_BEGIN = {width=30, height=20, tile_width=16, tile_height=16, layers={{40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 27, 31, 31, 19, 19, 28, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 21, 31, 31, 31, 11, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 27, 31, 19, 31, 19, 19, 19, 31, 19, 31, 19, 19, 17, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 21, 31, 31, 31, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 40, 40, 21, 19, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 21, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 32, 0, 0, 0, 0, 0, 0, 5, 9, 20, 9, 20, 20, 20, 18, 20, 20, 18, 18, 9, 18, 9, 18, 6, 0, 0, 0, 0, 0, 7, 32, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 8, 0, 0, 0, 0, 0, 7, 11, 0, 0, 0, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 38, 9, 9, 18, 18, 9, 39, 0, 0, 0, 5, 9, 20, 9, 44, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 0, 0, 0, 7, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 20, 9, 18, 39, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40}}, objects={}, background_image=nil}, + .ROOM_BEGIN_1 = {width=30, height=20, tile_width=16, tile_height=16, layers={{40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 21, 19, 19, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 40, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 27, 17, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 41, 9, 20, 20, 20, 18, 18, 18, 20, 8, 0, 0, 0, 0, 0, 0, 5, 18, 9, 9, 20, 20, 20, 18, 9, 18, 9, 18, 18, 9, 39, 40, 40, 40, 40, 40, 40, 40, 40, 43, 20, 20, 9, 20, 9, 9, 39, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40}}, objects={}, background_image=nil}, +} - // Allow conversion from paths to a resource id, since it's a better way to - // reference resources in other resources (JSON is a good example). - path_to_id["res/tileset.tsj"] = Tileset_Id.TILESET - path_to_id["res/img/player.ase"] = Image_Id.PLAYER - path_to_id["res/img/tilesets.png"] = Image_Id.TILESETS - path_to_id["res/room_begin.tmj"] = Map_Id.ROOM_BEGIN - path_to_id["res/room_begin_1.tmj"] = Map_Id.ROOM_BEGIN_1 +tilesets: [Tileset_Id]Tileset_Resource = { + .TILESET = {tiles={1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44}, image=.TILESETS}, } -@(private="file") -load_images :: proc() { - images[.TILESETS] = {data = #load("/home/xswan/demonchime/.compiled-res/tilesets.qoi")} - images[.PLAYER] = {data = #load("/home/xswan/demonchime/.compiled-res/player-sheet.qoi")} +tiles: []Tile_Resource = { + {tileset=.TILESET, rect=Rect{start = {0, 0}, size = {16, 16}}, id=1, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {16, 0}, size = {16, 16}}, id=2, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {32, 0}, size = {16, 16}}, id=3, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {48, 0}, size = {16, 16}}, id=4, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {64, 0}, size = {16, 16}}, id=5, collisions={Rect{start = {8, 8}, size = {8, 8}}}}, + {tileset=.TILESET, rect=Rect{start = {80, 0}, size = {16, 16}}, id=6, collisions={Rect{start = {0, 8}, size = {8, 8}}}}, + {tileset=.TILESET, rect=Rect{start = {96, 0}, size = {16, 16}}, id=7, collisions={Rect{start = {8, 0}, size = {8, 16}}}}, + {tileset=.TILESET, rect=Rect{start = {112, 0}, size = {16, 16}}, id=8, collisions={Rect{start = {0, 0}, size = {8, 16}}}}, + {tileset=.TILESET, rect=Rect{start = {128, 0}, size = {16, 16}}, id=9, collisions={Rect{start = {0, 8}, size = {16, 8}}}}, + {tileset=.TILESET, rect=Rect{start = {144, 0}, size = {16, 16}}, id=10, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {160, 0}, size = {16, 16}}, id=11, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {0, 16}, size = {16, 16}}, id=12, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {16, 16}, size = {16, 16}}, id=13, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {32, 16}, size = {16, 16}}, id=14, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {48, 16}, size = {16, 16}}, id=15, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {64, 16}, size = {16, 16}}, id=16, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {80, 16}, size = {16, 16}}, id=17, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {96, 16}, size = {16, 16}}, id=18, collisions={Rect{start = {0, 8}, size = {16, 8}}}}, + {tileset=.TILESET, rect=Rect{start = {112, 16}, size = {16, 16}}, id=19, collisions={Rect{start = {0, 0}, size = {16, 8}}}}, + {tileset=.TILESET, rect=Rect{start = {128, 16}, size = {16, 16}}, id=20, collisions={Rect{start = {0, 8}, size = {16, 8}}}}, + {tileset=.TILESET, rect=Rect{start = {144, 16}, size = {16, 16}}, id=21, collisions={Rect{start = {8, 0}, size = {8, 8}}, Rect{start = {0, 8}, size = {8, 8}}}}, + {tileset=.TILESET, rect=Rect{start = {160, 16}, size = {16, 16}}, id=22, collisions={Rect{start = {8, 8}, size = {8, 8}}, Rect{start = {0, 0}, size = {8, 8}}}}, + {tileset=.TILESET, rect=Rect{start = {0, 32}, size = {16, 16}}, id=23, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {16, 32}, size = {16, 16}}, id=24, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {32, 32}, size = {16, 16}}, id=25, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {48, 32}, size = {16, 16}}, id=26, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {64, 32}, size = {16, 16}}, id=27, collisions={Rect{start = {8, 0}, size = {8, 8}}, Rect{start = {0, 8}, size = {8, 8}}}}, + {tileset=.TILESET, rect=Rect{start = {80, 32}, size = {16, 16}}, id=28, collisions={Rect{start = {8, 8}, size = {8, 8}}, Rect{start = {0, 0}, size = {8, 8}}}}, + {tileset=.TILESET, rect=Rect{start = {96, 32}, size = {16, 16}}, id=29, collisions={Rect{start = {0, 8}, size = {8, 8}}}}, + {tileset=.TILESET, rect=Rect{start = {112, 32}, size = {16, 16}}, id=30, collisions={Rect{start = {8, 8}, size = {8, 8}}}}, + {tileset=.TILESET, rect=Rect{start = {128, 32}, size = {16, 16}}, id=31, collisions={Rect{start = {0, 0}, size = {16, 8}}}}, + {tileset=.TILESET, rect=Rect{start = {144, 32}, size = {16, 16}}, id=32, collisions={Rect{start = {0, 0}, size = {8, 16}}}}, + {tileset=.TILESET, rect=Rect{start = {160, 32}, size = {16, 16}}, id=33, collisions={Rect{start = {8, 0}, size = {8, 16}}}}, + {tileset=.TILESET, rect=Rect{start = {0, 48}, size = {16, 16}}, id=34, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {16, 48}, size = {16, 16}}, id=35, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {32, 48}, size = {16, 16}}, id=36, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {48, 48}, size = {16, 16}}, id=37, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {64, 48}, size = {16, 16}}, id=38, collisions={Rect{start = {0, 8}, size = {16, 8}}, Rect{start = {0, 0}, size = {8, 8}}}}, + {tileset=.TILESET, rect=Rect{start = {80, 48}, size = {16, 16}}, id=39, collisions={Rect{start = {0, 8}, size = {16, 8}}, Rect{start = {8, 0}, size = {8, 8}}}}, + {tileset=.TILESET, rect=Rect{start = {96, 48}, size = {16, 16}}, id=40, collisions={}}, + {tileset=.TILESET, rect=Rect{start = {112, 48}, size = {16, 16}}, id=41, collisions={Rect{start = {8, 8}, size = {8, 8}}}}, + {tileset=.TILESET, rect=Rect{start = {128, 48}, size = {16, 16}}, id=42, collisions={Rect{start = {0, 8}, size = {8, 8}}}}, + {tileset=.TILESET, rect=Rect{start = {144, 48}, size = {16, 16}}, id=43, collisions={Rect{start = {0, 8}, size = {16, 8}}, Rect{start = {0, 0}, size = {8, 8}}}}, + {tileset=.TILESET, rect=Rect{start = {160, 48}, size = {16, 16}}, id=44, collisions={Rect{start = {0, 8}, size = {16, 8}}, Rect{start = {8, 0}, size = {8, 8}}}}, } -@(private="file") -load_anims :: proc() { - animations[.PLAYER] = {frame_count = 23, frame_durations = {100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100}, tags = {"jump_trans"={from = 16, to = 16}, "jump_down"={from = 17, to = 18}, "idle"={from = 0, to = 5}, "sleep"={from = 19, to = 22}, "jump_up"={from = 14, to = 15}, "run"={from = 6, to = 13}}} +world: []Room_Position_Resource = { + {id=.ROOM_BEGIN_1, x=-528, y=-64, width=480, height=320}, + {id=.ROOM_BEGIN, x=-48, y=-64, width=480, height=320}, } -@(private="file") -load_maps :: proc() { - maps[.ROOM_BEGIN_1] = #load("/home/xswan/demonchime/res/room_begin_1.tmj") - maps[.ROOM_BEGIN] = #load("/home/xswan/demonchime/res/room_begin.tmj") +path_to_id: map[string]Resource_Id = { + "res/img/player.ase" = Image_Id.PLAYER, + "res/img/tilesets.png" = Image_Id.TILESETS, + "res/room_begin.tmj" = Room_Id.ROOM_BEGIN, + "res/room_begin_1.tmj" = Room_Id.ROOM_BEGIN_1, } -@(private="file") -load_tilesets :: proc() { - tilesets[.TILESET] = #load("/home/xswan/demonchime/res/tileset.tsj") +load_resources :: proc() { } -- cgit v1.3-2-g0d8e