definition.h
1 #ifndef _DEFINITION_H_
2 #define _DEFINITION_H_
3
4 enum Page
5 {
6 WelcomePage = 0, SelectPage, GamePage
7 };
8 enum Direct
9 {
10 ENTER = 13,
11 UP = 77,
12 LEFT = 61,
13 DOWN = 73,
14 RIGHT = 64
15 };
16 #endif
display.cpp
1 #include "WelcomePage.h"
2 #include "SelectPage.h"
3 #include "GamePage.h"
4 #include "GLobal.h"
5 #include "definition.h"
6
7 #include <cstdlib>
8 #include <gl\glut.h>
9
10 void Display( void )
11 {
12 glClear( GL_COLOR_BUFFER_BIT );
13 switch( page )
14 {
15 case WelcomePage:
16 if ( welcome_page != NULL )
17 {
18 welcome_page->Draw();
19 }
20 break;
21 case SelectPage:
22 if ( select_page != NULL )
23 {
24 select_page->Draw();
25 }
26 break;
27 case GamePage:
28 if ( game_page != NULL )
29 {
30 game_page->Draw();
31 }
32 break;
33 default:
34 break;
35 }
36 glutSwapBuffers();
37 }
init.cpp
1 #include "WelcomePage.h"
2 #include "SelectPage.h"
3 #include "GamePage.h"
4 #include "Global.h"
5
6 void Init( void )
7 {
8 welcome_page = new CWelcomePage;
9 select_page = new CSelectPage;
10 game_page = new CGamePage;
11 }
key.cpp
#include "WelcomePage.h"
#include "SelectPage.h"
#include "GamePage.h"
#include "GLobal.h"
#include "definition.h"
#include <cstdlib>
void Key( int key_char, int not_use, int not_use1 )
{
switch( page )
{
case WelcomePage:
if ( welcome_page != NULL )
{
welcome_page->SetDirect( key_char );
}
break;
case SelectPage:
if ( select_page != NULL )
{
select_page->SetDirect( key_char );
}
break;
case GamePage:
if ( game_page != NULL )
{
game_page->SetDirect( key_char );
}
break;
default:
break;
}
}
keyboard.cpp
1 #include "WelcomePage.h"
2 #include "SelectPage.h"
3 #include "GamePage.h"
4 #include "GLobal.h"
5 #include "definition.h"
6
7 #include <cstdlib>
8
9 void Keyboard( unsigned char key_char, int not_use, int not_use1 )
10 {
11 switch( page )
12 {
13 case WelcomePage:
14 if ( welcome_page != NULL )
15 {
16 welcome_page->SetDirect( key_char );
17 }
18 break;
19 case SelectPage:
20 if ( select_page != NULL )
21 {
22 select_page->SetDirect( key_char );
23 }
24 break;
25 case GamePage:
26 if ( game_page != NULL )
27 {
28 game_page->SetDirect( key_char );
29 }
30 break;
31 default:
32 break;
33 }
34 }