test/snake/snake.c

changeset 263
cc5cd4c98e46
parent 262
b47de42f4598
child 264
653869cd653f
equal deleted inserted replaced
262:b47de42f4598 263:cc5cd4c98e46
125 asc_ptr_cast(AscRectangle, frame, behavior->node); 125 asc_ptr_cast(AscRectangle, frame, behavior->node);
126 asc_rectangle_set_bounds(frame, MAIN_SCENE->camera.viewport); 126 asc_rectangle_set_bounds(frame, MAIN_SCENE->camera.viewport);
127 } 127 }
128 128
129 static void backdrop_create(void) { 129 static void backdrop_create(void) {
130 const float scale = asc_active_window->ui_scale; 130 const float scale = 1.f / asc_active_window->ui_scale;
131 AscSceneNode *node = asc_sprite( 131 AscSceneNode *node = asc_sprite(
132 .texture = TEXTURE_BACKDROP, 132 .texture = TEXTURE_BACKDROP,
133 .texture_scale_mode = ASC_TEXTURE_SCALE_REPEAT, 133 .texture_scale_mode = ASC_TEXTURE_SCALE_REPEAT,
134 .texture_scale_x = scale, .texture_scale_y = scale, 134 .texture_scale_x = scale, .texture_scale_y = scale,
135 ); 135 );
464 asc_window_center(0); 464 asc_window_center(0);
465 465
466 // load textures 466 // load textures
467 textures_init(); 467 textures_init();
468 468
469 // initialize the scenes 469 // initialize backdrop scene
470 asc_scene_init(BACKDROP_SCENE, "backdrop", 470 asc_scene_init(BACKDROP_SCENE, "backdrop",
471 .type = ASC_CAMERA_ORTHO, 471 .type = ASC_CAMERA_ORTHO,
472 .projection_update_func = asc_camera_ortho_update_size 472 .projection_update_func = asc_camera_ortho_update_size
473 ); 473 );
474 backdrop_create();
475
476 // Initialize main scene
474 asc_scene_init(MAIN_SCENE, "main", 477 asc_scene_init(MAIN_SCENE, "main",
475 .type = ASC_CAMERA_ORTHO, 478 .type = ASC_CAMERA_ORTHO,
476 .ortho.rect = ASC_RECT( 479 .ortho.rect = ASC_RECT(
477 -GAME_FIELD_TILE_SIZE, 480 -GAME_FIELD_TILE_SIZE,
478 -GAME_FIELD_TILE_SIZE, 481 -GAME_FIELD_TILE_SIZE,
481 ), 484 ),
482 .viewport_clear = true, 485 .viewport_clear = true,
483 .clear_color = ASC_RGBi(0, 32, 16), 486 .clear_color = ASC_RGBi(0, 32, 16),
484 .viewport_update_func = main_scene_viewport_update 487 .viewport_update_func = main_scene_viewport_update
485 ); 488 );
486 backdrop_create();
487 489
488 // create the fps counter 490 // create the fps counter
489 AscSceneNode *fps_counter = fps_counter_create(); 491 AscSceneNode *fps_counter = fps_counter_create();
490 asc_scene_node_hide(fps_counter); 492 asc_scene_node_hide(fps_counter);
491 493

mercurial