/////////////////// // Process & Draw the speech bubble void Dnr_SpeechProcess(void) { glColor4f(1,1,1,1); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); DrawPic( psDnrSpeech, 144, 500 ); int size = 16; Font_SetSize(size); int length = strlen( szDnrSpeech ) * size; Font_Draw( 400 - length/2, 445, CVec(0,0,0), szDnrSpeech ); if( (System_GetMouse()->Up & SDL_BUTTON(1)) || System_GetKeyboard()->KeyUp[SDLK_ESCAPE] ) { psDiner->bSpeechBubble = false; // If we have an offer, lets go! if(psDiner->bGoodOffer) { Dnr_LetsGo(); return; } } }
void Font::Draw(const char* text, const Vec2& position, const Color& color) { if (obj) Font_Draw(obj, text, position, color); }
void Font::Draw(const Text::DrawParams* params) { if (obj) Font_Draw(obj, params); }
/////////////////// // Start the diner bool Dnr_Start(char *szDir) { keyboard_t *kb = System_GetKeyboard(); GLfloat one[] = {0.3f,0.3f,0.3f,1}; GLfloat blue[] = {0.3f, 0.3f, 1.0f, 1.0f}; GLfloat pos1[4] = {1,1,1,1}; GLfloat pos2[4] = {1,1,1,1}; GLfloat pos3[4] = {25,-100,50,1}; int i; if( !Dnr_Load(szDir) ) return false; for( i=0; i<3; i++ ) { pos1[i] = psDiner->pcLocation->getScene()->getLight(0).Position.GetIndex(i); pos2[i] = psDiner->pcLocation->getScene()->getLight(1).Position.GetIndex(i); } // Setup the diner for an opponent psDiner->nOppState = opp_waiting; psDiner->fOppTimer = tMainSR3.fCurTime + (float)GetRandomInt(2)+2.0f; sRaceInfo.pcOpponent = NULL; // HACK: Quickly get the opponent in the diner //Dnr_RollinOpponent(); //psDiner->pcLocation->SetupCamera( CVec(25,11,-1.4f),100); //psDiner->pcLocation->setCamPos( CVec(0,0,0) ); // Setup the fog State_Disable(GL_FOG); // Setup the lighting State_Enable(GL_LIGHTING); State_Enable(GL_LIGHT1); State_Enable(GL_LIGHT2); glLightfv(GL_LIGHT0, GL_DIFFUSE, one); glLightfv(GL_LIGHT1, GL_DIFFUSE, one); glLightfv(GL_LIGHT2, GL_DIFFUSE, one); glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 1.00f); glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.0f); glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, 1.00f); glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.0f); glLightf(GL_LIGHT2, GL_CONSTANT_ATTENUATION, 0.80f); glLightf(GL_LIGHT2, GL_LINEAR_ATTENUATION, 0.01f); glMaterialf(GL_FRONT, GL_SHININESS, 25.0); glMaterialfv(GL_FRONT, GL_SPECULAR, one); System_ProcessInput(); while(psDiner->bProcessDiner) { System_ProcessInput(); // // Processing // psDiner->pcLocation->Process(); psDiner->cSky.Simulate(tMainSR3.fDeltaTime); if( !psDiner->bSpeechBubble ) { Dnr_ProcessOpponent(); Dnr_ProcessGUI(); } cMainGuy->processFrame(); // // 3D Drawing // glLightfv(GL_LIGHT0, GL_POSITION, pos1); glLightfv(GL_LIGHT1, GL_POSITION, pos2); glLightfv(GL_LIGHT2, GL_POSITION, pos3); SetupFrame(); // Manually setup the camera psDiner->pcLocation->getCamera()->LookAt(psDiner->pcLocation->getCamLook()); psDiner->pcLocation->getCamera()->Show(); psDiner->cSky.Render( psDiner->pcLocation->getCamera() ); State_Enable(GL_LIGHTING); psDiner->pcLocation->Draw(true, true, false); Dnr_DrawOpponent(); // // 2D Drawing // Render_Begin2D(); // Draw the sidedoor bit State_Enable(GL_TEXTURE_2D); State_Disable(GL_LIGHTING); State_Enable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(1,1,1,1); BlitTexture(psDiner->psSideDoor, 0,0, 0,472, 105,128, 1,1); for(i=0; i<10; i++ ) { BlitTexture(psDiner->psSideDoor, 105,0, i*95+105,472, 95,128, 1,1); } if( psDiner->bSpeechBubble ) Dnr_SpeechProcess(); psDiner->pcLocation->FinalDraw(); if(psOptions->nShowFPS) { Font_SetAlpha(1); Font_SetSize(14); int fps = GetFPS(); Font_Draw(5, 583, CVec(0,0,0), "FPS: %d", fps); Font_Draw(5, 585, CVec(1,1,1), "FPS: %d", fps); } if(psOptions->nDeveloper) { Font_SetAlpha(1); Font_SetSize(14); Font_Draw(5, 563, CVec(0,0,0), "Tris: %d", tMainSR3.TriCount); Font_Draw(5, 565, CVec(1,1,1), "Tris: %d", tMainSR3.TriCount); } // Draw the gui if(!psDiner->bSpeechBubble && psDiner->bProcessDiner) { if( psDiner->bOppClicked ) cDinerLayout.Draw(); cDinerLayout2.Draw(); } gui_DrawMouse(); Render_End2D(); SDL_GL_SwapBuffers(); } // // Show a loading sign on the screen // Render_Begin2D(); Font_SetSize(14); Font_SetAlpha(1); Font_DrawCentered(400, 300, CVec(1,1,1), "Loading..."); Render_End2D(); SDL_GL_SwapBuffers(); // Are we going to race? if(psDiner->bRacing) // Off to the track Game_SetLocation(LOC_RACE); else // Back to the garage Game_SetLocation(LOC_GARAGE); Dnr_Shutdown(); return true; }