From d6f276be6bc1214c88cfc5346ceb7a5bea610638 Mon Sep 17 00:00:00 2001 From: iamcheeseman <[hidden email]> Date: Wed, 14 Jan 2026 19:21:33 -0500 Subject: i HATE physics bugs (i haven't fixed them yet) --- src/draw/animation.odin | 86 ------------------------------- src/draw/draw.odin | 134 ------------------------------------------------ src/draw/sprite.odin | 5 -- 3 files changed, 225 deletions(-) delete mode 100644 src/draw/animation.odin delete mode 100644 src/draw/draw.odin delete mode 100644 src/draw/sprite.odin (limited to 'src/draw') diff --git a/src/draw/animation.odin b/src/draw/animation.odin deleted file mode 100644 index a59fe5f..0000000 --- a/src/draw/animation.odin +++ /dev/null @@ -1,86 +0,0 @@ -package draw - -import "core:encoding/json" -import "core:log" -import "core:os" -import "core:path/filepath" -import "core:strings" - -FrameRect :: struct { - x: i32 `json:"x"`, - y: i32 `json:"y"`, - w: i32 `json:"w"`, - h: i32 `json:"h"`, -} - -Frame :: struct { - rect: FrameRect `json:"frame"`, - duration: i32 `json:"duration"`, -} - -Tag :: struct { - name: string `json:"name"`, - from: i32 `json:"from"`, - to: i32 `json:"to"`, - direction: string `json:"direction"`, -} - -AnimationMeta :: struct { - image_path: string `json:"image"`, - frame_tags: []Tag `json:"frameTags"`, - frame_tags_indices: map[string]u32, -} - -Animation :: struct { - frames: []Frame `json:"frames"`, - using meta: AnimationMeta `json:"meta"`, -} - -@(require_results) -init_anim_data :: proc(anim: ^Animation, path: string) -> bool { - data, ok := os.read_entire_file(path) - if !ok { - return false - } - defer delete(data) - - json_err := json.unmarshal(data, anim) - if json_err != nil { - log.error("could not unmarshal data") - return false - } - - for tag, i in anim.frame_tags { - anim.frame_tags_indices[tag.name] = u32(i) - } - - partial_img_path := anim.image_path - defer delete(partial_img_path) - anim_dir := filepath.dir(path) - defer delete(anim_dir) - - anim.image_path = strings.concatenate({anim_dir, "/", partial_img_path}) - - log.debugf("loaded animation '%v'", path) - - return true -} - -delete_anim_data :: proc(anim: Animation) { - delete(anim.frames) - - for tag in anim.frame_tags { - delete(tag.name) - delete(tag.direction) - } - - // sg.destroy_image(anim.image) - - delete(anim.frame_tags) - delete(anim.frame_tags_indices) - delete(anim.image_path) -} - -get_anim_tag :: proc(anim: Animation, tag_name: string) -> Tag { - return anim.frame_tags[anim.frame_tags_indices[tag_name]] -} diff --git a/src/draw/draw.odin b/src/draw/draw.odin deleted file mode 100644 index 75071f3..0000000 --- a/src/draw/draw.odin +++ /dev/null @@ -1,134 +0,0 @@ -package draw - -import "core:c" -import "core:math" - -import rl "vendor:raylib" - -Vec2 :: [2]f32 -Vec3 :: [3]f32 - -Rect :: struct { - start: Vec2, - size: Vec2, -} - -Mat4 :: matrix[4, 4]f32 - -Color :: [4]f32 - -SCREEN_WIDTH :: 480 -SCREEN_HEIGHT :: 320 - -renderer: struct { - screen: rl.RenderTexture2D, - tint: Color, -} - -@(private) -_color_to_rl :: proc(col: Color) -> rl.Color { - return rl.Color { - u8(col.r * 255), - u8(col.g * 255), - u8(col.b * 255), - u8(col.a * 255), - } -} - -init :: proc() { - renderer.screen = rl.LoadRenderTexture(SCREEN_WIDTH, SCREEN_HEIGHT) - renderer.tint = Color{1, 1, 1, 1} -} - -deinit :: proc() { - rl.UnloadRenderTexture(renderer.screen) -} - -new_frame :: proc() { - rl.BeginTextureMode(renderer.screen) - rl.ClearBackground(_color_to_rl(Color{0.2, 0.2, 0.2, 1})) -} - -end_frame :: proc() { - rl.EndTextureMode() - - rl.BeginDrawing() - { - rl.ClearBackground(_color_to_rl(Color{0, 0, 0, 1})) - scale := math.min( - f32(rl.GetScreenWidth()) / f32(SCREEN_WIDTH), - f32(rl.GetScreenHeight()) / f32(SCREEN_HEIGHT), - ) - screen_start := Vec2 { - (f32(rl.GetScreenWidth()) - (SCREEN_WIDTH * scale)) / 2, - (f32(rl.GetScreenHeight()) - (SCREEN_HEIGHT * scale)) / 2, - } - - texture_full( - renderer.screen.texture, - screen_start, - scale = Vec2{scale, scale}, - ) - } - rl.EndDrawing() -} - -rect :: proc(rect: Rect) { - assert(rect.size.x > 0 && rect.size.y > 0) - - rl.DrawRectangle( - c.int(rect.start.x), - c.int(rect.start.y), - c.int(rect.size.x), - c.int(rect.size.y), - _color_to_rl(renderer.tint), - ) -} - -texture :: proc { - texture_full, - texture_quad, -} - -texture_quad :: proc( - img: rl.Texture2D, - quad: Rect, - position: Vec2, - offset := Vec2{0, 0}, - rotation: f32 = 0, - scale := Vec2{1, 1}, -) { - quad := quad - if scale.x < 0 { - quad.size.x *= -1 - } - if scale.y < 0 { - quad.size.y *= -1 - } - - rl.DrawTexturePro( - img, - transmute(rl.Rectangle)quad, - rl.Rectangle { - position.x, - position.y, - quad.size.x * scale.x, - quad.size.y * scale.y, - }, - offset, - rotation, - _color_to_rl(renderer.tint), - ) -} - -texture_full :: proc( - img: rl.Texture2D, - position: Vec2, - offset := Vec2{0, 0}, - rotation: f32 = 0, - scale := Vec2{1, 1}, -) { - size := Vec2{f32(img.width), -f32(img.height)} - - texture_quad(img, Rect{Vec2{0, 0}, size}, position, offset, rotation, scale) -} diff --git a/src/draw/sprite.odin b/src/draw/sprite.odin deleted file mode 100644 index f7cd87b..0000000 --- a/src/draw/sprite.odin +++ /dev/null @@ -1,5 +0,0 @@ -package draw - -import "core:log" - -import rl "vendor:raylib" -- cgit v1.3-2-g0d8e