test/snake.c

changeset 58
26ebb2f1e6e6
parent 48
6e5b5ba2752c
child 59
764fbb013252
--- a/test/snake.c	Wed Apr 10 19:43:34 2024 +0200
+++ b/test/snake.c	Fri Apr 12 22:03:15 2024 +0200
@@ -41,8 +41,7 @@
         fps /= asc_context.frame_nanos;
         if (fps != last_fps) {
             last_fps = fps;
-            snprintf(asc_text_data(node)->text, 11, "%"PRIu64" FPS", fps);
-            asc_node_update(node);
+            asc_text_printf(node, "%"PRIu64" FPS", fps);
         }
     }
 }
@@ -50,9 +49,9 @@
 static void create_fps_counter(void) {
     asc_set_font(asc_font(ASC_FONT_REGULAR, 24));
     asc_ink_rgb(255, 0, 0);
-    AscSceneNode* node = asc_text(10, 10, "XXXXXXX FPS");
+    AscSceneNode* node = asc_text(10, 10, NULL);
     asc_scene_add_behavior(node, update_fps_counter);
-    asc_scene_node_link(asc_window_active->ui, node);
+    asc_add_ui_node(node);
 }
 
 static void update_score_counter(AscSceneNode *node) {
@@ -73,7 +72,7 @@
     asc_ink_rgb(0, 255, 0);
     AscSceneNode* node = asc_text(0, 0, "Score: 0");
     asc_scene_add_behavior(node, update_score_counter);
-    asc_scene_node_link(asc_window_active->ui, node);
+    asc_add_ui_node(node);
 }
 
 int main(int argc, char** argv) {
@@ -94,7 +93,6 @@
     create_fps_counter();
     create_score_counter();
 
-
     // Main Loop
     do {
         // quit application on any error

mercurial