aboutsummaryrefslogtreecommitdiff
path: root/dc
diff options
context:
space:
mode:
authoriamcheeseman <[email protected]>2026-05-11 09:47:22 -0400
committeriamcheeseman <[email protected]>2026-05-11 09:47:22 -0400
commit2c27120a61631dffd4527db8b1349379d53ccc3b (patch)
tree81cde508604701a3dfa0a0edc663bc22d961e119 /dc
parent4ab4f2a64a3cd2b3c9a49a2a41040af96ed28b14 (diff)
fix fps counting
Diffstat (limited to 'dc')
-rw-r--r--dc/dc.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/dc/dc.c b/dc/dc.c
index 69df3f8..b0e7b60 100644
--- a/dc/dc.c
+++ b/dc/dc.c
@@ -15,10 +15,10 @@
struct ty_image img;
struct ty_font font;
+double last_frame = 0;
+
void tick(void)
{
- double start = ty_get_time();
-
ty_draw_clear(TY_COLOR_BLACK);
ty_draw_image(
@@ -31,7 +31,8 @@ void tick(void)
ty_draw_text(&font, ty_vec2i(5, SCREEN_HEIGHT - 5 - 8), "hello, world!");
- double frame_time = ty_get_time() - start;
+ 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);
@@ -50,7 +51,7 @@ void tick(void)
frame_time * 1000
);
- char fps_fmt[] = "%4d fps";
+ char fps_fmt[] = "%2d fps";
int fps_width = ty_font_width(&font, fps_fmt, (int)(1.0 / frame_time));
ty_draw_rect(
@@ -85,6 +86,7 @@ void tick(void)
);
ty_draw_end();
+
}
struct ty_image load_qoi_image(const char *path)
@@ -105,7 +107,7 @@ int main(void)
.scr_width = SCREEN_WIDTH,
.scr_height = SCREEN_HEIGHT,
.game_title = "Demonchime",
- .ticrate = 30,
+ .ticrate = 60,
};
ty_init(hints);