From 8f5833955f535dc81df956380795c67428ebf00c Mon Sep 17 00:00:00 2001 From: peony Date: Sun, 10 Nov 2024 15:42:41 +0100 Subject: [PATCH] Circle test. (Precision issues) --- .../render_example/src/examples/orbit.hb | 36 +++++++++++++++++++ sysdata/programs/render_example/src/main.hb | 2 +- sysdata/programs/tetris/src/main.hb | 28 --------------- sysdata/system_config.toml | 12 +++---- 4 files changed, 43 insertions(+), 35 deletions(-) create mode 100644 sysdata/programs/render_example/src/examples/orbit.hb delete mode 100644 sysdata/programs/tetris/src/main.hb diff --git a/sysdata/programs/render_example/src/examples/orbit.hb b/sysdata/programs/render_example/src/examples/orbit.hb new file mode 100644 index 000000000..84b47e3ca --- /dev/null +++ b/sysdata/programs/render_example/src/examples/orbit.hb @@ -0,0 +1,36 @@ +.{Vec2, sin, cos, PI} := @use("../../../../libraries/stn/src/lib.hb").math +render := @use("../../../../libraries/render/src/lib.hb") + +able_bmp := @embed("../../../../assets/able.bmp") +mini_bmp := @embed("../../../../assets/mini.bmp") + +/* expected result: + two textured circles rotating + around one yellow filled circle + with a blue line showing their + 'orbit' */ + +example := fn(): void { + able := render.image.from(@bitcast(&able_bmp)) + mini := render.image.from(@bitcast(&mini_bmp)) + if able == null | mini == null { + return + } + + angle := 0.0 + + screen := render.init(true) + + loop { + render.clear(screen, render.black) + render.put_filled_circle(screen, .(screen.width / 2, screen.height / 2), 128, render.light_yellow) + render.put_circle(screen, .(screen.width / 2, screen.height / 2), 256, render.light_blue) + // Precision issues? + render.put_textured_circle(screen, able, .(able.width / 2, able.height / 2), .(screen.width / 2 + @intcast(@fti(sin(angle) * 256)), screen.height / 2 + @intcast(@fti(cos(angle) * 256))), able.width / 2 - 1) + render.put_textured_circle(screen, mini, .(mini.width / 2, mini.height / 2), .(screen.width / 2 + @intcast(@fti(sin(angle + PI) * 256)), screen.height / 2 + @intcast(@fti(cos(angle + PI) * 256))), mini.width / 2 - 1) + render.sync(screen) + + angle += 0.01 + } + return +} \ No newline at end of file diff --git a/sysdata/programs/render_example/src/main.hb b/sysdata/programs/render_example/src/main.hb index 77cb04c04..ab66cfa82 100644 --- a/sysdata/programs/render_example/src/main.hb +++ b/sysdata/programs/render_example/src/main.hb @@ -1 +1 @@ -.{example: main} := @use("./examples/text.hb") \ No newline at end of file +.{example: main} := @use("./examples/orbit.hb") \ No newline at end of file diff --git a/sysdata/programs/tetris/src/main.hb b/sysdata/programs/tetris/src/main.hb deleted file mode 100644 index f4eaa3bb4..000000000 --- a/sysdata/programs/tetris/src/main.hb +++ /dev/null @@ -1,28 +0,0 @@ -.{memory, log, string, buffer, math} := @use("../../../libraries/stn/src/lib.hb") -render := @use("../../../libraries/render/src/lib.hb") -Color := render.Color -Vec2 := math.Vec2 - -main := fn(): void { - input := @as(u8, 0) - output_buffer := memory.request_page(1) - input_buffer := buffer.search("XKeyboard\0") - - render.init() - - loop { - render.clear(render.black) - render.put_vline(100, 255, 128, Color.(255, 255, 255, 255)) - render.put_hline(64, 100 - 64, 164, Color.(255, 255, 255, 255)) - render.put_trirect(Vec2(int).(128, 128 + 256), Vec2(int).(256, -256), Color.(147, 147, 147, 255), Color.(107, 107, 107, 255)) - render.put_filled_rect(Vec2(int).(128 + 32, 128 + 32), Vec2(int).(256 - 64, 256 - 64), Color.(127, 127, 127, 127)) - render.sync() - - buffer.recv(input_buffer, &input, 1) - if input != 0 { - log.info(string.display_int(input, output_buffer)) - input = 0 - } - } - return -} diff --git a/sysdata/system_config.toml b/sysdata/system_config.toml index 1992a8004..93bd7396b 100644 --- a/sysdata/system_config.toml +++ b/sysdata/system_config.toml @@ -22,14 +22,14 @@ resolution = "1024x768x24" [boot.limine.ableos.modules] -# [boot.limine.ableos.modules.render_example] -# path = "boot:///render_example.hbf" +[boot.limine.ableos.modules.render_example] +path = "boot:///render_example.hbf" -[boot.limine.ableos.modules.horizon] -path = "boot:///horizon.hbf" +# [boot.limine.ableos.modules.horizon] +# path = "boot:///horizon.hbf" -[boot.limine.ableos.modules.ps2_mouse_driver] -path = "boot:///ps2_mouse_driver.hbf" +# [boot.limine.ableos.modules.ps2_mouse_driver] +# path = "boot:///ps2_mouse_driver.hbf" # [boot.limine.ableos.modules.ps2_keyboard_driver] # path = "boot:///ps2_keyboard_driver.hbf"