Original Post
Anyone know where to get sample code on game menu ? the game menu here means the page where the player get to choose to start game or quit game?
unsigned int GS_StartCursor = 0;const float WHITE[3] = { 1.0f, 1.0f, 1.0f };const float GREY[3] = { 0.5f, 0.5f, 0.5f };/* Handles user input during the START state */bool StartInput(){ // Process directional input (UP and DOWN arrow keys) if((KEY->LUP()) && (!KEY->DOWN()) && (GS_StartCursor > 0)) { --GS_StartCursor; } else if((KEY->LDOWN()) && (!KEY->UP()) && (GS_StartCursor < 2)) { ++GS_StartCursor; } // Process NEW GAME option (ENTER or SPACE was pressed) if(((KEY->RETURN()) || (KEY->SPACE())) && (GS_StartCursor == 0)) { // Play sound - stop music SOUND->PlaySound(1); FadeOut(g_FadeTime, StartRender); MUSIC->StopMusic(); // Clear RPG lists - initialize RPG RPG::Free(CLEAR_ALL); if(!RPG::CreateNew()) { return(false); } // Proceed to FIELD state if(!GAME_APP->PushState(FieldInit, FieldInput, FieldRender)) { return(false); } } // Process CONTINUE option (ENTER or SPACE was pressed) else if(((KEY->RETURN()) || (KEY->SPACE())) && (GS_StartCursor == 1)) { // Proceed to LOAD state SOUND->PlaySound(1); FadeOut(g_FadeTime, StartRender, false); if(!GAME_APP->PushState(LoadInit, LoadInput, LoadRender)) { return(false); } } // Process QUIT option (ENTER or SPACE was pressed) else if(((KEY->RETURN()) || (KEY->SPACE())) && (GS_StartCursor == 2)) { // Quit game SOUND->PlaySound(1); FadeOut(g_FadeTime, StartRender); return(false); } return(true);}/* Handles graphics rendering during the START state */void StartRender(){ // Update camera and frustum CAMERA->SetPosition(0.0f, 0.0f, 0.0f); FRUSTUM->ExtractFrustum(); // Begin rendering HUD GRAPHICS->StartHUD(); // Render title box (from an OpenGL display list) DSPL->Use(0); // Render cursor - print text if(GS_StartCursor == 0) { DrawCursor(353, 455); glColor3fv(WHITE); } else { glColor3fv(GREY); } FONT->Print(0, 369, 454, "NEW GAME"); // Render cursor - print text if(GS_StartCursor == 1) { DrawCursor(353, 477); glColor3fv(WHITE); } else { glColor3fv(GREY); } FONT->Print(0, 369, 476, "CONTINUE"); // Render cursor - print text if(GS_StartCursor == 2) { DrawCursor(353, 499); glColor3fv(WHITE); } else { glColor3fv(GREY); } FONT->Print(0, 369, 498, "QUIT"); // Finish rendering HUD GRAPHICS->EndHUD();}void Init2D(int wid, int hei){ glViewport(0, 0, wid, hei); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluOrtho2D( 0, wid, 0, hei ); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); }void End2D(){ glPopMatrix(); glMatrixMode( GL_PROJECTION ); glPopMatrix(); glMatrixMode( GL_MODELVIEW );}This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more