test/snake/snake.c

changeset 214
9d460888a83e
parent 213
3d252dbd7c8e
child 215
a7c8e1727971
--- a/test/snake/snake.c	Thu Jul 17 20:26:39 2025 +0200
+++ b/test/snake/snake.c	Fri Jul 18 18:01:41 2025 +0200
@@ -128,21 +128,23 @@
 }
 
 static void create_fps_counter(void) {
-    asc_font(ASC_FONT_REGULAR, 12);
-    asc_ink_rgb(255, 255, 255);
-    AscSceneNode *node = asc_text(.name = "FPS Counter");
+    AscSceneNode *node = asc_text(
+        .name = "FPS Counter",
+        .color = ASC_RGB(255, 255, 255),
+        .font = asc_font(ASC_FONT_REGULAR, 12),
+    );
     asc_behavior_add(node, .func = update_fps_counter, .interval = asc_seconds(1));
     asc_behavior_add(node, tie_fps_counter_to_corner);
     asc_ui_add_node(node);
 }
 
 static void create_score_counter(void) {
-    asc_font(ASC_FONT_BOLD, 16);
-    asc_ink_rgb(0, 255, 0);
     AscSceneNode *node = asc_text(
         .name = "Score Counter",
         .x = 10, .y = 10,
-        .text = "Score: 0"
+        .text = "Score: 0",
+        .color = ASC_RGB(0, 255, 0),
+        .font = asc_font(ASC_FONT_BOLD, 16),
     );
     asc_ui_add_node(node);
 }
@@ -180,10 +182,10 @@
     AscSceneNode *gamefield = asc_scene_node_empty();
     for (unsigned x = 0; x < game_field_size; x+=game_field_tile_size) {
         for (unsigned y = 0; y < game_field_size; y+=game_field_tile_size) {
-            asc_ink_rgb(0, 128, 255);
             AscSceneNode *tile = asc_rectangle(
                 .x = x, .y = y, .filled = true, .thickness = 1,
                 .width = game_field_tile_size, .height = game_field_tile_size,
+                .color = ASC_RGB(0, 128, 255),
                 .border_color = ASC_RGB(64, 196, 255),
             );
             asc_scene_node_link(gamefield, tile);
@@ -242,7 +244,6 @@
         .type = ASC_CAMERA_ORTHO,
         .projection_update_func = asc_camera_ortho_update_size
     );
-    asc_ink_rgb(0, 128, 90);
     asc_scene_init(MAIN_SCENE,
         .type = ASC_CAMERA_ORTHO,
         .ortho.rect = ASC_RECT(
@@ -252,6 +253,7 @@
             game_field_size+game_field_tile_size
         ),
         .viewport_clear = true,
+        .clear_color = ASC_RGB(0, 128, 90),
         .viewport_update_func = update_viewport_for_window_resize
     );
 

mercurial