diff options
| author | Xander Swan <[hidden email]> | 2026-01-07 23:12:22 -0500 |
|---|---|---|
| committer | Xander Swan <[hidden email]> | 2026-01-07 23:12:22 -0500 |
| commit | 0988ab832bfc7a1b1c851125b6172cf68c6d9cb9 (patch) | |
| tree | 460bc2d9f0bce463af273d6b2b2c20faa880ac29 /src | |
| parent | ade0dc4d257d053b7064184f193f8168c496e308 (diff) | |
doesn't compile but i'm commiting anywya
Diffstat (limited to 'src')
| -rwxr-xr-x | src/assets.odin | 78 | ||||
| -rw-r--r-- | src/resources.odin | 27 |
2 files changed, 105 insertions, 0 deletions
diff --git a/src/assets.odin b/src/assets.odin new file mode 100755 index 0000000..e74dcf8 --- /dev/null +++ b/src/assets.odin @@ -0,0 +1,78 @@ +#+feature dynamic-literals +package demonchime + +// DO NOT EDIT +// +// This file is autogenerated by tools/compile_assets +// All resource types are defined in 'src/resources.odin'. + +import rl "vendor:raylib" + +Image_Id :: enum { + TILESETS, + PLAYER, +} + +Animation_Id :: enum { + PLAYER, +} + +Map_Id :: enum { + ROOM_BEGIN_1, + ROOM_BEGIN, +} + +Tileset_Id :: enum { + TILESET, +} + +Resource_Id :: union { + Image_Id, + Animation_Id, + Map_Id, + Tileset_Id, +} + +images: [Image_Id]Image_Resource +animations: [Animation_Id]Animation_Resource +maps: [Map_Id]Map_Resource +tilesets: [Tileset_Id]Tileset_Resource + +path_to_id: map[string]Resource_Id + +load_resources :: proc() { + load_images() + load_anims() + load_maps() + load_tilesets() + + // 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 +} + +@(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")} +} + +@(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}}} +} + +@(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") +} + +@(private="file") +load_tilesets :: proc() { + tilesets[.TILESET] = #load("/home/xswan/demonchime/res/tileset.tsj") +} diff --git a/src/resources.odin b/src/resources.odin new file mode 100644 index 0000000..6120812 --- /dev/null +++ b/src/resources.odin @@ -0,0 +1,27 @@ +package demonchime + +import rl "vendor:raylib" + +Image_Resource :: struct { + texture: rl.Texture2D, + anim: Animation_Id, + data: []u8, +} + +Tag_Resource :: struct { + from: i32, + to: i32, +} + +Animation_Resource :: struct { + frame_count: i32, + frame_durations: []i32, + tags: map[string]Tag_Resource, +} + +Map_Resource :: struct { +} + +Tileset_Resource :: struct { +} + |
