void client_render_quit() { graphics_quit(); if ( md1 != NULL ) delete md1; if ( md2 != NULL ) delete md2; }
void kissSim_end() { printf("Simulation end - "); _world.simPaused=0; if (glfwGetWindowParam(GLFW_OPENED)) { // if we still have graphics graphics_quit(); // clear out GLFW graphics } }
//if something goes wrong (after initing physics and graphics) void emergency_quit (void) { printlog(0, "ERROR REQUIRES GAME TO STOP:\n"); free_all(); graphics_quit(); physics_quit(); exit (-1); printlog(0, "WTF?!\n"); }
int clean_up() { // free images / animations bomb_quit(); bomber_quit(); level_quit(); sound_quit(); graphics_quit(); input_quit(); config_quit(); return 0; }
//simple demo: int main (int argc, char *argv[]) { //issue printf("\n -=[ Hello, and welcome to RollCageX version %s ]=-\n\n", VERSION); printf(" Copyright (C) 2009, This program comes with ABSOLUTELY NO WARRANTY; see\n \"license.txt\" for details\n\n"); printf(" This is free software, and you are welcome to redistribute it and/or modify\n it under the GNU General Public License as published by the Free Software\n Foundation, version 3 or (at your option) later\n\n"); printf("= Credits (nicknames refers to usernames on the gorcx.net forum):\n"); printf(" \"MaAkaJon\"\t\tproject creator\n"); printf(" \"Soul Slinger\"\tcoder (created this and the earlier versions)\n"); printf(" All of you on the planetrollcage.com and gorcx.net forums!\n\n"); printf("* Projects that made RCX possible:\n"); printf(" GNU\t\t\t\tdefines computer freedom itself... :-)\n"); printf(" Simple DirectMedia Layer\twindow handling, input/outputs\n"); printf(" Open Dynamics Engine\trigid body dynamics\n"); printf("= End of credits\n\n"); printf(" Default controls (can be changed in profile):\n"); printf(" > Arrow keys: Steering and throttling\n"); printf(" > Spacebar: Drifting break\n"); printf(" > Left Alt: Soft breaks\n"); printf(" > Q and E: change camera distance along Z axis\n"); printf(" > A and D: change camera distance along X axis\n"); printf(" > W and S: change camera distance along Y axis\n"); printf(" > F1 to F4: change camera settings\n"); printf(" > F5: spawn box\n"); printf(" > F6: spawn box (10s above ground)\n\n"); //end of issue if (argc != 1) printf("(Passing arguments - not supported)\n\n"); //printlog needs internal.verbosity, set it to default value printf("(verbosity level is assumed \"1\" until read from internal conf)\n"); internal.verbosity = 1; //check if program was called with another pwd (got '/' in "name") int count; for (count = strlen(argv[0]); count != -1; --count) if (argv[0][count] == '/') { char pwd[count+2]; //1 for \0 and 1 for [0] strncpy (pwd, argv[0], count+1); pwd[count+1] = '\0'; printf ("(changing pwd: %s)\n", pwd); chdir (pwd); break; } if (load_conf ((char *)"data/internal.conf", (char *)&internal, internal_index)) return -1; if (graphics_init()) return -1; //<insert menu here> profile *prof = load_profile ((char *)"data/profiles/default"); if (!prof) return -1; venom = load_car((char *)"data/teams/Nemesis/cars/Venom"); if (!venom) emergency_quit(); prof->car = venom; camera.car = venom; //menu done, race selected, starting race... if (physics_init()) { graphics_quit(); return -1; } if (load_track((char *)"data/worlds/Sandbox/tracks/Box")) emergency_quit(); //load box for online spawning box = load_object((char *)"data/objects/misc/box"); sphere = load_object((char *)"data/objects/misc/sphere"); if (!box) emergency_quit(); spawn_car (venom, track.start[0], track.start[1], track.start[2]); focused_car = venom; //single-thread function //WARNING: Don't run the game constantly for more than around 49 days! //(or the realtime will wrap, and the timing solution will go crazy) Uint32 simtime = SDL_GetTicks(); //set simulated time to realtime Uint32 realtime; //real time (with possible delay since last update) Uint32 stepsize_ms = internal.stepsize*1000+0.0001; //calculate stepsize from s to ms (append 0.0001 for correct conversion) printlog (0, "\n-> Starting Race\n"); runlevel = running; while (runlevel == running) { event_step(stepsize_ms); //always check for events physics_step(); simtime += stepsize_ms; //if realtime is larger than simtime (and graphics threshold) if (SDL_GetTicks()+internal.threshold > simtime) { printlog(2, "\nWarning: simtime less than realtime (to low stepsize), dropping frame..\n\n"); ++stepsize_warnings; } else //we got time left to draw frame on { graphics_step(stepsize_ms); realtime = SDL_GetTicks(); if (simtime > realtime) { SDL_Delay (simtime - realtime); } else { printlog(2, "\nWarning: (not sleeping, realtime became to high (to low treshold?))\n"); ++threshold_warnings; } } } printlog(0, "-> Race done!\n"); free_all(); physics_quit(); //race done //<insert menu here> //menu done, quit selected, ending graphics and terminating program graphics_quit(); printlog(0, "\n<-- Some basic info: -->\n"); printlog(0, "(does not interest most people)\n"); printlog(0, "Race time (ms): %i\n", simtime); printlog(0, "Stepsize-to-low (framedrop) warnings: %i\n", stepsize_warnings); printlog(0, "Graphics-threshold-to-low warnings: %i\n", threshold_warnings); printlog(0, "\nBye!\n\n"); return 0; }
//simple demo: int main (int argc, char *argv[]) { //issue printf("\n -=[ Hello, and welcome to RollCageX version %s ]=-\n\n%s\n", VERSION, ISSUE); //end if (argc != 1) printf("(Passing arguments - not supported)\n\n"); //check if program was called with another pwd (got '/' in "name") if (char *s = strrchr(argv[0], '/')) { *s='\0'; //modify string to end at last slash printf("(changing pwd: %s)\n", argv[0]); chdir (argv[0]); } printlog(0, "Loading...\n"); load_conf ("data/internal.conf", (char *)&internal, internal_index); if (!graphics_init()) return -1; //TODO: there should be menus here, but menu/osd system is not implemented yet... also: //on failure, rcx should not just terminate but instead abort the race and warn the user //MENU: welcome to rcx, please select profile or create a new profile Profile *prof = Profile_Load ("data/profiles/default"); if (!prof) return -1; //GOTO: profile menu if (!physics_init()) { //menu: warn and quit! graphics_quit(); return -1; } //MENU: select race type // - assuming 2P free roam - //MENU: P1: select theme/car Car_Template *venom_template = Car_Template::Load("data/teams/Nemesis/cars/Venom"); if (!venom_template) return -1; //GOTO: car selection menu //MENU: P2: select theme/car Car_Template *reaper_template = Car_Template::Load("data/teams/Vostok/cars/Reaper"); if (!reaper_template) return -1; //GOTO: car selection //MENU: select world/track if (!load_track((char *)"data/worlds/Sandbox/tracks/Box")) return -1; //GOTO: track selection menu //TMP: load box for online spawning box = Object_Template::Load("data/objects/misc/box"); sphere = Object_Template::Load("data/objects/misc/sphere"); funbox = Object_Template::Load("data/objects/misc/funbox"); if (!box || !sphere || !funbox) return -1; //spawn car Venom = venom_template->Spawn(track.start[0]-4, track.start[1], track.start[2]); prof->car = Venom; camera.car = Venom; //lets spawn another car: Reaper = reaper_template->Spawn(track.start[0]+4, track.start[1], track.start[2]); //MENU: race configured, start? start_race(); //race done, remove all objects... Object::Destroy_All(); //MENU: race done, replay, play again, quit? // - assuming quit - //remove loaded data (not all data, only "racetime" - for this race) Racetime_Data::Destroy_All(); //MENU: back to main menu here // - assuming player wants to log out - physics_quit(); Profile_Remove_All(); //should only be one active profile right now, but any case, remove all //MENU: select profile // - assumes player wants to quit - graphics_quit(); //some basic info (until menu for printing it) print_info(); printf("\nBye!\n\n"); return 0; }