diff -r 2ca88ec29953 -r 2b7f92ff2c15 test/snake/snake.c --- a/test/snake/snake.c Sat May 03 13:30:04 2025 +0200 +++ b/test/snake/snake.c Sat May 03 13:49:24 2025 +0200 @@ -42,7 +42,7 @@ #define BACKDROP_SCENE asc_window_scene(0) #define MAIN_SCENE asc_window_scene(1) -static void destroy_textures(void *dummy) { +static void destroy_textures(__attribute__((__unused__)) void *dummy) { asc_texture_destroy(tex2d, TEX2D_COUNT); } @@ -70,12 +70,13 @@ // tie to bottom right of the screen if (asc_test_flag(node->flags, ASC_SCENE_NODE_GRAPHICS_UPDATED) || asc_active_window->resized) { - asc_vec2i bottom_right = asc_active_window->dimensions; - asc_vec2i scale = asc_get_scale2d(node); + asc_vec2u bottom_right = asc_active_window->dimensions; + // TODO: replace scale with asc_text_get_size() + asc_vec3f text_size = node->scale; asc_set_position2d( node, - bottom_right.x - scale.width - 10, - bottom_right.y - scale.height - 10 + (int)bottom_right.x - (int)text_size.width - 10, + (int)bottom_right.y - (int)text_size.height - 10 ); } } @@ -83,8 +84,9 @@ static void scale_backdrop(AscSceneNode *node) { // scale the backdrop to the size of the window if (asc_active_window->resized) { - asc_vec2i window_size = asc_active_window->dimensions; - asc_set_scale2d(node, window_size.width, window_size.height); + asc_vec2u window_size = asc_active_window->dimensions; + // TODO: replace scale with asc_sprite_set_size() + asc_set_scale(node, (float)window_size.width, (float)window_size.height, 1); // TODO: implement texture repetition } } @@ -126,9 +128,9 @@ // TODO: return something } -static asc_recti update_viewport_for_window_resize(asc_vec2i window_size) { +static asc_recti update_viewport_for_window_resize(asc_vec2u window_size) { // Compute scaling and offsets - int viewport_size, offset_x = 0, offset_y = 0; + unsigned viewport_size, offset_x = 0, offset_y = 0; if (window_size.width > window_size.height) { // Wider window: letterbox (black bars on top/bottom) offset_x = (window_size.width - window_size.height) / 2; @@ -140,15 +142,10 @@ } // Set the viewport to the scaled and centered region - return (asc_recti){ - offset_x, - offset_y, - viewport_size, - viewport_size - }; + return asc_recti_new(offset_x, offset_y, viewport_size, viewport_size); } -int main(int argc, char** argv) { +int main(void) { asc_context_initialize(); if (asc_has_error()) { SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, @@ -178,7 +175,7 @@ }); asc_scene_init(MAIN_SCENE, (AscCameraParams) { .type = ASC_CAMERA_ORTHO, - .ortho.rect = (asc_recti){0, 0, game_field_size, game_field_size}, + .ortho.rect = asc_recti_new(0, 0, game_field_size, game_field_size), .viewport_update_func = update_viewport_for_window_resize });