diff options
| author | Alec Goncharow <alec@goncharow.dev> | 2026-05-27 14:34:32 -0400 |
|---|---|---|
| committer | Alec Goncharow <alec@goncharow.dev> | 2026-05-27 14:34:32 -0400 |
| commit | 93ad8a5cdeb8421bcf02195bc470257935062138 (patch) | |
| tree | bd76666718c27f3c79e015f6c9f7404a38663207 /src/apps/example_app.jai | |
| parent | 13335d5ee6778ad65d49a774274bae84a64a7edf (diff) | |
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.
Diffstat (limited to 'src/apps/example_app.jai')
| -rw-r--r-- | src/apps/example_app.jai | 33 |
1 files changed, 33 insertions, 0 deletions
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); + }; +} |
