int main (int argc, char *argv[]) { char *ptr, *data = LoadInput(); int i; /* * Handle CGI data */ if (data) { ptr = strtok (data, "&"); while (ptr) { HandleString (ptr); ptr = strtok (NULL, "&"); } free (data); } /* * Add Path info */ if (getenv ("PATH_INFO") != NULL) { data = FP_strdup (getenv ("PATH_INFO")); ptr = strtok (data, "/"); while (ptr) { HandleString (ptr); ptr = strtok (NULL, "/"); } free (data); } /* * Add args */ for (i=1; i<argc; i++) { HandleString (argv[i]); } /* * done */ return 0; }
// Main function int main( int argc, char ** argv ) { // Initialize the memory leak detector for Win32 only (ignored by default in linux) bitInitMemoryLeak( BIT_NULL ); // Setting the absolute path in order to read files. Bit::SetAbsolutePath( argv[ 0 ] ); // Initialize the application if( LoadAudio( ) != BIT_OK || LoadInput( ) != BIT_OK ) { return CloseApplication( 0 ); } while( 1 ) { // Update the keyboard pKeyboard->Update( ); // Should we exit the program? if( pKeyboard->KeyIsJustReleased( Bit::Keyboard::Key_Escape ) ) { break; } // Play sound if( pKeyboard->KeyIsJustReleased( Bit::Keyboard::Key_P ) ) { pAudio->Play( ); } } // We are done bitTrace( "Closing the program.\n" ); return CloseApplication( 0 ); }
Input::Input() { LoadInput("../Resources/XML/Input.xml"); g_input = this; }
int install() { int screen_mode; if(IsInstalled) return 0; if(allegro_init()) return 1; if(install_allegro_gl()) return 1; set_window_title("Sharp Fighters"); Resolutions=get_gfx_mode_list(GFX_OPENGL_FULLSCREEN); LoadSettings(); LoadCollisionData(); if(install_keyboard()) return 1; if(install_timer()) return 1; if(install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL)) return 1; JoyStickEnabled=(install_joystick(JOY_TYPE_AUTODETECT)==0); JoyStickEnabled=JoyStickEnabled && num_joysticks; LoadInput(); if(install_fonts()) printf("One or more font files were not loaded.\n"); allegro_gl_set(AGL_COLOR_DEPTH, depth); allegro_gl_set(AGL_RENDERMETHOD, 1); allegro_gl_set(AGL_DOUBLEBUFFER, 1); allegro_gl_set(AGL_SUGGEST, AGL_COLOR_DEPTH | AGL_DOUBLEBUFFER | AGL_RENDERMETHOD); if(Fullscreen) screen_mode=GFX_OPENGL_FULLSCREEN; else screen_mode=GFX_OPENGL_WINDOWED; if (set_gfx_mode(screen_mode, Width,Height, 0, 0)) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Unable to set graphic mode\n%s\n", allegro_error); return 1; } set_close_button_callback(close_button_handler); SetOpenGL2D(); screenimage=(IMAGE*)malloc(sizeof(IMAGE)); screenimage->ID=0; AspectRatio=(float)SCREEN_W/(float)SCREEN_H; if(install_int(Ticks,1)) return 1; if(install_int(ProcessKeys,25)) return 1; IsInstalled=1; return 0; }