diff options
Diffstat (limited to 'src/GameInitDispose.cpp')
-rw-r--r-- | src/GameInitDispose.cpp | 363 |
1 files changed, 81 insertions, 282 deletions
diff --git a/src/GameInitDispose.cpp b/src/GameInitDispose.cpp index f4d898e..69396c5 100644 --- a/src/GameInitDispose.cpp +++ b/src/GameInitDispose.cpp @@ -1,10 +1,7 @@ #include <ctype.h> -#include "Textures.h" - -#ifndef OS9 #include <time.h> -#endif +#include "Textures.h" #include "Game.h" extern unsigned int gSourceID[100]; @@ -1044,35 +1041,20 @@ void Game::LoadingScreen(float percent) } - 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 - + 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); - glColor4f(.6-.6*percent/100,0,0,1); - static char string[256]=""; - sprintf (string, "LOADING..."); - text.glPrint(280,195,string,1,1,640,480); - -#ifdef OS9 - aglSwapBuffers( gOpenGLContext ); -#else SDL_GL_SwapBuffers( ); -#endif } @@ -1691,39 +1673,22 @@ void Game::InitGame() if(!initialized)LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); //Setup random seed - -#ifdef OS9 - qd.randSeed = TickCount(); -#else srand(time(NULL)); -#endif - gamespeed=1; //Setup camera - camera.position=0; - camera.position.x=num_blocks/2*block_spacing+block_spacing/2; - camera.position.z=num_blocks/2*block_spacing+block_spacing/2; - camera.position.y=30; - camera.oldposition=camera.position; - numpeople=1; //Setup path to walk around blocks - path.load((unsigned char *)":Data:Models:path.solid"); - path.Rotate(90,0,0); - path.Scale(.8,.8,.8); - path.CalculateNormals(); - loadingscreenamount+=5; if(!initialized)LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); @@ -3119,23 +3084,12 @@ void Game::InitGame() } initialized=1; - loadingscreenamount+=5; //Sync to refresh rate - - if(vblsync){ - + if(vblsync) GLint swapInt = 1; -#ifdef OS9 - aglSetInteger(gOpenGLContext, AGL_SWAP_INTERVAL, &swapInt); -#else - -#endif - - } - /* for(int i=0;i<sprites.howmanysprites;i++){ @@ -3163,247 +3117,125 @@ void Game::InitGame() /*********************> InitGL() <*****/ int Game::InitGL(void) - { - //Config - if(!initialized){ - //Default config in case config is not found -#ifdef OS9 - HideCursor(); -#else STUB_FUNCTION; -#endif - screenwidth = 640; - screenheight = 480; - usermousesensitivity=.7; - debug=0; - vblsync=1; - blood = 1; - blurness = 0; - mainmenuness=1; - - customlevels=0; - - musictoggle=1; + customlevels=0; + musictoggle=1; //If no config, write one - ifstream ipstream("config.txt"); - - if(!ipstream) { - - ofstream opstream("config.txt"); - - opstream << "Screenwidth:\n"; - - opstream << screenwidth; - - opstream << "\nScreenheight:\n"; - - opstream << screenheight; - - opstream << "\nMouse sensitivity:\n"; - - opstream << usermousesensitivity; - - opstream << "\nShow fps and other info:\n"; - - opstream << debug; - - opstream << "\nVBL sync:\n"; - - opstream << vblsync; - - opstream << "\nBlood:\n"; - - opstream << blood; - - opstream << "\nBlur:\n"; - - opstream << blurness; - + if(!ipstream) { + ofstream opstream("config.txt"); + opstream << "Screenwidth:\n"; + opstream << screenwidth; + opstream << "\nScreenheight:\n"; + opstream << screenheight; + opstream << "\nMouse sensitivity:\n"; + opstream << usermousesensitivity; + opstream << "\nShow fps and other info:\n"; + opstream << debug; + opstream << "\nVBL sync:\n"; + opstream << vblsync; + opstream << "\nBlood:\n"; + opstream << blood; + opstream << "\nBlur:\n"; + opstream << blurness; opstream << "\nMain Menu:\n"; - - opstream << mainmenuness; - - opstream << "\nCustom levels:\n"; - - opstream << customlevels; - + opstream << mainmenuness; + opstream << "\nCustom levels:\n"; + opstream << customlevels; opstream << "\nMusic:\n"; - - opstream << musictoggle; - + opstream << musictoggle; opstream << "\azerty keyboard:\n"; - - opstream << azertykeyboard; - + opstream << azertykeyboard; opstream.close(); + } - } - - //Read config - + //Read config if(ipstream){ - ipstream.ignore(256,'\n'); - - ipstream >> screenwidth; - - ipstream.ignore(256,'\n'); - - ipstream.ignore(256,'\n'); - - ipstream >> screenheight; - - ipstream.ignore(256,'\n'); - - ipstream.ignore(256,'\n'); - - ipstream >> usermousesensitivity; - - ipstream.ignore(256,'\n'); - - ipstream.ignore(256,'\n'); - - ipstream >> debug; - - ipstream.ignore(256,'\n'); - - ipstream.ignore(256,'\n'); - - ipstream >> vblsync; - - ipstream.ignore(256,'\n'); - - ipstream.ignore(256,'\n'); - - ipstream >> blood; - - ipstream.ignore(256,'\n'); - - ipstream.ignore(256,'\n'); - - ipstream >> blurness; - - ipstream.ignore(256,'\n'); - - ipstream.ignore(256,'\n'); - - ipstream >> mainmenuness; - - ipstream.ignore(256,'\n'); - - ipstream.ignore(256,'\n'); - - ipstream >> customlevels; - - ipstream.ignore(256,'\n'); - - ipstream.ignore(256,'\n'); - - ipstream >> musictoggle; - - ipstream.ignore(256,'\n'); - - ipstream.ignore(256,'\n'); - - ipstream >> azertykeyboard; - - ipstream.close(); - + ipstream >> screenwidth; + ipstream.ignore(256,'\n'); + ipstream.ignore(256,'\n'); + ipstream >> screenheight; + ipstream.ignore(256,'\n'); + ipstream.ignore(256,'\n'); + ipstream >> usermousesensitivity; + ipstream.ignore(256,'\n'); + ipstream.ignore(256,'\n'); + ipstream >> debug; + ipstream.ignore(256,'\n'); + ipstream.ignore(256,'\n'); + ipstream >> vblsync; + ipstream.ignore(256,'\n'); + ipstream.ignore(256,'\n'); + ipstream >> blood; + ipstream.ignore(256,'\n'); + ipstream.ignore(256,'\n'); + ipstream >> blurness; + ipstream.ignore(256,'\n'); + ipstream.ignore(256,'\n'); + ipstream >> mainmenuness; + ipstream.ignore(256,'\n'); + ipstream.ignore(256,'\n'); + ipstream >> customlevels; + ipstream.ignore(256,'\n'); + ipstream.ignore(256,'\n'); + ipstream >> musictoggle; + ipstream.ignore(256,'\n'); + ipstream.ignore(256,'\n'); + ipstream >> azertykeyboard; + ipstream.close(); } - //Read high score -#ifdef OS9 - ifstream ipstream2(":Data:Highscore"); -#else - /* TODO */ + // TODO: Read high score ifstream ipstream2("Data/Highscore"); -#endif - if(!ipstream2) { - - highscore=0; - - beatgame=0; - -#ifdef OS9 - ofstream opstream(":Data:Highscore"); -#else - /* TODO */ - ofstream opstream("Data/Highscore"); -#endif - opstream << highscore; - + if(!ipstream2) { + highscore=0; + beatgame=0; + ofstream opstream("Data/Highscore"); + opstream << highscore; opstream << "\n"; - - opstream << beatgame; - + opstream << beatgame; opstream.close(); - - } - + } if(ipstream2){ - - ipstream2 >> highscore; - - ipstream.ignore(256,'\n'); - - ipstream2 >> beatgame; - - ipstream2.close(); - + ipstream2 >> highscore; + ipstream.ignore(256,'\n'); + ipstream2 >> beatgame; + ipstream2.close(); } sps=40; - maxfps=90; - disttest=1; - cubetest=1; - } //Setup screen -#ifdef OS9 - if(screenwidth<640||screenheight<480) - - theScreen = SetupScreen( 640, 480 ); - - else - - theScreen = SetupScreen( screenwidth, screenheight ); - - gOpenGLContext = SetupAGL( ( AGLDrawable )theScreen ); - - if ( !gOpenGLContext ) - - return; -#else - if (SDL_Init(SDL_INIT_VIDEO) == -1) { + if (SDL_Init(SDL_INIT_VIDEO) == -1) { fprintf(stderr, "SDL Init Video failed: %s\n", SDL_GetError()); exit(EXIT_FAILURE); - } + } atexit(SDL_Quit); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); - SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); - SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); + SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); + SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); if(screenwidth<640||screenheight<480) { #ifdef FULLSCREEN @@ -3434,66 +3266,33 @@ int Game::InitGL(void) SDL_ShowCursor(0); #endif -#endif - text.LoadFontTexture(":Data:Textures:Font.png"); - text.BuildFont(); - glAlphaFunc(GL_GREATER, 0.01); - glDepthFunc(GL_LESS); - glPolygonOffset(-8,0); - glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); - return TRUE; - } //***************> Dispose() <******/ - void Game::Dispose() - { -#ifdef OS9 - CleanupAGL( gOpenGLContext ); - - ShutdownScreen( theScreen ); - - ShowCursor(); -#endif - //Delete sound sources - alDeleteSources(100, gSourceID); - } //***************> ResizeGLScene() <******/ GLvoid Game::ReSizeGLScene(float fov, float near) - { - if (screenheight==0) - - { - screenheight=1; - } - glViewport(0,0,screenwidth,screenheight); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - gluPerspective(fov,(GLfloat)screenwidth/(GLfloat)screenheight,near,viewdistance); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); } |