- static float loadprogress,minprogress,maxprogress;
-
- float size=1;
- glLoadIdentity();
- //Clear to black
- glClearColor(0,0,0,1);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- loadprogress=howmuch;
-
- //loadprogress=abs(Random()%100);
-
- //Background
-
- //glEnable(GL_TEXTURE_2D);
- glDisable(GL_TEXTURE_2D);
- //glBindTexture( GL_TEXTURE_2D, loadscreentexture);
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
- glDisable(GL_DEPTH_TEST); // Disables Depth Testing
- glDisable(GL_CULL_FACE);
- glDisable(GL_LIGHTING);
- glDepthMask(0);
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPushMatrix(); // Store The Projection Matrix
- glLoadIdentity(); // Reset The Projection Matrix
- glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPushMatrix(); // Store The Modelview Matrix
- glLoadIdentity(); // Reset The Modelview Matrix
- glTranslatef(screenwidth/2,screenheight/2,0);
- glScalef((float)screenwidth/2,(float)screenheight/2,1);
- glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_BLEND);
- glColor4f(loadprogress/100,0,0,1);
- /*if(loadscreencolor==0)glColor4f(1,1,1,1);
- if(loadscreencolor==1)glColor4f(1,0,0,1);
- if(loadscreencolor==2)glColor4f(0,1,0,1);
- if(loadscreencolor==3)glColor4f(0,0,1,1);
- if(loadscreencolor==4)glColor4f(1,1,0,1);
- if(loadscreencolor==5)glColor4f(1,0,1,1);
- */
- glPushMatrix();
- //glScalef(.25,.25,.25);
- glBegin(GL_QUADS);
- glTexCoord2f(0,0);
- glVertex3f(-1, -1, 0.0f);
- glTexCoord2f(1,0);
- glVertex3f(1, -1, 0.0f);
- glTexCoord2f(1,1);
- glVertex3f(1, 1, 0.0f);
- glTexCoord2f(0,1);
- glVertex3f(-1, 1, 0.0f);
- glEnd();
- glPopMatrix();
- glDisable(GL_TEXTURE_2D);
- glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
- glPopMatrix(); // Restore The Old Projection Matrix
- glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
- glPopMatrix(); // Restore The Old Projection Matrix
- glDisable(GL_BLEND);
- glDepthMask(1);
- //Text
- /*
- glEnable(GL_TEXTURE_2D);
- static char string[256]="";
- sprintf (string, "LOADING... %d%",(int)loadprogress);
- glColor4f(1,1,1,.2);
- text.glPrint(280-280*loadprogress/100/2/4,125-125*loadprogress/100/2/4,string,1,1+loadprogress/100,640,480);
- glColor4f(1.2-loadprogress/100,1.2-loadprogress/100,1.2-loadprogress/100,1);
- text.glPrint(280,125,string,1,1,640,480);
- */
-#ifdef WIN32
- SwapBuffers( hDC);
-#else
- aglSwapBuffers(gaglContext); // send swap command
-#endif
-
- loadscreencolor=0;
-}
-
-
-void Game::InitGame()
-{
-#ifndef WIN32
- ProcessSerialNumber PSN;
- ProcessInfoRec pinfo;
- FSSpec pspec;
- OSStatus err;
- /* set up process serial number */
- PSN.highLongOfPSN = 0;
- PSN.lowLongOfPSN = kCurrentProcess;
- /* set up info block */
- pinfo.processInfoLength = sizeof(pinfo);
- pinfo.processName = NULL;
- pinfo.processAppSpec = &pspec;
- /* grab the vrefnum and directory */
- err = GetProcessInformation(&PSN, &pinfo);
- if (err == noErr) {
- vRefNum = pspec.vRefNum;
- dirID = pspec.parID;
- }
-#endif
-
- LOGFUNC;
-
- autocam=0;
-
- int i,j;
-
- numchallengelevels=14;
-
- registered=0;
-
- /*char tempstring[256];
- sprintf (tempstring, "%s", registrationname);
- long num1;
- long num2;
- long num3;
- long num4;
- long long longnum;
- longnum = MD5_string ( tempstring);
- //longnum = 1111111111111111;
- num1 = longnum/100000000;
- num2 = longnum%100000000;
- sprintf (tempstring, "%d-%d-%d-%d", num1/10000, num1%10000, num2/10000, num2%10000);
- */
-
- FILE *tfile;
- tfile=fopen( ":Data:Sounds:flame.ogg", "rb" );
- if(tfile)
- {
- long num1;
- long num2;
- long long longnum;
- long long longnuma;
- long num1a;
- long num2a;
-
- int numchars;
- funpackf(tfile, "Bb", ®istered);
- if(registered)
- {
- funpackf(tfile, "Bi", &numchars);
- if(numchars>0)
- {
- for(j=0;j<numchars;j++)
- {
- funpackf(tfile, "Bb", ®istrationname[j]);
- }
- registrationname[numchars]='\0';
- funpackf(tfile, "Bi", &num1);
- funpackf(tfile, "Bi", &num2);
- longnum=num2+num1*100000000;
-
- char tempstring[256];
- sprintf (tempstring, "%s-windows", registrationname);
- longnuma = MD5_string ( tempstring);
- num1a = longnuma/100000000;
- num2a = longnuma%100000000;
- //if(num1a==num1&&num2a==num2)registered=1;
- if(numchars>2)registered=1;
- else registered=0;
- }
- }
- fclose(tfile);
- }
- else registered=0;
-
- accountactive=-1;
-
- sprintf (mapname, ":Data:Users");
- tfile=fopen( mapname, "rb" );
- if(tfile)
- {
- funpackf(tfile, "Bi", &numaccounts);
- funpackf(tfile, "Bi", &accountactive);
- if(numaccounts>0)
- {
- for(i=0;i<numaccounts;i++)
- {
- funpackf(tfile, "Bf", &accountcampaigntime[i]);
- funpackf(tfile, "Bf", &accountcampaignscore[i]);
- funpackf(tfile, "Bf", &accountcampaignfasttime[i]);
- funpackf(tfile, "Bf", &accountcampaignhighscore[i]);
- funpackf(tfile, "Bi", &accountdifficulty[i]);
- funpackf(tfile, "Bi", &accountprogress[i]);
- funpackf(tfile, "Bi", &accountcampaignchoicesmade[i]);
- for(j=0;j<accountcampaignchoicesmade[i];j++)
- {
- funpackf(tfile, "Bi", &accountcampaignchoices[i][j]);
- if (accountcampaignchoices[i][j] >= 10)
- {
- accountcampaignchoices[i][j] = 0;
- }
- }
- funpackf(tfile, "Bf", &accountpoints[i]);
- for(j=0;j<50;j++)
- {
- funpackf(tfile, "Bf", &accounthighscore[i][j]);
- funpackf(tfile, "Bf", &accountfasttime[i][j]);
- }
- for(j=0;j<60;j++)
- {
- funpackf(tfile, "Bb", &accountunlocked[i][j]);
- }
- int temp;
- funpackf(tfile, "Bi", &temp);
- if(temp>0)
- {
- for(j=0;j<temp;j++)
- {
- funpackf(tfile, "Bb", &accountname[i][j]);
- }
- }
- }
- }
-
- fclose(tfile);
- }
-
- tintr=1;
- tintg=1;
- tintb=1;
-
- whichjointstartarray[0]=righthip;
- whichjointendarray[0]=rightfoot;
-
- whichjointstartarray[1]=righthip;
- whichjointendarray[1]=rightankle;
-
- whichjointstartarray[2]=righthip;
- whichjointendarray[2]=rightknee;
-
- whichjointstartarray[3]=rightknee;
- whichjointendarray[3]=rightankle;
-
- whichjointstartarray[4]=rightankle;
- whichjointendarray[4]=rightfoot;
-
- whichjointstartarray[5]=lefthip;
- whichjointendarray[5]=leftfoot;
-
- whichjointstartarray[6]=lefthip;
- whichjointendarray[6]=leftankle;
-
- whichjointstartarray[7]=lefthip;
- whichjointendarray[7]=leftknee;
-
- whichjointstartarray[8]=leftknee;
- whichjointendarray[8]=leftankle;
-
- whichjointstartarray[9]=leftankle;
- whichjointendarray[9]=leftfoot;
-
- whichjointstartarray[10]=abdomen;
- whichjointendarray[10]=rightshoulder;
-
- whichjointstartarray[11]=abdomen;
- whichjointendarray[11]=rightelbow;
-
- whichjointstartarray[12]=abdomen;
- whichjointendarray[12]=rightwrist;
-
- whichjointstartarray[13]=abdomen;
- whichjointendarray[13]=righthand;
-
- whichjointstartarray[14]=rightshoulder;
- whichjointendarray[14]=rightelbow;
-
- whichjointstartarray[15]=rightelbow;
- whichjointendarray[15]=rightwrist;
-
- whichjointstartarray[16]=rightwrist;
- whichjointendarray[16]=righthand;
-
- whichjointstartarray[17]=abdomen;
- whichjointendarray[17]=leftshoulder;
-
- whichjointstartarray[18]=abdomen;
- whichjointendarray[18]=leftelbow;
-
- whichjointstartarray[19]=abdomen;
- whichjointendarray[19]=leftwrist;
-
- whichjointstartarray[20]=abdomen;
- whichjointendarray[20]=lefthand;
-
- whichjointstartarray[21]=leftshoulder;
- whichjointendarray[21]=leftelbow;
-
- whichjointstartarray[22]=leftelbow;
- whichjointendarray[22]=leftwrist;
-
- whichjointstartarray[23]=leftwrist;
- whichjointendarray[23]=lefthand;
-
- whichjointstartarray[24]=abdomen;
- whichjointendarray[24]=neck;
-
- whichjointstartarray[25]=neck;
- whichjointendarray[25]=head;
-
- FadeLoadingScreen(0);
-
- stillloading=1;
-
- texture.data = ( GLubyte* )malloc( 1024*1024*4 );
-
- int temptexdetail=texdetail;
- texdetail=1;
- text.LoadFontTexture(":Data:Textures:Font.png");
- text.BuildFont();
- texdetail=temptexdetail;
-
- FadeLoadingScreen(10);
-
- if(detail==2){
- texdetail=1;
- terraindetail=1;
- }
- if(detail==1){
- texdetail=2;
- terraindetail=1;
- }
- if(detail==0){
- texdetail=4;
- terraindetail=1;
- //terraindetail=2;
- }
-
- for (int it = 0; it < 100; ++it)
- {
- channels[it] = -1;
- samp[it] = NULL;
- }
- for (int it = 0; it < 20; ++it)
- {
- strm[it] = NULL;
- }
-
- LOG("Initializing sound system...");
-
- FSOUND_Init(44100, 32, 0);
-
- FSOUND_SetSFXMasterVolume((int)(volume*255));
-
- strm[stream_music3] = FSOUND_Stream_Open(ConvertFileName(":Data:Sounds:music3.mp3"), FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=0;}
-// FSOUND_Sample_SetMinMaxDistance(strm[stream_music3], 4.0f, 1000.0f);
- FSOUND_Stream_SetMode(strm[stream_music3], FSOUND_LOOP_NORMAL);
-
- if(musictoggle){
-// PlaySoundEx( stream_music3, strm[stream_music3], NULL, TRUE);
- PlayStreamEx(stream_music3, strm[stream_music3], 0, TRUE);
- FSOUND_SetPaused(channels[stream_music3], FALSE);
- FSOUND_SetVolume(channels[stream_music3], 256);
- }
-
- FadeLoadingScreen(20);
-
- if(ambientsound){
- strm[stream_wind] = FSOUND_Stream_Open(ConvertFileName(":Data:Sounds:wind.mp3"), FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
-// FSOUND_Sample_SetMinMaxDistance(strm[stream_wind], 4.0f, 1000.0f);
- FSOUND_Stream_SetMode(strm[stream_wind], FSOUND_LOOP_NORMAL);
-
- FadeLoadingScreen(30);
-
- strm[stream_desertambient] = FSOUND_Stream_Open(ConvertFileName(":Data:Sounds:desertambient.mp3"), FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
-// FSOUND_Sample_SetMinMaxDistance(strm[stream_desertambient], 4.0f, 1000.0f);
- FSOUND_Stream_SetMode(strm[stream_desertambient], FSOUND_LOOP_NORMAL);
- }
-
- FadeLoadingScreen(40);
-
- samp[firestartsound] = FSOUND_Sample_Load(FSOUND_FREE, ConvertFileName(":Data:Sounds:firestart.ogg"), FSOUND_2D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
- FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
-
- strm[stream_firesound] = FSOUND_Stream_Open(":Data:Sounds:fire.ogg", FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
-// FSOUND_Sample_SetMinMaxDistance(strm[stream_firesound], 8.0f, 2000.0f);
- FSOUND_Stream_SetMode(strm[stream_firesound], FSOUND_LOOP_NORMAL);
-
- FadeLoadingScreen(50);
-
- samp[fireendsound] = FSOUND_Sample_Load(FSOUND_FREE, ConvertFileName(":Data:Sounds:fireend.ogg"), FSOUND_2D, 0); if(visibleloading){LoadingScreen(); loadscreencolor=5;}
- FSOUND_Sample_SetMinMaxDistance(samp[fireendsound], 8.0f, 2000.0f);
-
- //if(musictoggle){
- strm[stream_music1grass] = FSOUND_Stream_Open(ConvertFileName(":Data:Sounds:music1grass.mp3"), FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=1;}
-// FSOUND_Sample_SetMinMaxDistance(strm[stream_music1grass], 4.0f, 1000.0f);
- FSOUND_Stream_SetMode(strm[stream_music1grass], FSOUND_LOOP_NORMAL);
-
- strm[stream_music1snow] = FSOUND_Stream_Open(ConvertFileName(":Data:Sounds:music1snow.mp3"), FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=2;}
-// FSOUND_Sample_SetMinMaxDistance(strm[stream_music1snow], 4.0f, 1000.0f);
- FSOUND_Stream_SetMode(strm[stream_music1snow], FSOUND_LOOP_NORMAL);
-
- FadeLoadingScreen(60);
-
- strm[stream_music1desert] = FSOUND_Stream_Open(ConvertFileName(":Data:Sounds:music1desert.mp3"), FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=3;}
-// FSOUND_Sample_SetMinMaxDistance(strm[stream_music1desert], 4.0f, 1000.0f);
- FSOUND_Stream_SetMode(strm[stream_music1desert], FSOUND_LOOP_NORMAL);
-
- FadeLoadingScreen(80);
- strm[stream_music2] = FSOUND_Stream_Open(ConvertFileName(":Data:Sounds:music2.ogg"), FSOUND_2D, 0, 0); if(visibleloading){LoadingScreen(); loadscreencolor=4;}
-// FSOUND_Sample_SetMinMaxDistance(strm[stream_music2], 4.0f, 1000.0f);
- FSOUND_Stream_SetMode(strm[stream_music2], FSOUND_LOOP_NORMAL);
-
- //}
-
-
- FadeLoadingScreen(90);
-
-
- LoadTexture(":Data:Textures:Cursor.png",&cursortexture,0,1);
-
- LoadTexture(":Data:Textures:MapCircle.png",&Mapcircletexture,0,1);
- LoadTexture(":Data:Textures:MapBox.png",&Mapboxtexture,0,1);
- LoadTexture(":Data:Textures:MapArrow.png",&Maparrowtexture,0,1);
-
- temptexdetail=texdetail;
- if(texdetail>2)texdetail=2;
- LoadTexture(":Data:Textures:Lugaru.png",&Mainmenuitems[0],0,0);
- LoadTexture(":Data:Textures:Newgame.png",&Mainmenuitems[1],0,0);
- LoadTexture(":Data:Textures:Options.png",&Mainmenuitems[2],0,0);
- LoadTexture(":Data:Textures:Quit.png",&Mainmenuitems[3],0,0);
- LoadTexture(":Data:Textures:World.png",&Mainmenuitems[7],0,0);
- LoadTexture(":Data:Textures:Eyelid.png",&Mainmenuitems[4],0,1);
- //LoadTexture(":Data:Textures:Eye.jpg",&Mainmenuitems[5],0,1);
- texdetail=temptexdetail;
-
- loaddistrib=0;
- anim=0;
-
- FadeLoadingScreen(95);
-
-
- gameon=0;
- mainmenu=1;
-
- stillloading=0;
- firstload=0;
- oldmainmenu=0;
-
- newdetail=detail;
- newscreenwidth=screenwidth;
- newscreenheight=screenheight;
-
-
-
- /*
- float gLoc[3]={0,0,0};
- float vel[3]={0,0,0};
- FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 9999.0f, 99999.0f);
- PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
- FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
- FSOUND_SetVolume(channels[firestartsound], 256);
- FSOUND_SetPaused(channels[firestartsound], FALSE);
- FSOUND_Sample_SetMinMaxDistance(samp[firestartsound], 8.0f, 2000.0f);
-
- flashr=1;
- flashg=0;
- flashb=0;
- flashamount=1;
- flashdelay=1;
- */