diff --git a/src/game.odin b/src/game.odin index b1ff9ba..0df7608 100644 --- a/src/game.odin +++ b/src/game.odin @@ -448,7 +448,6 @@ open_file_dialog :: proc() { fmt.println("Got an empty path from the file dialog!") } - case .OutputFolder: file := cstring( diag.select_folder_dialog( diff --git a/src/math.odin b/src/math.odin deleted file mode 100644 index 4f6634c..0000000 --- a/src/math.odin +++ /dev/null @@ -1,8 +0,0 @@ -package game - -Vec2i :: [2]int -Vec2 :: [2]f32 - -vec2_from_vec2i :: proc(p: Vec2i) -> Vec2 { - return {f32(p.x), f32(p.y)} -} diff --git a/src/raylib_helpers.odin b/src/raylib_helpers.odin deleted file mode 100644 index d884fc4..0000000 --- a/src/raylib_helpers.odin +++ /dev/null @@ -1,70 +0,0 @@ -package game - -import "core:slice" -import rl "vendor:raylib" - -Texture :: rl.Texture -Color :: rl.Color - -texture_rect :: proc(tex: Texture, flip_x: bool) -> Rect { - return( - { - x = 0, - y = 0, - width = flip_x ? -f32(tex.width) : f32(tex.width), - height = f32(tex.height), - } \ - ) -} - -load_premultiplied_alpha_ttf_from_memory :: proc(file_data: []byte, font_size: int) -> rl.Font { - font := rl.Font { - baseSize = i32(font_size), - glyphCount = 95, - } - - font.glyphs = rl.LoadFontData( - &file_data[0], - i32(len(file_data)), - font.baseSize, - {}, - font.glyphCount, - .DEFAULT, - ) - - if font.glyphs != nil { - font.glyphPadding = 4 - - atlas := rl.GenImageFontAtlas( - font.glyphs, - &font.recs, - font.glyphCount, - font.baseSize, - font.glyphPadding, - 0, - ) - atlas_u8 := slice.from_ptr((^u8)(atlas.data), int(atlas.width * atlas.height * 2)) - - for i in 0 ..< atlas.width * atlas.height { - a := atlas_u8[i * 2 + 1] - v := atlas_u8[i * 2] - atlas_u8[i * 2] = u8(f32(v) * (f32(a) / 255)) - } - - font.texture = rl.LoadTextureFromImage(atlas) - rl.SetTextureFilter(font.texture, .BILINEAR) - - // Update glyphs[i].image to use alpha, required to be used on ImageDrawText() - for i in 0 ..< font.glyphCount { - rl.UnloadImage(font.glyphs[i].image) - font.glyphs[i].image = rl.ImageFromImage(atlas, font.recs[i]) - } - //TRACELOG(LOG_INFO, "FONT: Data loaded successfully (%i pixel size | %i glyphs)", font.baseSize, font.glyphCount); - - rl.UnloadImage(atlas) - } else { - font = rl.GetFontDefault() - } - - return font -} diff --git a/src/rect.odin b/src/rect.odin deleted file mode 100644 index 4291aa2..0000000 --- a/src/rect.odin +++ /dev/null @@ -1,66 +0,0 @@ -// procs for modifying and managing rects - -package game - -import rl "vendor:raylib" - -Rect :: rl.Rectangle - -RectEmpty :: Rect{} - -split_rect_top :: proc(r: Rect, y: f32, m: f32) -> (top, bottom: Rect) { - top = r - bottom = r - top.y += m - top.height = y - bottom.y += y + m - bottom.height -= y + m - return -} - -split_rect_left :: proc(r: Rect, x: f32, m: f32) -> (left, right: Rect) { - left = r - right = r - left.width = x - right.x += x + m - right.width -= x + m - return -} - -split_rect_bottom :: proc(r: rl.Rectangle, y: f32, m: f32) -> (top, bottom: rl.Rectangle) { - top = r - top.height -= y + m - bottom = r - bottom.y = top.y + top.height + m - bottom.height = y - return -} - -split_rect_right :: proc(r: Rect, x: f32, m: f32) -> (left, right: Rect) { - left = r - right = r - right.width = x - left.width -= x + m - right.x = left.x + left.width - return -} - -rect_middle :: proc(r: Rect) -> Vec2 { - return {r.x + f32(r.width) * 0.5, r.y + f32(r.height) * 0.5} -} - -inset_rect :: proc(r: Rect, x: f32, y: f32) -> Rect { - return {r.x + x, r.y + y, r.width - x * 2, r.height - y * 2} -} - -rect_add_pos :: proc(r: Rect, p: Vec2) -> Rect { - return {r.x + p.x, r.y + p.y, r.width, r.height} -} - -mouse_in_rect :: proc(r: Rect) -> bool { - return rl.CheckCollisionPointRec(rl.GetMousePosition(), r) -} - -mouse_in_world_rect :: proc(r: Rect, camera: rl.Camera2D) -> bool { - return rl.CheckCollisionPointRec(rl.GetScreenToWorld2D(rl.GetMousePosition(), camera), r) -} diff --git a/src/animation.odin b/src/utils/animation.odin similarity index 98% rename from src/animation.odin rename to src/utils/animation.odin index aeeaed5..4a55c6e 100644 --- a/src/animation.odin +++ b/src/utils/animation.odin @@ -4,7 +4,7 @@ // `animation_rect` when you wish to know the source rect to use in the texture // With the source rect you can run rl.DrawTextureRec to draw the current frame. -package game +package utils import "core:log" diff --git a/src/handle_array.odin b/src/utils/handle_array.odin similarity index 99% rename from src/handle_array.odin rename to src/utils/handle_array.odin index 69d9709..b6b59d1 100644 --- a/src/handle_array.odin +++ b/src/utils/handle_array.odin @@ -3,7 +3,7 @@ // that makes sure you don't get bugs when slots are re-used. // Read more about it here: https://floooh.github.io/2018/06/17/handles-vs-pointers.html */ -package game +package utils Handle :: struct($T: typeid) { // idx 0 means unused. Note that slot 0 is a dummy slot, it can never be used. diff --git a/src/helpers.odin b/src/utils/helpers.odin similarity index 87% rename from src/helpers.odin rename to src/utils/helpers.odin index 190d044..6f07e8b 100644 --- a/src/helpers.odin +++ b/src/utils/helpers.odin @@ -1,6 +1,6 @@ // generic odin helpers -package game +package utils import "core:intrinsics" import "core:reflect" @@ -39,3 +39,10 @@ remap :: proc "contextless" ( } return clamp(((old_value - old_min) / old_range) * new_range + new_min, new_min, new_max) } + +Vec2i :: [2]int +Vec2 :: [2]f32 + +vec2_from_vec2i :: proc(p: Vec2i) -> Vec2 { + return {f32(p.x), f32(p.y)} +} \ No newline at end of file