tuxanci2-game
Game code/assets for tuxanci2
Log | Files | Refs | README | LICENSE

loading.c (1222B)


      1 #include <tuxanci2/screen.h>
      2 #include <tuxanci2/display.h>
      3 #include <tuxanci2/image.h>
      4 #include <ta_files.h>
      5 #include <stdint.h>
      6 #include "loading.h"
      7 #include "../screens.h"
      8 
      9 #define TA_LOADING_LOGO_SIZE TA_FIXED(0.3)
     10 
     11 void ta_screen_loading_init(void) {
     12 	ta_image_init(TA_FILE_LOADING_LOGO);
     13 }
     14 
     15 void ta_screen_loading_update(void) {
     16 	uint32_t width;
     17 	uint32_t height;
     18 
     19 	if (!ta_image_get_size(TA_FILE_LOADING_LOGO, &width, &height)) {
     20 		return;
     21 	}
     22 
     23 	uint32_t frame_width = ta_display_width();
     24 	uint32_t frame_height = ta_display_height();
     25 	ta_fixed draw_width;
     26 	ta_fixed draw_height;
     27 
     28 	if (frame_width * height <= frame_height * width) {
     29 		draw_width = TA_LOADING_LOGO_SIZE;
     30 		draw_height = (ta_fixed)((TA_LOADING_LOGO_SIZE * (uint32_t)height * frame_width) / ((uint32_t)width * frame_height));
     31 	} else {
     32 		draw_height = TA_LOADING_LOGO_SIZE;
     33 		draw_width = (ta_fixed)((TA_LOADING_LOGO_SIZE * (uint32_t)width * frame_height) / ((uint32_t)height * frame_width));
     34 	}
     35 
     36 	ta_fixed x = (TA_FIXED(1.0) - draw_width) / 2;
     37 	ta_fixed y = (TA_FIXED(1.0) - draw_height) / 2;
     38 
     39 	ta_image_draw(TA_FILE_LOADING_LOGO, x, y, draw_width, draw_height, 0);
     40 
     41 	ta_screen_switch(TA_SCREEN_MAIN_MENU);
     42 }
     43 
     44 void ta_screen_loading_destroy(void) {
     45 }