diff --git a/.focus-config b/.focus-config index 6d578f8..8b920f3 100644 --- a/.focus-config +++ b/.focus-config @@ -1,4 +1,4 @@ -[6] # Version number. Do not delete. +[18] # Version number. Do not delete. [[workspace]] # These directories and files will be scanned when a workspace is opened so that search etc. works. @@ -26,13 +26,7 @@ build_command: jai build.jai build_command: arch -x86_64 /opt/jai/bin/jai-macos build.jai key_binding: Cmd-Shift-B -[Run MacOS] -run_working_dir: . -run_command: term.scpt "cd %RUN_WORKING_DIR%/build_debug && ./console3d" -key_binding: F5 - - [[settings]] tab_size: 4 -insert_spaces_when_pressing_tab: true +indent_using: spaces # options: spaces, tabs strip_trailing_whitespace_on_save: except_lines_with_cursor # options: all, except_lines_with_cursor, disabled diff --git a/modules/Console_Render/module.jai b/modules/Console_Render/module.jai index 9ad70c4..3d07385 100644 --- a/modules/Console_Render/module.jai +++ b/modules/Console_Render/module.jai @@ -105,9 +105,7 @@ maybe_resize_screen :: (screen: *Screen) { } #load "draw.jai"; -#load "rotate.jai"; -#load "scale.jai"; -#load "translate.jai"; +#load "transform.jai"; #load "file_operations.jai"; #load "console.jai"; #load "math_extras.jai"; diff --git a/modules/Console_Render/scale.jai b/modules/Console_Render/scale.jai deleted file mode 100644 index d38e745..0000000 --- a/modules/Console_Render/scale.jai +++ /dev/null @@ -1,14 +0,0 @@ -scale :: (factor: Vector2, pn: ..*Vec2s64) { - for pn { - it.x = cast(s64)(it.x * factor.x); - it.y = cast(s64)(it.y * factor.y); - } -} - -scale :: (factor: Vector2, t: *Triangle) { - scale(factor, *t.p1, *t.p2, *t.p3); -} - -scale :: (factor: Vector2, q: *Quad) { - scale(factor, *q.p1, *q.p2, *q.p3, *q.p4); -} \ No newline at end of file diff --git a/modules/Console_Render/rotate.jai b/modules/Console_Render/transform.jai similarity index 54% rename from modules/Console_Render/rotate.jai rename to modules/Console_Render/transform.jai index 0293a31..935de2a 100644 --- a/modules/Console_Render/rotate.jai +++ b/modules/Console_Render/transform.jai @@ -1,3 +1,22 @@ +// for n points +translate :: (amount: Vec2s64, pn: ..*Vec2s64) { + for pn { + it.x += amount.x; + it.y += amount.y; + } +} + +// for a triangle +translate :: (amount: Vec2s64, t: *Triangle) { + translate(amount, *t.p1, *t.p2, *t.p3); +} + + +// for a quad +translate :: (amount: Vec2s64, q: *Quad) { + translate(amount, *q.p1, *q.p2, *q.p3, *q.p4); +} + // single point rotation rotate :: (angle: s64, center: Vec2s64, p: *Vec2s64) { rad := cast(float64)angle * (PI / 180.0); @@ -30,4 +49,19 @@ rotate :: (angle: s64, center: Vec2s64, t: *Triangle) { // rotate 4 points via quad struct rotate :: (angle: s64, center: Vec2s64, q: *Quad) { rotate(angle, center, *q.p1, *q.p2, *q.p3, *q.p4); +} + +scale :: (factor: Vector2, pn: ..*Vec2s64) { + for pn { + it.x = cast(s64)(it.x * factor.x); + it.y = cast(s64)(it.y * factor.y); + } +} + +scale :: (factor: Vector2, t: *Triangle) { + scale(factor, *t.p1, *t.p2, *t.p3); +} + +scale :: (factor: Vector2, q: *Quad) { + scale(factor, *q.p1, *q.p2, *q.p3, *q.p4); } \ No newline at end of file diff --git a/modules/Console_Render/translate.jai b/modules/Console_Render/translate.jai deleted file mode 100644 index 4de296d..0000000 --- a/modules/Console_Render/translate.jai +++ /dev/null @@ -1,18 +0,0 @@ -// for n points -translate :: (amount: Vec2s64, pn: ..*Vec2s64) { - for pn { - it.x += amount.x; - it.y += amount.y; - } -} - -// for a triangle -translate :: (amount: Vec2s64, t: *Triangle) { - translate(amount, *t.p1, *t.p2, *t.p3); -} - - -// for a quad -translate :: (amount: Vec2s64, q: *Quad) { - translate(amount, *q.p1, *q.p2, *q.p3, *q.p4); -} diff --git a/src/main.jai b/src/main.jai index 399bab2..fdcaa57 100644 --- a/src/main.jai +++ b/src/main.jai @@ -22,10 +22,10 @@ main :: () { fill_entire_screen(screen, BLANK_PIXEL); // cool_demo_2(screen, offset, theta); - // cool_demo_1(screen, offset, theta); - dvd_logo_bounce(screen); + cool_demo_1(screen, offset, theta); + // dvd_logo_bounce(screen); - annoying_color_effect(screen, offset); + // annoying_color_effect(screen, offset); swap_buffer(screen); sleep_milliseconds(20); @@ -47,7 +47,7 @@ annoying_color_effect :: (screen: *Screen, modifier: s64) { cool_demo_1 :: (screen: *Screen, offset: s64, theta: s64) { t1 := Triangle.{ .{30 - offset, 20}, - .{95, 10 - (offset / 2)}, + .{95, 10 - (offset / 2)}, .{90 + offset, 40}, }; @@ -64,16 +64,8 @@ cool_demo_1 :: (screen: *Screen, offset: s64, theta: s64) { // draw centroid lines draw_text(screen, get_triangle_centroid(t2), " [ TEXT-BASED RENDERING DEMO ]"); - draw_line(screen, get_triangle_centroid(t1), get_triangle_centroid(t2), #char "."); - // draw_line(screen, get_triangle_centroid(t1), t1.p1, #char "."); - // draw_line(screen, get_triangle_centroid(t1), t1.p2, #char "."); - // draw_line(screen, get_triangle_centroid(t1), t1.p3, #char ".");18 - // draw_line(screen, get_triangle_centroid(t2), t2.p1, #char "."); - // draw_line(screen, get_triangle_centroid(t2), t2.p2, #char "."); - // draw_line(screen, get_triangle_centroid(t2), t2.p3, #char "."); - // connect triangles to eachother for fake 3d effect draw_line(screen, t1.p1, t2.p1, #char "%"); draw_line(screen, t1.p2, t2.p2, #char "%");