From 93ad8a5cdeb8421bcf02195bc470257935062138 Mon Sep 17 00:00:00 2001 From: Alec Goncharow Date: Wed, 27 May 2026 14:34:32 -0400 Subject: Working widget idea, makings of a maze app Forgot to commit as I went over the weekend, which is fine, not a ton of interesting stuff just yet. --- src/apps/example_app.jai | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/apps/example_app.jai (limited to 'src/apps/example_app.jai') diff --git a/src/apps/example_app.jai b/src/apps/example_app.jai new file mode 100644 index 0000000..2298fb7 --- /dev/null +++ b/src/apps/example_app.jai @@ -0,0 +1,33 @@ +#import "Basic"; +#import "Math"; + +Example_Data :: struct { + timer: float; +} + +init_example_widget :: (widget: *Widget_State) { + data := New(Example_Data); + data.timer = 0; + widget.data = data; + + widget.init = (app: *Widget_State) {}; + + widget.update = (widget: *Widget_State, dt: float) { + data := cast(*Example_Data) widget.data; + data.timer += dt; + }; + + widget.handle_input = (widget: *Widget_State, occluded: bool) -> (occludes: bool) {return false;}; + + widget.render = (widget: *Widget_State) { + data := cast(*Example_Data) widget.data; + + // Pulse background color to red to show it's updating and distinct from menu + r := 0.5 + 0.5 * sin(data.timer * 2.0); + Simp.clear_render_target(r, 0.1, 0.1, 1.0); + }; + + widget.shutdown = (widget: *Widget_State) { + free(widget.data); + }; +} -- cgit v1.2.3-70-g09d2