int main(int argc, char * argv[]) { if(!t3f_initialize("ex_gui", 640, 480, 60.0, logic, render, T3F_USE_KEYBOARD | T3F_USE_MOUSE, NULL)) { return 1; } bitmap = al_load_bitmap("data/bitmap.png"); if(!bitmap) { return 1; } font = al_load_bitmap_font("data/font.png"); if(!font) { return 1; } t3f_set_gui_driver(NULL); page = t3f_create_gui(0, 0); t3f_add_gui_text_element(page, red_proc, "Red", font, 16, 0, t3f_color_white, T3F_GUI_ELEMENT_SHADOW); t3f_add_gui_text_element(page, green_proc, "Green", font, 16, 24, t3f_color_white, T3F_GUI_ELEMENT_SHADOW); t3f_add_gui_text_element(page, blue_proc, "Blue", font, 16, 48, t3f_color_white, T3F_GUI_ELEMENT_SHADOW); t3f_add_gui_image_element(page, black_proc, bitmap, 16, 120, T3F_GUI_ELEMENT_SHADOW); t3f_run(); return 0; }
bool paddle_initialize(void) { /* initialize the T^3 Framework - create 640x480 display - logic runs at 60.0 FPS, typical game refresh rate - name the program "Paper Paddle" (displayed as window title when in windowed mode) - use paddle_logic() and paddle_render() to handle logic and rendering - use keyboard (T3F_USE_KEYBOARD), mouse (T3F_USE_MOUSE), sound (T3F_USE_SOUND), and fullscreen mode (T3F_USE_FULLSCREEN) */ if(!t3f_initialize("Paper Paddle", 640, 480, 60.0, paddle_logic, paddle_render, T3F_USE_KEYBOARD | T3F_USE_MOUSE | T3F_USE_SOUND, NULL)) { printf("Failed to initialize T^3 Framework!\n"); return false; } /* load bitmaps */ paddle_bitmap[EXAMPLE_BITMAP_BG] = al_load_bitmap("data/graphics/bg.png"); if(!paddle_bitmap[EXAMPLE_BITMAP_BG]) { printf("Failed to load image!\n"); return false; } paddle_bitmap[EXAMPLE_BITMAP_LOGO] = al_load_bitmap("data/graphics/logo.png"); if(!paddle_bitmap[EXAMPLE_BITMAP_LOGO]) { printf("Failed to load image!\n"); return false; } paddle_bitmap[EXAMPLE_BITMAP_PADDLE] = al_load_bitmap("data/graphics/paddle.png"); if(!paddle_bitmap[EXAMPLE_BITMAP_PADDLE]) { printf("Failed to load image!\n"); return false; } paddle_bitmap[EXAMPLE_BITMAP_BALL] = al_load_bitmap("data/graphics/ball.png"); if(!paddle_bitmap[EXAMPLE_BITMAP_BALL]) { printf("Failed to load image!\n"); return false; } /* load fonts */ paddle_font[EXAMPLE_FONT_MENU] = al_load_bitmap_font("data/fonts/title_font.png"); if(!paddle_font[EXAMPLE_FONT_MENU]) { printf("Failed to load font!\n"); return false; } paddle_font[EXAMPLE_FONT_GAME] = al_load_bitmap_font("data/fonts/game_font.png"); if(!paddle_font[EXAMPLE_FONT_GAME]) { printf("Failed to load font!\n"); return false; } /* load sound samples */ paddle_sample[EXAMPLE_SAMPLE_HIT] = al_load_sample("data/sounds/hit.ogg"); if(!paddle_sample[EXAMPLE_SAMPLE_HIT]) { printf("Failed to load sample!\n"); return false; } paddle_sample[EXAMPLE_SAMPLE_SCORE] = al_load_sample("data/sounds/score.ogg"); if(!paddle_sample[EXAMPLE_SAMPLE_SCORE]) { printf("Failed to load sample!\n"); return false; } /* create GUI */ t3f_set_gui_driver(NULL); paddle_menu = t3f_create_gui(0, 0); t3f_add_gui_text_element(paddle_menu, paddle_menu_play_proc, "Play", paddle_font[EXAMPLE_FONT_MENU], 320, 240, t3f_color_black, T3F_GUI_ELEMENT_CENTRE); t3f_add_gui_text_element(paddle_menu, paddle_menu_quit_proc, "Quit", paddle_font[EXAMPLE_FONT_MENU], 320, 270, t3f_color_black, T3F_GUI_ELEMENT_CENTRE); return true; }
bool dot_intro_initialize(void * data) { APP_INSTANCE * app = (APP_INSTANCE *)data; float top, bottom; t3f_set_gui_driver(NULL); if(app->desktop_mode) { top = 0; bottom = DOT_GAME_PLAYFIELD_HEIGHT; } else { top = (t3f_virtual_display_height / 2 - DOT_GAME_PLAYFIELD_HEIGHT) / 2 + t3f_virtual_display_height / 2; bottom = t3f_virtual_display_height; } /* create menus */ app->menu[DOT_MENU_MAIN] = t3f_create_gui(0, 0); if(!app->menu[DOT_MENU_MAIN]) { return false; } t3f_add_gui_text_element(app->menu[DOT_MENU_MAIN], dot_menu_proc_leaderboard, "Leaderboard", app->font[DOT_FONT_32], t3f_virtual_display_width / 2, 0, t3f_color_white, T3F_GUI_ELEMENT_CENTRE | T3F_GUI_ELEMENT_SHADOW); t3f_add_gui_text_element(app->menu[DOT_MENU_MAIN], dot_menu_proc_setup, "Setup", app->font[DOT_FONT_32], t3f_virtual_display_width / 2, 64, t3f_color_white, T3F_GUI_ELEMENT_CENTRE | T3F_GUI_ELEMENT_SHADOW); t3f_add_gui_text_element(app->menu[DOT_MENU_MAIN], dot_menu_proc_privacy, "Privacy", app->font[DOT_FONT_32], t3f_virtual_display_width / 2, 128, DOT_MENU_COLOR_ENABLED, T3F_GUI_ELEMENT_CENTRE | T3F_GUI_ELEMENT_SHADOW); t3f_add_gui_text_element(app->menu[DOT_MENU_MAIN], dot_menu_proc_play, "Play", app->font[DOT_FONT_32], t3f_virtual_display_width / 2, 192, t3f_color_white, T3F_GUI_ELEMENT_CENTRE | T3F_GUI_ELEMENT_SHADOW); t3f_center_gui(app->menu[DOT_MENU_MAIN], top, bottom); t3f_set_gui_shadow(app->menu[DOT_MENU_MAIN], -2, 2); app->menu[DOT_MENU_PRIVACY] = t3f_create_gui(0, 0); if(!app->menu[DOT_MENU_PRIVACY]) { return false; } t3f_add_gui_text_element(app->menu[DOT_MENU_PRIVACY], dot_menu_proc_privacy_back, "Back", app->font[DOT_FONT_32], t3f_virtual_display_width / 2, 0, t3f_color_white, T3F_GUI_ELEMENT_CENTRE | T3F_GUI_ELEMENT_SHADOW); t3f_center_gui(app->menu[DOT_MENU_PRIVACY], top, bottom); t3f_set_gui_shadow(app->menu[DOT_MENU_PRIVACY], -2, 2); app->menu[DOT_MENU_LEADERBOARD] = t3f_create_gui(0, 0); if(!app->menu[DOT_MENU_LEADERBOARD]) { return false; } t3f_add_gui_text_element(app->menu[DOT_MENU_LEADERBOARD], dot_menu_proc_leaderboard_back, "Back", app->font[DOT_FONT_32], t3f_virtual_display_width / 2, 0, t3f_color_white, T3F_GUI_ELEMENT_CENTRE | T3F_GUI_ELEMENT_SHADOW); t3f_center_gui(app->menu[DOT_MENU_LEADERBOARD], top, bottom); t3f_set_gui_shadow(app->menu[DOT_MENU_LEADERBOARD], -2, 2); app->menu[DOT_MENU_LEADERBOARD_2] = t3f_create_gui(0, 0); if(!app->menu[DOT_MENU_LEADERBOARD_2]) { return false; } t3f_add_gui_text_element(app->menu[DOT_MENU_LEADERBOARD_2], NULL, "Play Again?", app->font[DOT_FONT_32], t3f_virtual_display_width / 2, 0, al_map_rgba_f(1.0, 1.0, 0.0, 1.0), T3F_GUI_ELEMENT_CENTRE | T3F_GUI_ELEMENT_SHADOW | T3F_GUI_ELEMENT_STATIC); t3f_add_gui_text_element(app->menu[DOT_MENU_LEADERBOARD_2], dot_menu_proc_play, "Yes", app->font[DOT_FONT_32], t3f_virtual_display_width / 2, 64, t3f_color_white, T3F_GUI_ELEMENT_CENTRE | T3F_GUI_ELEMENT_SHADOW); t3f_add_gui_text_element(app->menu[DOT_MENU_LEADERBOARD_2], dot_menu_proc_leaderboard_main_menu, "No", app->font[DOT_FONT_32], t3f_virtual_display_width / 2, 128, t3f_color_white, T3F_GUI_ELEMENT_CENTRE | T3F_GUI_ELEMENT_SHADOW); t3f_center_gui(app->menu[DOT_MENU_LEADERBOARD_2], top, bottom); t3f_set_gui_shadow(app->menu[DOT_MENU_LEADERBOARD_2], -2, 2); app->menu[DOT_MENU_UPLOAD_SCORES] = t3f_create_gui(0, 0); if(!app->menu[DOT_MENU_UPLOAD_SCORES]) { return false; } t3f_add_gui_text_element(app->menu[DOT_MENU_UPLOAD_SCORES], NULL, "Upload Scores?", app->font[DOT_FONT_32], t3f_virtual_display_width / 2, 0, al_map_rgba_f(1.0, 1.0, 0.0, 1.0), T3F_GUI_ELEMENT_CENTRE | T3F_GUI_ELEMENT_SHADOW | T3F_GUI_ELEMENT_STATIC); t3f_add_gui_text_element(app->menu[DOT_MENU_UPLOAD_SCORES], dot_menu_proc_upload_yes, "Yes", app->font[DOT_FONT_32], t3f_virtual_display_width / 2, 64, t3f_color_white, T3F_GUI_ELEMENT_CENTRE | T3F_GUI_ELEMENT_SHADOW); t3f_add_gui_text_element(app->menu[DOT_MENU_UPLOAD_SCORES], dot_menu_proc_upload_no, "No", app->font[DOT_FONT_32], t3f_virtual_display_width / 2, 128, t3f_color_white, T3F_GUI_ELEMENT_CENTRE | T3F_GUI_ELEMENT_SHADOW); t3f_center_gui(app->menu[DOT_MENU_UPLOAD_SCORES], top, bottom); t3f_set_gui_shadow(app->menu[DOT_MENU_UPLOAD_SCORES], -2, 2); app->menu[DOT_MENU_PROFILE] = t3f_create_gui(0, 0); if(!app->menu[DOT_MENU_PROFILE]) { return false; } t3f_add_gui_text_element(app->menu[DOT_MENU_PROFILE], NULL, "User Name", app->font[DOT_FONT_32], t3f_virtual_display_width / 2, 0, al_map_rgba_f(1.0, 1.0, 0.0, 1.0), T3F_GUI_ELEMENT_CENTRE | T3F_GUI_ELEMENT_SHADOW | T3F_GUI_ELEMENT_STATIC); t3f_add_gui_text_element(app->menu[DOT_MENU_PROFILE], dot_menu_proc_profile_name, app->user_name, app->font[DOT_FONT_32], t3f_virtual_display_width / 2, 64, t3f_color_white, T3F_GUI_ELEMENT_CENTRE | T3F_GUI_ELEMENT_SHADOW); t3f_add_gui_text_element(app->menu[DOT_MENU_PROFILE], dot_menu_proc_profile_okay, "Okay", app->font[DOT_FONT_32], t3f_virtual_display_width / 2, 128, t3f_color_white, T3F_GUI_ELEMENT_CENTRE | T3F_GUI_ELEMENT_SHADOW); t3f_center_gui(app->menu[DOT_MENU_PROFILE], top, bottom); t3f_set_gui_shadow(app->menu[DOT_MENU_PROFILE], -2, 2); app->menu[DOT_MENU_MUSIC] = t3f_create_gui(0, 0); if(!app->menu[DOT_MENU_MUSIC]) { return false; } t3f_add_gui_text_element(app->menu[DOT_MENU_MUSIC], NULL, "Enable Music?", app->font[DOT_FONT_32], t3f_virtual_display_width / 2, 0, al_map_rgba_f(1.0, 1.0, 0.0, 1.0), T3F_GUI_ELEMENT_CENTRE | T3F_GUI_ELEMENT_SHADOW | T3F_GUI_ELEMENT_STATIC); t3f_add_gui_text_element(app->menu[DOT_MENU_MUSIC], dot_menu_proc_music_yes, "Yes", app->font[DOT_FONT_32], t3f_virtual_display_width / 2, 64, t3f_color_white, T3F_GUI_ELEMENT_CENTRE | T3F_GUI_ELEMENT_SHADOW); t3f_add_gui_text_element(app->menu[DOT_MENU_MUSIC], dot_menu_proc_music_no, "No", app->font[DOT_FONT_32], t3f_virtual_display_width / 2, 128, t3f_color_white, T3F_GUI_ELEMENT_CENTRE | T3F_GUI_ELEMENT_SHADOW); t3f_center_gui(app->menu[DOT_MENU_MUSIC], top, bottom); t3f_set_gui_shadow(app->menu[DOT_MENU_MUSIC], -2, 2); app->current_menu = DOT_MENU_MAIN; return true; }