aboutsummaryrefslogtreecommitdiff
path: root/dc
diff options
context:
space:
mode:
authoriamcheeseman <[email protected]>2026-05-11 14:30:48 -0400
committeriamcheeseman <[email protected]>2026-05-11 14:30:48 -0400
commitf4017a52d90567c2df482c5d553076dc706ac59b (patch)
tree6cce9684cee03370188e6c46e745fabb64007a46 /dc
parentda2585ddc49abb80e7457ccc2805fff884eb2021 (diff)
Allow user input
Diffstat (limited to 'dc')
-rw-r--r--dc/dc.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/dc/dc.c b/dc/dc.c
index adecb4e..b68988e 100644
--- a/dc/dc.c
+++ b/dc/dc.c
@@ -1,7 +1,7 @@
#include <stdio.h>
-#include <teensy.h>
#include <math.h>
+#include <teensy.h>
#include <time.h>
#define QOI_IMPLEMENTATION
@@ -17,6 +17,8 @@ struct ty_font font;
double last_frame = 0;
+bool toggled = false;
+
void tick(void)
{
ty_draw_clear(TY_COLOR_BLACK);
@@ -39,12 +41,21 @@ void tick(void)
ty_draw_text(&font, ty_vec2i(5, SCREEN_HEIGHT - 5 - 8), "hello, world!");
+ if (ty_button_pressed(TY_BTN_LEFT_UP)) {
+ toggled = !toggled;
+ }
+
+ if (toggled) {
+ ty_draw_image(img, ty_vec2i(200, 200));
+ }
+
double frame_time = ty_get_time() - last_frame;
last_frame = ty_get_time();
char ms_fmt[] = "%.2g ms";
int ms_width = ty_font_width(&font, ms_fmt, frame_time * 1000);
+ int y = 5;
ty_draw_rect(
(struct ty_recti){
5, 5,
@@ -58,6 +69,7 @@ void tick(void)
ms_fmt,
frame_time * 1000
);
+ y += 8;
char fps_fmt[] = "%2d fps";
int fps_width = ty_font_width(&font, fps_fmt, (int)(1.0 / frame_time));
@@ -75,8 +87,14 @@ void tick(void)
fps_fmt,
(int)(1.0 / frame_time)
);
+ y += 8;
+
+ ty_draw_text_fmt(&font, ty_vec2i(5, y),
+ "%.2g",
+ ty_get_time()
+ );
+ y += 8;
- int y = 5+24;
ty_draw_text(&font, ty_vec2i(5, y),
"abcdefghijklmnopqrstuvwxyz"
);
@@ -101,10 +119,6 @@ void tick(void)
"THe_value = MY_arr[15]"
);
y += 8;
- ty_draw_text_fmt(&font, ty_vec2i(5, y),
- "%.2g",
- ty_get_time()
- );
ty_draw_end();