#include #include #include #include #include "config.h" #if USB_FEATURE #include #include #endif //USB_FEATURE #if GRAYMODEOK #include #endif //GRAYMODEOK #include #include #include "game.h" #include "mapdata.h" #include "dialogs.h" extern bopti_image_t player_face_img; /* Game data (defined in "game.h")*/ Game game = { &map_level0, {10*PXSIZE, 48*PXSIZE, 0, 0, 100, SPEED}, false, false, false, 0 }; /* screen capture management code */ #if USB_FEATURE void USB_feature( void ) { if (game.screenshot && usb_is_open()) { #if GRAYMODEOK // This is a trick, if GRAYMODEOK is defined then // we make the code accessible if (dgray_enabled()) usb_fxlink_screenshot_gray(false); else #endif // else we just let the usual screeshot function usb_fxlink_screenshot(false); game.screenshot = false; } if (game.record && usb_is_open()) { #if GRAYMODEOK if (dgray_enabled()) usb_fxlink_videocapture_gray(false); else #endif usb_fxlink_videocapture(false); } } #endif /* Timer callback */ int update_time(void) { game.frame_duration++; return TIMER_CONTINUE; } int main(void) { int timer; timer = timer_configure(TIMER_TMU, 1000, GINT_CALL(update_time)); if(timer < 0){ return -1; } timer_start(timer); #if USB_FEATURE usb_interface_t const *interfaces[] = {&usb_ff_bulk, NULL}; usb_open(interfaces, GINT_CALL_NULL); #endif /* start grayscale engine */ #if GRAYMODEOK dgray(DGRAY_ON); #endif showtext(&game, &player_face_img, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet.", true, true); int in = showtext_dialog_ask(&game, &player_face_img, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet.", true, false, "Lorem\0ipsum", 2, 0); if(in) showtext_dialog(&game, &player_face_img, "You choosed ipsum", false, true); else showtext_dialog(&game, &player_face_img, "You choosed Lorem", false, true); do{ /* clear screen */ dclear(C_WHITE); /* render the map */ draw(&game); /* start the logic of the game */ game_logic(&game); /* Screen blit */ dupdate(); /* Screen capture feature if enabled */ #if USB_FEATURE USB_feature(); #endif /* Management of the inputs */ get_inputs(&game); /* Run the game at max. 50fps */ while(game.frame_duration < 20) sleep(); /* Reset frame_duration for the next frame */ game.frame_duration = 0; }while(!game.exittoOS); // want to exit ? /* shutdown grayengine*/ #if GRAYMODEOK dgray(DGRAY_OFF); #endif /* close USB */ #if USB_FEATURE usb_close(); #endif timer_stop(timer); return 1; }