This repository has been archived on 2025-02-04. You can view files and clone it, but cannot push or open issues or pull requests.
helpless/entry.c

40 lines
955 B
C
Raw Normal View History

2024-06-29 01:18:22 +02:00
int start(int argc, char **argv) {
2024-06-29 01:18:22 +02:00
window.title = fixed_string("My epic game");
window.width = 400;
window.height = 400;
window.x = 200;
window.y = 200;
2024-06-29 01:18:22 +02:00
seed_for_random = os_get_current_cycle_count();
2024-06-29 01:18:22 +02:00
float64 last_time = os_get_current_time_in_seconds();
2024-06-29 01:18:22 +02:00
while (!window.should_close) {
reset_temporary_storage();
context.allocator = temp;
os_update();
2024-06-29 01:18:22 +02:00
float64 now = os_get_current_time_in_seconds();
float64 delta = now - last_time;
last_time = now;
// Print some random FPS samples every now and then
if ((get_random() % 4000) == 3)
print("%2.f FPS\n", 1.0/delta);
2024-06-29 01:18:22 +02:00
draw_rect_rotated(v2(-.25f, -.25f), v2(.5f, .5f), COLOR_RED, v2(.25, .25), (f32)now);
Vector2 hover_position = v2_rotate_point_around_pivot(v2(-.5, -.5), v2(0, 0), -(f32)now);
Vector2 local_pivot = v2(.125f, .125f);
draw_rect(v2_sub(hover_position, local_pivot), v2(.25f, .25f), COLOR_GREEN);
gfx_update();
2024-06-29 01:18:22 +02:00
}
return 0;
}