aboutsummaryrefslogtreecommitdiff
path: root/src/resources.odin
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources.odin')
-rw-r--r--src/resources.odin61
1 files changed, 60 insertions, 1 deletions
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]
+}