38 if (debounce >= 1000u) { |
38 if (debounce >= 1000u) { |
39 debounce = 0; |
39 debounce = 0; |
40 fps /= asc_context.elapsed_millis; |
40 fps /= asc_context.elapsed_millis; |
41 if (fps != last_fps) { |
41 if (fps != last_fps) { |
42 last_fps = fps; |
42 last_fps = fps; |
43 snprintf(((AscText*)node)->text, 9, "%u FPS", fps); |
43 snprintf(asc_text_data(node)->text, 9, "%u FPS", fps); |
44 asc_node_update(node); |
44 asc_node_update(node); |
45 } |
45 } |
46 } |
46 } |
47 } |
47 } |
48 |
48 |
49 static void create_fps_counter(void) { |
49 static void create_fps_counter(void) { |
50 asc_set_font(asc_font(ASC_FONT_REGULAR, 24)); |
50 asc_set_font(asc_font(ASC_FONT_REGULAR, 24)); |
51 asc_ink_rgb(255, 0, 0); |
51 asc_ink_rgb(255, 0, 0); |
52 AscText* text = asc_text(10, 10, "XXXXX FPS"); |
52 AscSceneNode* node = asc_text(10, 10, "XXXXX FPS"); |
53 asc_scene_add_behavior(asc_node(text), update_fps_counter); |
53 asc_scene_add_behavior(node, update_fps_counter); |
|
54 asc_scene_add(asc_window_active_ui, node); |
54 } |
55 } |
55 |
56 |
56 int main(int argc, char** argv) { |
57 int main(int argc, char** argv) { |
57 asc_context_initialize(); |
58 asc_context_initialize(); |
58 if (asc_has_error()) { |
59 if (asc_has_error()) { |
61 return 1; |
62 return 1; |
62 } |
63 } |
63 |
64 |
64 AscWindowSettings settings; |
65 AscWindowSettings settings; |
65 asc_window_settings_init_defaults(&settings); |
66 asc_window_settings_init_defaults(&settings); |
66 settings.title = "Sandbox Application"; |
67 settings.title = "Snake"; |
67 |
68 |
68 AscWindow *window = asc_window_initialize(0, &settings); |
69 AscWindow *window = asc_window_initialize(0, &settings); |
69 asc_shader_initialize_predefined(); |
70 asc_shader_initialize_predefined(); |
70 |
71 |
71 // create fps counter |
72 // create fps counter |