📄 menu.h
字号:
#pragma once
#include "highscore.h"
void RenderMenu() //if ( game_state == menu_state )
{
glEnable( GL_TEXTURE_2D );
glColor3f( 1.0, 1.0, 1.0 );
glInitNames();
glPushName(0);
// start button
glBindTexture( GL_TEXTURE_2D, textures[21].id );
glPushName(START_BUTTON);
glBegin(GL_QUADS);
glTexCoord2f( 0.0 , 0.0 ); glVertex3f( -0.35, 0.5, -3);
glTexCoord2f( 1.0 , 0.0 ); glVertex3f( 0.35, 0.5, -3);
glTexCoord2f( 1.0 , 1.0 ); glVertex3f( 0.35, 0.7, -3);
glTexCoord2f( 0.0 , 1.0 ); glVertex3f( -0.35, 0.7, -3);
glEnd();
glPopName();
// high score button
glBindTexture( GL_TEXTURE_2D, textures[22].id );
glPushName(HIGH_SCORE_BUTTON);
glBegin(GL_QUADS);
glTexCoord2f( 0.0 , 0.0 ); glVertex3f( -0.35, 0.2, -3);
glTexCoord2f( 1.0 , 0.0 ); glVertex3f( 0.35, 0.2, -3);
glTexCoord2f( 1.0 , 1.0 ); glVertex3f( 0.35, 0.4, -3);
glTexCoord2f( 0.0 , 1.0 ); glVertex3f( -0.35, 0.4, -3);
glEnd();
glPopName();
// quit button
glBindTexture( GL_TEXTURE_2D, textures[23].id );
glPushName(QUIT_BUTTON);
glBegin( GL_QUADS );
glTexCoord2f( 0.0 , 0.0 ); glVertex3f( -0.35, -0.1, -3);
glTexCoord2f( 1.0 , 0.0 ); glVertex3f( 0.35, -0.1, -3);
glTexCoord2f( 1.0 , 1.0 ); glVertex3f( 0.35, 0.1, -3);
glTexCoord2f( 0.0 , 1.0 ); glVertex3f( -0.35, 0.1, -3);
glEnd();
glPopName();
}
void RenderGameOver()//if( game_state == gameover_state )
{
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, textures[25].id );
glBegin(GL_QUADS);
glTexCoord2f( 0.0 , 0.0 ); glVertex3f( -0.5, 0.0 , -3);
glTexCoord2f( 1.0 , 0.0 ); glVertex3f( 0.5, 0.0 , -3);
glTexCoord2f( 1.0 , 1.0 ); glVertex3f( 0.5, 0.75 , -3);
glTexCoord2f( 0.0 , 1.0 ); glVertex3f( -0.5, 0.75 , -3);
glEnd();
glDisable( GL_TEXTURE_2D );
Print("Press 'Esc' to quit ",220,350, 1.0, 1.0, 1.0 );
}
void RenderHighscoreEntry() //if ( game_state == highscore_entry_state && !entername )
{
glColor3f( 1.0, 1.0, 1.0 );
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, textures[26].id );
glBegin(GL_QUADS);
glTexCoord2f( 0.0 , 0.0 ); glVertex3f( -0.5, 0.0 , -3);
glTexCoord2f( 1.0 , 0.0 ); glVertex3f( 0.5, 0.0 , -3);
glTexCoord2f( 1.0 , 1.0 ); glVertex3f( 0.5, 0.75 , -3);
glTexCoord2f( 0.0 , 1.0 ); glVertex3f( -0.5, 0.75 , -3);
glEnd();
glDisable( GL_TEXTURE_2D );
Print("Name : ",240,380, 1.0, 1.0, 0.0 );
Print( const_cast<char *> (player_name.c_str()),320,380, 1.0,0.0,1.0);
}
void RenderHighscore()//if ( game_state == highscore_view_state )
{
// back button
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, textures[24].id );
glPushName(BACK_BUTTON);
glBegin(GL_QUADS);
glTexCoord2f( 0.0 , 0.0 ); glVertex3f( -0.35, -0.6, -3);
glTexCoord2f( 1.0 , 0.0 ); glVertex3f( 0.35, -0.6, -3);
glTexCoord2f( 1.0 , 1.0 ); glVertex3f( 0.35, -0.4, -3);
glTexCoord2f( 0.0 , 1.0 ); glVertex3f( -0.35, -0.4, -3);
glEnd();
glPopName();
glDisable( GL_TEXTURE_2D );
glEnable( GL_BLEND );
glBlendFunc (GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glColor3f(1.0f, 1.0f, 1.0f);
glBindTexture(GL_TEXTURE_2D, fontTextures[0].id);
glMatrixMode ( GL_PROJECTION ) ;
glPushMatrix();
glLoadIdentity();
glOrtho(0.0f,640,480,0.0f,-1.0f,1.0f);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glColor3f(1.0f,0.0f,0.0f);
PrintList(260,100, 0,"HIGH SCORES");
glColor3f(1.0,1.0,0.0);
char s[80];
multimap <int,string>::iterator i = high_scores.end();
i--;
PrintList(210,150,0, ScoreLine( (*i).second,(*i).first ).c_str());
i--;
PrintList(210,190,0,ScoreLine( (*i).second,(*i).first ).c_str());
i--;
PrintList(210,230,0,ScoreLine( (*i).second,(*i).first ).c_str());
glMatrixMode ( GL_PROJECTION ) ;
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glDisable( GL_BLEND );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -