// The good old main() int main(int argc, char *argv[]) { // Initialize SDL and OpenGL init_sdl_and_gl(); // Initialize FMOD init_mixer(); // Load fonts build_font_list(); font1 = load_png("fonts.png", true, false, true); // Show the loading screen loading_screen(); // Find the level files find_levels(); // Load textures font_num = load_png("fonts_num.png", true, false, true); load_bgrounds(); load_players(); load_enemies(); load_bonus(); load_maptex(); load_bombs(); load_particles(); load_teleports(); load_traps(); load_wisps(); load_potatoman(); load_icons(); load_menus(); // Add timer to run 60 fps start_timer(60); // Menu logic int ans = show_menu(MENU_ID_MAIN); while(ans != MENU_EXIT) { // Start the game? if(ans == MENU_SINGLEPLAY) // Single player start_game(); else if(ans == MENU_MULTIPLAY) // Two players start_game(true); // Show the menu again ans = show_menu(MENU_ID_MAIN); } // Destroy timer kill_timer(); // Free stuff delete_font_list(); kill_particles(); // Kill SDL SDL_Quit(); // Close the pakfile pakfile.close_mpk(); // Close the FMOD if(music_mod){ Mix_HaltMusic(); Mix_FreeMusic(music_mod); } Mix_CloseAudio(); // Save the config save_config(get_config_location(true), &config); return 0; }
int main(int argc, char **argv) { XGCValues gcv; unsigned long gcm; int exact,left,right,device_index,i; XpmAttributes xpmattr; XpmColorSymbol xpmcsym[4]; elementinfo *e; scanArgs(argc, argv); initXWin(argc, argv); exact=left=right=device_index=-1; init_mixer(); cure=element; e=element; while(e) { if(!strcasecmp(e->info.eid.name,"Master Volume")) e->icon=0; else if(!strcasecmp(e->info.eid.name,"PCM Volume")) e->icon=1; else if(!strcasecmp(e->info.eid.name,"MIC Volume")) e->icon=5; else if(!strcasecmp(e->info.eid.name,"Line Volume")) e->icon=4; else if(!strcasecmp(e->info.eid.name,"CD Volume")) e->icon=3; else if(!strcasecmp(e->info.eid.name,"Synth Volume")) e->icon=2; else if(!strcasecmp(e->info.eid.name,"PC Speaker Volume")) e->icon=6; /* * bass = 7 * treble = 8 */ else e->icon=9; e=e->next; } gcm=GCGraphicsExposures; gcv.graphics_exposures=0; gc_gc=XCreateGC(d_display, w_root, gcm, &gcv); color[0]=mixColor(ledcolor, 0, backcolor, 100); color[1]=mixColor(ledcolor, 100, backcolor, 0); color[2]=mixColor(ledcolor, 60, backcolor, 40); color[3]=mixColor(ledcolor, 25, backcolor, 75); xpmcsym[0].name="back_color"; xpmcsym[0].value=NULL;; xpmcsym[0].pixel=color[0]; xpmcsym[1].name="led_color_high"; xpmcsym[1].value=NULL;; xpmcsym[1].pixel=color[1]; xpmcsym[2].name="led_color_med"; xpmcsym[2].value=NULL;; xpmcsym[2].pixel=color[2]; xpmcsym[3].name="led_color_low"; xpmcsym[3].value=NULL;; xpmcsym[3].pixel=color[3]; xpmattr.numsymbols=4; xpmattr.colorsymbols=xpmcsym; xpmattr.exactColors=0; xpmattr.closeness=40000; xpmattr.valuemask=XpmColorSymbols | XpmExactColors | XpmCloseness; XpmCreatePixmapFromData(d_display, w_root, wmmixer_xpm, &pm_main, &pm_mask, &xpmattr); XpmCreatePixmapFromData(d_display, w_root, tile_xpm, &pm_tile, NULL, &xpmattr); XpmCreatePixmapFromData(d_display, w_root, icons_xpm, &pm_icon, NULL, &xpmattr); pm_disp=XCreatePixmap(d_display, w_root, 64, 64, DefaultDepth(d_display, DefaultScreen(d_display))); if(wmaker || ushape || astep) XShapeCombineMask(d_display, w_activewin, ShapeBounding, winsize/2-32, winsize/2-32, pm_mask, ShapeSet); else XCopyArea(d_display, pm_tile, pm_disp, gc_gc, 0, 0, 64, 64, 0, 0); XSetClipMask(d_display, gc_gc, pm_mask); XCopyArea(d_display, pm_main, pm_disp, gc_gc, 0, 0, 64, 64, 0, 0); XSetClipMask(d_display, gc_gc, None); if(count==0) fprintf(stderr,"%s : Sorry, no supported channels found.\n", NAME); else { int done=0; XEvent xev; checkVol(); XSelectInput(d_display, w_activewin, ExposureMask | ButtonPressMask | ButtonReleaseMask | ButtonMotionMask); XMapWindow(d_display, w_main); while(!done) { while(XPending(d_display)) { XNextEvent(d_display, &xev); switch(xev.type) { case Expose: repaint(); break; case ButtonPress: pressEvent(&xev.xbutton); break; case ButtonRelease: releaseEvent(&xev.xbutton); break; case MotionNotify: motionEvent(&xev.xmotion); break; case ClientMessage: if(xev.xclient.data.l[0]==deleteWin) done=1; break; } } if(btnstate & (BTNPREV | BTNNEXT)) { rpttimer++; if(rpttimer>=RPTINTERVAL) { if(btnstate & BTNNEXT) { cure=cure->next; if(!cure) cure=element; } else { cure=cure->prev; if(!cure) { elementinfo *e; e=element; while(e->next) e=e->next; cure=e; } } checkVol(); rpttimer=0; } } else checkVol(); XFlush(d_display); usleep(50000); } } XFreeGC(d_display, gc_gc); XFreePixmap(d_display, pm_main); XFreePixmap(d_display, pm_tile); XFreePixmap(d_display, pm_disp); XFreePixmap(d_display, pm_mask); XFreePixmap(d_display, pm_icon); freeXWin(); return 0; }