test/snake.c

changeset 65
9c44c55d327a
parent 63
e3cacdd636e4
child 70
81a089a47eff
--- a/test/snake.c	Thu Apr 18 21:53:53 2024 +0200
+++ b/test/snake.c	Thu Apr 18 22:53:55 2024 +0200
@@ -47,7 +47,7 @@
 }
 
 static void create_fps_counter(void) {
-    asc_set_font(asc_font(ASC_FONT_REGULAR, 24));
+    asc_font(ASC_FONT_REGULAR, 24);
     asc_ink_rgb(255, 0, 0);
     AscSceneNode* node = asc_text( .x = 10, .y = 10 );
     asc_scene_add_behavior(node, update_fps_counter);
@@ -56,8 +56,8 @@
 
 static void update_score_counter(AscSceneNode *node) {
     // tie to bottom right of the screen
-    if (asc_window_active->resized) {
-        asc_vec2i bottom_right = asc_window_active->dimensions;
+    if (asc_active_window->resized) {
+        asc_vec2i bottom_right = asc_active_window->dimensions;
         asc_vec2i scale = asc_get_scale2d(node);
         asc_set_position2d(
                 node,
@@ -68,7 +68,7 @@
 }
 
 static void create_score_counter(void) {
-    asc_set_font(asc_font(ASC_FONT_BOLD, 14));
+    asc_font(ASC_FONT_BOLD, 14);
     asc_ink_rgb(0, 255, 0);
     AscSceneNode* node = asc_text(.text = "Score: 0" );
     asc_scene_add_behavior(node, update_score_counter);
@@ -87,7 +87,7 @@
     AscWindowSettings settings;
     asc_window_settings_init_defaults(&settings);
     settings.title = "Snake";
-    AscWindow *window = asc_window_initialize(0, &settings);
+    asc_window_initialize(0, &settings);
 
     // create UI elements
     create_fps_counter();
@@ -98,7 +98,8 @@
         // quit application on any error
         if (asc_has_error()) {
             SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
-                    "Fatal Error", asc_get_error(), window->window);
+                    "Fatal Error", asc_get_error(),
+                    asc_active_window->window);
             asc_clear_error();
             asc_context_quit();
         }

mercurial