aboutsummaryrefslogtreecommitdiff
path: root/src/apps/example_app.jai
diff options
context:
space:
mode:
authorAlec Goncharow <alec@goncharow.dev>2026-05-27 14:34:32 -0400
committerAlec Goncharow <alec@goncharow.dev>2026-05-27 14:34:32 -0400
commit93ad8a5cdeb8421bcf02195bc470257935062138 (patch)
treebd76666718c27f3c79e015f6c9f7404a38663207 /src/apps/example_app.jai
parent13335d5ee6778ad65d49a774274bae84a64a7edf (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.jai33
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);
+ };
+}