diff options
45 files changed, 778 insertions, 2302 deletions
diff --git a/src/AGL_DSp.cpp b/src/AGL_DSp.cpp index eace870..8e86b0a 100644 --- a/src/AGL_DSp.cpp +++ b/src/AGL_DSp.cpp @@ -2,19 +2,16 @@ #include "AGL_DSp.h" #include "Alerts.h" - /**> GLOBAL VARIABLES <**/ DSpContextAttributes gDSpContextAttributes; // Global DrawSprocket context attributes DSpContextReference gDSpContext; // The global DrawSprocket context AGLContext gOpenGLContext; // The global OpenGL (AGL) context - /********************> ToolboxInit() <*****/ void ToolboxInit( void ) { - MaxApplZone(); - + InitGraf( &qd.thePort ); InitFonts(); InitWindows(); @@ -22,39 +19,38 @@ void ToolboxInit( void ) TEInit(); InitDialogs( 0L ); InitCursor(); - } /********************> HasAppearance() <*****/ Boolean HasAppearance( void ) { - + OSErr error; SInt32 response; Boolean appearancePresent = false; Boolean appearance101present = false; Boolean appearance110present = false; Boolean inCompatibilityMode = false; - + error = Gestalt( gestaltAppearanceAttr, &response ); - + // If Gestalt returns no error and the bit in response represented by the constant // gestaltAppearanceExists is set, proceed, otherwise exit with an error message. - + if ( error == noErr && ( BitTst( &response, 31 - gestaltAppearanceExists ) ) ) { // At least Version 1.0 is present. Set a flag. appearancePresent = true; - + // If the bit in response represented by the constant gestaltAppearanceCompatMode // is set, system-wide Appearance is off. The result of this check will be // relevant only where Versions 1.0 through 1.0.3 are present. if( BitTst( &response, 31 - gestaltAppearanceCompatMode ) ) inCompatibilityMode = true; - + // Call Gestalt again with the gestaltAppearanceVersion selector. Gestalt( gestaltAppearanceVersion, &response ); - + // If the low order word in response is 0x0101, Version 1.0.1, 1.0.2, or 1.0.3 is // present. If the low order word in response is 0x0110, Version 1.1 is available. if( response == 0x00000101 ) @@ -67,26 +63,26 @@ Boolean HasAppearance( void ) StopAlert( kNoAppearanceAlert, nil ); ExitToShell(); }*/ - + // Register this app as an Appearance Client //RegisterAppearanceClient(); - + return appearancePresent; - + } /********************> SetupScreen() <*****/ CGrafPtr SetupScreen( int width, int height ) { - + OSStatus theError; CGrafPtr theFrontBuffer; - + // Start DrawSprocket theError = DSpStartup(); if( theError ) FatalErrorAlert( kErr_DSpStartupFailed, theError ); - + // Set the Context Attributes gDSpContextAttributes.displayWidth = width; gDSpContextAttributes.displayHeight = height; @@ -96,104 +92,104 @@ CGrafPtr SetupScreen( int width, int height ) gDSpContextAttributes.displayBestDepth = 32; gDSpContextAttributes.backBufferBestDepth = 32; gDSpContextAttributes.pageCount = 1; - + // Find the best context for our attributes theError = DSpFindBestContext( &gDSpContextAttributes, &gDSpContext ); if( theError != noErr ) FatalErrorAlert( kErr_DSpFindBestContextFailed, theError ); // This function is in my Alerts.cpp - + // Reserve that context theError = DSpContext_Reserve( gDSpContext, &gDSpContextAttributes ); if( theError != noErr ) FatalErrorAlert( kErr_DSpContext_ReserveFailed, theError ); - + // Fade out - theError = DSpContext_FadeGammaOut( NULL, NULL ); + theError = DSpContext_FadeGammaOut( NULL, NULL ); if( theError != noErr ) FatalErrorAlert( kErr_DSpFadeFailed, theError ); - + // Activate the context theError = DSpContext_SetState( gDSpContext, kDSpContextState_Active ); if( theError != noErr ) { // Fade back in the display before dying theError = DSpContext_FadeGammaIn( NULL, NULL ); - + // Now do the fatal error alert FatalErrorAlert( kErr_ActivateContextFailed, theError ); } - + // Fade in theError = DSpContext_FadeGammaIn( NULL, NULL ); if( theError != noErr ) FatalErrorAlert( kErr_DSpFadeFailed, theError ); - + // Create a window to draw in CreateWindow( theFrontBuffer, width, height ); - + return theFrontBuffer; - + } /********************> CreateWindow() <*****/ void CreateWindow( CGrafPtr &theFrontBuffer, int width, int height ) { - + Rect rect; AuxWinHandle awh; CTabHandle theColorTable; OSErr error; RGBColor backColor = { 0xFFFF, 0xFFFF, 0xFFFF }; RGBColor foreColor = { 0x0000, 0x0000, 0x0000 }; - + // Set the window rect rect.top = rect.left = 0; DSpContext_LocalToGlobal( gDSpContext, ( Point* )&rect ); rect.right = rect.left + width; rect.bottom = rect.top + height; - + // Create a new color window theFrontBuffer = ( CGrafPtr )NewCWindow( NULL, &rect, "\p", 0, plainDBox, kMoveToFront, 0, 0 ); - - // set the content color of the window to black to avoid a white flash when the window appears. + + // set the content color of the window to black to avoid a white flash when the window appears. if ( GetAuxWin( ( WindowPtr )theFrontBuffer, &awh ) ) { theColorTable = ( **awh ).awCTable; error = HandToHand( ( Handle* )&theColorTable ); if ( error ) DebugStr( "\pOut of memory!" ); - + ( **theColorTable ).ctTable[wContentColor].rgb.red = 0; ( **theColorTable ).ctTable[wContentColor].rgb.green = 0; ( **theColorTable ).ctTable[wContentColor].rgb.blue = 0; - + CTabChanged( theColorTable ); - + // the color table will be disposed by the window manager when the window is disposed SetWinColor( ( WindowPtr )theFrontBuffer, ( WCTabHandle )theColorTable ); } - + // Show the window ShowWindow( ( GrafPtr )theFrontBuffer ); SetPort( ( GrafPtr )theFrontBuffer ); - + // Set current pen colors RGBForeColor( &foreColor ); RGBBackColor( &backColor ); - + } /********************> ShutdownScreen() <*****/ void ShutdownScreen( CGrafPtr theFrontBuffer ) { - + DSpContext_FadeGammaOut( NULL, NULL ); DisposeWindow( ( WindowPtr )theFrontBuffer ); DSpContext_SetState( gDSpContext, kDSpContextState_Inactive ); DSpContext_FadeGammaIn( NULL, NULL ); DSpContext_Release( gDSpContext ); DSpShutdown(); - + } /********************> SetupAGL() <*****/ @@ -218,7 +214,7 @@ AGLContext SetupAGL( AGLDrawable window ) ok = aglSetDrawable( context, window ); if ( !ok ) return NULL; - + // Make the context the current context ok = aglSetCurrentContext( context ); if ( !ok ) @@ -228,15 +224,12 @@ AGLContext SetupAGL( AGLDrawable window ) aglDestroyPixelFormat( format ); return context; - } /********************> CleanupAGL() <*****/ void CleanupAGL( AGLContext context ) { - aglSetCurrentContext( NULL ); aglSetDrawable( context, NULL ); aglDestroyContext( context ); - } diff --git a/src/AGL_DSp.h b/src/AGL_DSp.h index 4c1d531..f001017 100644 --- a/src/AGL_DSp.h +++ b/src/AGL_DSp.h @@ -3,7 +3,6 @@ #ifndef _AGL_DSP_H_ #define _AGL_DSP_H_ - /**> HEADER FILES <**/ #include <stdlib.h> // ANSI C cross platform headers #include <stdio.h> @@ -12,7 +11,6 @@ #include <glu.h> // Used for setting perspective and making objects #include <tk.h> // Used for loading images - /**> CONSTANT DECLARATIONS <**/ #define kMoveToFront kFirstWindowOfClass @@ -20,14 +18,12 @@ #define SCREEN_WIDTH 640 #define SCREEN_HEIGHT 480 - /**> GLOBAL VARIABLES <**/ extern DSpContextAttributes gDSpContextAttributes; // Global DrawSprocket context attributes extern DSpContextReference gDSpContext; // The global DrawSprocket context extern AGLContext gOpenGLContext; // The global OpenGL (AGL) context // Note: These are actually defined in AGL_DSp.cpp - /**> FUNCTION PROTOTYPES <**/ void ToolboxInit( void ); Boolean HasAppearance( void ); @@ -37,5 +33,4 @@ void ShutdownScreen( CGrafPtr theFrontBuffer ); AGLContext SetupAGL( AGLDrawable window ); void CleanupAGL( AGLContext context ); - #endif \ No newline at end of file diff --git a/src/Alerts.cpp b/src/Alerts.cpp index acfefae..2e01ca9 100644 --- a/src/Alerts.cpp +++ b/src/Alerts.cpp @@ -1,11 +1,9 @@ /**> HEADER FILES <**/ #include "Alerts.h" - /********************> SelectResolution() <*****/ int SelectResolution( void ) { - DialogPtr dialog; Boolean dialogDone = false; short itemHit, itemType; @@ -13,29 +11,28 @@ int SelectResolution( void ) Handle resolutionItem; Rect itemRect; int selectionNum; - + // Load the dialog dialog = GetNewDialog( kResID_DLOG_SelectResolution, nil, kMoveToFront ); - + // Display the dialog ShowWindow( dialog ); SetPort( dialog ); - + // Load dialog items SetDialogDefaultItem( dialog, iOK ); SetDialogTracksCursor( dialog, true ); GetDialogItem( dialog, iOK, &itemType, &okItem, &itemRect ); GetDialogItem( dialog, iResolutionPopUp, &itemType, &resolutionItem, &itemRect ); - + // Set item values SetControlValue( ( ControlHandle )resolutionItem, i640x480 ); - - + while ( !dialogDone ) { - + ModalDialog( nil, &itemHit ); - + switch( itemHit ) { case iOK: @@ -47,9 +44,9 @@ int SelectResolution( void ) // We don't actually need to do anything here break; } - + } - + DisposeDialog( dialog ); // Return the item selected in the popup menu @@ -59,35 +56,34 @@ int SelectResolution( void ) /********************> MessageAlert() <*****/ void MessageAlert( unsigned char *theMessage ) { - + // Set parameter ^0 to our message (I could set up to three, but for simplicity's sake I won't) ParamText( ( unsigned char * )theMessage, NULL, NULL, NULL ); - + // Do the Alert NoteAlert( kResID_ALRT_MessageAlert, nil ); - + } /********************> FatalErrorAlert() <*****/ void FatalErrorAlert( UInt16 errorNum, OSErr osError ) { - + Str15 errNumStr; Str255 mainMessage; - + // Convert the OSErr to a string NumToString( osError, errNumStr ); - + // Get the error description (inErrorDesc) from the STR# resource GetIndString( mainMessage, kResID_STRn_ErrorStrings, errorNum ); - + // Set the parameters (^0 and ^1) in the ALRT to our error messages ParamText( mainMessage, errNumStr, NULL, NULL ); - + // Do the alert (which now has our messages in it) StopAlert( kResID_ALRT_ErrorAlert, NULL ); - + // Quit exit( EXIT_SUCCESS ); - } diff --git a/src/Alerts.h b/src/Alerts.h index 5db7938..02cad9f 100644 --- a/src/Alerts.h +++ b/src/Alerts.h @@ -1,12 +1,10 @@ #ifndef _MYALERTS_H_ #define _MYALERTS_H_ - /**> HEADER FILES <**/ #include <string.h> #include <stdlib.h> - /**> CONSTANT DECLARATIONS <**/ #define kMoveToFront kFirstWindowOfClass // Alerts @@ -26,7 +24,7 @@ // Misc #define kInsignificantConstant7454955 0 -// Error numbers +// Error numbers #define kErr_DSpFindBestContextFailed 1 #define kErr_DSpContext_ReserveFailed 2 #define kErr_ActivateContextFailed 3 @@ -34,11 +32,9 @@ #define kErr_DSpFadeFailed 5 #define kErr_AGLContext_CreationFailed 6 - /**> FUNCTION PROTOTYPES <**/ int SelectResolution( void ); void MessageAlert( unsigned char *theMessage ); void FatalErrorAlert( UInt16 errorNum, OSErr osError ); - #endif \ No newline at end of file diff --git a/src/Camera.cpp b/src/Camera.cpp index 950c12d..ca2b9af 100644 --- a/src/Camera.cpp +++ b/src/Camera.cpp @@ -1,9 +1,7 @@ /**> HEADER FILES <**/ #include "Camera.h" - void Camera::Apply() { glTranslatef(-position.x,-position.y,-position.z); } - diff --git a/src/Camera.h b/src/Camera.h index a31055f..72319a3 100644 --- a/src/Camera.h +++ b/src/Camera.h @@ -1,9 +1,8 @@ #ifndef _CAMERA_H_ #define _CAMERA_H_ - /**> HEADER FILES <**/ -#ifdef OS9 +#ifdef OS9 #include <gl.h> #else #include <GL/gl.h> @@ -17,7 +16,7 @@ class Camera XYZ position; XYZ oldposition; XYZ targetoffset; - + float rotation, rotation2; float oldrotation, oldrotation2; float oldoldrotation, oldoldrotation2; @@ -26,4 +25,3 @@ class Camera }; #endif - diff --git a/src/Constants.h b/src/Constants.h index 76c67de..71e434d 100644 --- a/src/Constants.h +++ b/src/Constants.h @@ -133,4 +133,3 @@ #define soundscalefactordefault 10 #endif - diff --git a/src/Decals.cpp b/src/Decals.cpp index 3cebb4c..7617420 100644 --- a/src/Decals.cpp +++ b/src/Decals.cpp @@ -26,21 +26,20 @@ int Decals::MakeDecal(int atype, XYZ location, float size, XYZ normal, int poly, XYZ nothing; XYZ axis[3]; XYZ temp; - + nothing=0; - + axis[0].x=1; axis[1].y=1; axis[2].z=1; - + normalv[0]=abs(normal.x); normalv[1]=abs(normal.y); normalv[2]=abs(normal.z); - - + if(normalv[1]>normalv[major])major=1; if(normalv[2]>normalv[major])major=2; - + if (normalv[0] == 1 || normalv[1] == 1 || normalv[2] == 1) { if ((major == 0 && normal.x > 0) || major == 1){ @@ -55,11 +54,11 @@ int Decals::MakeDecal(int atype, XYZ location, float size, XYZ normal, int poly, } else CrossProduct(axis[major], normal, &right); - + CrossProduct(normal, right, &up); - Normalise(&up); + Normalise(&up); Normalise(&right); - + float count; float count2; float countinc=1/size; @@ -67,7 +66,7 @@ int Decals::MakeDecal(int atype, XYZ location, float size, XYZ normal, int poly, if(countinc>.2)countinc=.2; float normaloffset=.02; int good; - + numpoints[howmanydecals]=0; points[howmanydecals*8+numpoints[howmanydecals]] = location + (nothing - right - up) * (size/3) /*+ normal/100*/; texcoordsx[howmanydecals*8+numpoints[howmanydecals]] = 0; @@ -113,7 +112,7 @@ int Decals::MakeDecal(int atype, XYZ location, float size, XYZ normal, int poly, if(good!=-1)numpoints[howmanydecals]++; } } - + points[howmanydecals*8+numpoints[howmanydecals]] = location + (nothing + right - up) * (size/3) /*+ normal/100*/; texcoordsx[howmanydecals*8+numpoints[howmanydecals]] = 1; texcoordsy[howmanydecals*8+numpoints[howmanydecals]] = 0; @@ -158,7 +157,7 @@ int Decals::MakeDecal(int atype, XYZ location, float size, XYZ normal, int poly, if(good!=-1)numpoints[howmanydecals]++; } } - + points[howmanydecals*8+numpoints[howmanydecals]] = location + (nothing + right + up) * (size/3) /*+ normal/100*/; texcoordsx[howmanydecals*8+numpoints[howmanydecals]] = 1; texcoordsy[howmanydecals*8+numpoints[howmanydecals]] = 1; @@ -203,7 +202,7 @@ int Decals::MakeDecal(int atype, XYZ location, float size, XYZ normal, int poly, if(good!=-1)numpoints[howmanydecals]++; } } - + points[howmanydecals*8+numpoints[howmanydecals]] = location + (nothing - right + up) * (size/3) /*+ normal/100*/; texcoordsx[howmanydecals*8+numpoints[howmanydecals]] = 0; texcoordsy[howmanydecals*8+numpoints[howmanydecals]] = 1; @@ -251,7 +250,7 @@ int Decals::MakeDecal(int atype, XYZ location, float size, XYZ normal, int poly, for(int i=0;i<numpoints[howmanydecals];i++){ points[howmanydecals*8+i] += normal*normaloffset; } - + type[howmanydecals]=atype; alivetime[howmanydecals]=0; if(howmanydecals<maxdecals){howmanydecals++;} @@ -271,7 +270,7 @@ int Decals::DeleteDecal(int which){ } if(howmanydecals>0){howmanydecals--;} } - + return 0; } @@ -302,9 +301,9 @@ void Decals::DoStuff() void Decals::draw() { glAlphaFunc(GL_GREATER, 0.01); - + float bloodpoolspeed=1; - + glDepthFunc(GL_LEQUAL); glEnable(GL_BLEND); glEnable(GL_CULL_FACE); @@ -320,7 +319,7 @@ void Decals::draw() if(type[i]==bullethole)glBindTexture(GL_TEXTURE_2D, bulletholetextureptr); if(type[i]==crater)glBindTexture(GL_TEXTURE_2D, cratertextureptr); if(type[i]!=bloodpool)glColor4f(1,1,1,10-alivetime[i]); - + if(type[i]==bloodpool&&alivetime[i]<bloodpoolspeed*.2)glBindTexture(GL_TEXTURE_2D, bloodtextureptr[0]); if(type[i]==bloodpool&&alivetime[i]>=bloodpoolspeed*.2&&alivetime[i]<bloodpoolspeed*.4)glBindTexture(GL_TEXTURE_2D, bloodtextureptr[1]); if(type[i]==bloodpool&&alivetime[i]>=bloodpoolspeed*.4&&alivetime[i]<bloodpoolspeed*.6)glBindTexture(GL_TEXTURE_2D, bloodtextureptr[2]); @@ -334,7 +333,7 @@ void Decals::draw() if(type[i]==bloodpool&&alivetime[i]>=bloodpoolspeed*2.0)glBindTexture(GL_TEXTURE_2D, bloodtextureptr[10]); if(type[i]==bloodpool&&alivetime[i]<bloodpoolspeed*2.0)glColor4f(1,1,1,1.5-(alivetime[i]*5/bloodpoolspeed-(int)(alivetime[i]*5/bloodpoolspeed))); if(type[i]==bloodpool&&alivetime[i]>=bloodpoolspeed*2.0)glColor4f(1,1,1,20-alivetime[i]); - + glPushMatrix(); glBegin(GL_TRIANGLE_FAN); for(int j=0;j<numpoints[i];j++){ @@ -342,7 +341,7 @@ void Decals::draw() } glEnd(); glPopMatrix(); - + if(type[i]==bloodpool&&alivetime[i]<bloodpoolspeed*2.0){ if(type[i]==bloodpool&&alivetime[i]<bloodpoolspeed*.2)glBindTexture(GL_TEXTURE_2D, bloodtextureptr[1]); if(type[i]==bloodpool&&alivetime[i]>=bloodpoolspeed*.2&&alivetime[i]<bloodpoolspeed*.4)glBindTexture(GL_TEXTURE_2D, bloodtextureptr[2]); @@ -355,7 +354,7 @@ void Decals::draw() if(type[i]==bloodpool&&alivetime[i]>=bloodpoolspeed*1.6&&alivetime[i]<bloodpoolspeed*1.8)glBindTexture(GL_TEXTURE_2D, bloodtextureptr[9]); if(type[i]==bloodpool&&alivetime[i]>=bloodpoolspeed*1.8&&alivetime[i]<bloodpoolspeed*2.0)glBindTexture(GL_TEXTURE_2D, bloodtextureptr[10]); if(type[i]==bloodpool)glColor4f(1,1,1,alivetime[i]*5/bloodpoolspeed-(int)(alivetime[i]*5/bloodpoolspeed)); - + glPushMatrix(); glBegin(GL_TRIANGLE_FAN); for(int j=0;j<numpoints[i];j++){ @@ -372,4 +371,3 @@ void Decals::draw() glDisable(GL_POLYGON_OFFSET_FILL); glDepthFunc(GL_LEQUAL); } - diff --git a/src/Decals.h b/src/Decals.h index 127a6d2..e77195a 100644 --- a/src/Decals.h +++ b/src/Decals.h @@ -2,7 +2,7 @@ #define _DECALS_H_ #include "Quaternions.h" -#ifdef OS9 +#ifdef OS9 #include <gl.h> #include <glu.h> #include "glut.h" @@ -27,27 +27,27 @@ class Decals{ GLuint bulletholetextureptr; GLuint cratertextureptr; GLuint bloodtextureptr[11]; - + int howmanydecals; - + int type[maxdecals]; - + XYZ points[8*maxdecals]; int numpoints[maxdecals]; float texcoordsx[8*maxdecals]; float texcoordsy[8*maxdecals]; float alivetime[maxdecals]; - + void draw(); - + int DeleteDecal(int which); int MakeDecal(int atype, XYZ location, float size, XYZ normal, int poly, Model *model, XYZ move, float rotation); - + void DoStuff(); void LoadBulletHoleTexture(char *fileName); void LoadCraterTexture(char *fileName); void LoadBloodTexture(char *fileName, int which); - + ~Decals() { glDeleteTextures( 1, (const GLuint *)bulletholetextureptr ); glDeleteTextures( 1, (const GLuint *)cratertextureptr ); @@ -56,4 +56,3 @@ class Decals{ }; #endif - diff --git a/src/Files.cpp b/src/Files.cpp index dd55c52..542595b 100644 --- a/src/Files.cpp +++ b/src/Files.cpp @@ -23,22 +23,21 @@ short Files::OpenNewFile( SFReply *psfReply, { sFile = 0; OSErr osErr; - + SetVol( nil, psfReply->vRefNum ); osErr = Create( psfReply->fName, psfReply->vRefNum, osTypeCreator, osTypeType ); - + if ( osErr == dupFNErr ) { FSDelete( psfReply->fName, psfReply->vRefNum ); Create( psfReply->fName, psfReply->vRefNum, osTypeCreator, osTypeType ); } - + FSOpen( psfReply->fName, psfReply->vRefNum, &sFile ); return( sFile ); } - short Files::PromptForSaveAS( short sPromptID, short sNameID, Str255 str255NamePrompt, @@ -50,7 +49,7 @@ short Files::PromptForSaveAS( short sPromptID, Str255 str255Name; sFile = 0; Point ptOrigin = { 0, 0 }; - + GetIndString( str255Prompt, FILE_STRINGS, sPromptID ); if ( !str255NamePrompt ) @@ -58,9 +57,9 @@ short Files::PromptForSaveAS( short sPromptID, else memcpy( str255Name, str255NamePrompt, *str255NamePrompt + 1 ); - + SFPutFile( ptOrigin, str255Prompt, str255Name, nil, psfReply ); - + if ( psfReply->good ) { sFile = OpenNewFile( psfReply, osTypeCreator, osTypeType ); @@ -88,7 +87,7 @@ short Files::OpenFileDialog() SFReply sfReply; SFTypeList sfTypeList = { 'DMAP', '\p', '\p', '\p' }; SFGetFile( ptOrigin, "\p", nil, 1, sfTypeList, nil, &sfReply ); - + if ( sfReply.good ) { PtoCstr( sfReply.fName ); @@ -101,7 +100,7 @@ short Files::OpenFileDialog() SetVol( nil, sSavedGameVolume ); CtoPstr( szSavedGameName ); - + FSOpen( (Pstr) szSavedGameName, sSavedGameVolume,&sFile ); PtoCstr( (Pstr) szSavedGameName ); @@ -117,7 +116,7 @@ void Files::StartSave() sFile = 0; long lSize; long lLongSize = sizeof( long ); - + CtoPstr( szSavedGameName ); sFile = PromptForSaveAS( SAVE_GAME_STRING, 0, (Pstr)szSavedGameName,'DAVD', 'DMAP', &sfReply ); @@ -139,7 +138,7 @@ void Files::StartSave() sFile = OpenNewFile( &sfReply, 'GLF2', 'SKLT' ); } - + } void Files::EndSave() @@ -148,7 +147,7 @@ void Files::EndSave() SFReply sfReply; long lSize; long lLongSize = sizeof( long ); - + if ( sFile ) FSClose( sFile ); @@ -159,15 +158,14 @@ void Files::StartLoad() Boolean bLoaded = false; long lSize; long lLongSize = sizeof( long ); - + int x,y,kl; sFile=OpenFileDialog(); - + } void Files::EndLoad() { - if (sFile) FSClose( sFile ); } \ No newline at end of file diff --git a/src/Files.h b/src/Files.h index 35f4b6e..01ea9da 100644 --- a/src/Files.h +++ b/src/Files.h @@ -10,7 +10,7 @@ #include <cmath> #include <iostream> #include <fstream> -#ifdef OS9 +#ifdef OS9 #include "gl.h" // Header File For The OpenGL32 Library #include "glu.h" // Header File For The GLu32 Library #include "tk.h" // Header File For The Glaux Library @@ -18,14 +18,14 @@ #include <GL/gl.h> #include <GL/glu.h> #endif -#ifdef OS9 +#ifdef OS9 #include <Sound.h> #include <Resources.h> #include "AGL_DSp.h" // Header for OpenGL and DrawSprocket Functions #include "Alerts.h" // Header for Dialogs and alerts for this application #endif #include "MacInput.h" // Header for Special Mac Input functions -#ifdef OS9 +#ifdef OS9 #include "glm.h" #include <TextUtils.h> #endif @@ -72,24 +72,24 @@ class Files public: char szSavedGameName[FILE_NAME_SIZE + 1]; short sSavedGameVolume; -#ifdef OS9 +#ifdef OS9 SFReply sfReply; Boolean bGameSaved; #endif -#ifdef OS9 +#ifdef OS9 short sFile; #else int sFile; #endif -#ifdef OS9 +#ifdef OS9 short OpenFile(Str255 Name); #else int OpenFile(Str255 Name); - Files() : sFile(-1) { } + Files() : sFile(-1) { } #endif -#ifdef OS9 +#ifdef OS9 short PromptForSaveAS( short sPromptID, short sNameID, Str255 str255NamePrompt, @@ -109,5 +109,5 @@ class Files void StartLoad(); void EndLoad(); }; - + #endif diff --git a/src/Fog.cpp b/src/Fog.cpp index 21ca229..82f1d88 100644 --- a/src/Fog.cpp +++ b/src/Fog.cpp @@ -18,7 +18,7 @@ void Fog::SetFog(float colorR, float colorG, float colorB, float fStart, float f glFogi(GL_FOG_HINT,GL_DONT_CARE); glFogi(GL_FOG_START,fogStart); glFogi(GL_FOG_END,fogEnd); - + glEnable(GL_FOG); } @@ -36,7 +36,7 @@ void Fog::TempFog(float colorR, float colorG, float colorB) glFogi(GL_FOG_HINT,GL_DONT_CARE); glFogi(GL_FOG_START,fogStart); glFogi(GL_FOG_END,fogEnd); - + glEnable(GL_FOG); } @@ -48,7 +48,6 @@ void Fog::ResetFog() glFogi(GL_FOG_HINT,GL_DONT_CARE); glFogi(GL_FOG_START,fogStart); glFogi(GL_FOG_END,fogEnd); - + glEnable(GL_FOG); } - diff --git a/src/Fog.h b/src/Fog.h index a7e0c25..a22c378 100644 --- a/src/Fog.h +++ b/src/Fog.h @@ -1,16 +1,14 @@ #ifndef _FOG_H_ #define _FOG_H_ - /**> HEADER FILES <**/ -#ifdef OS9 +#ifdef OS9 #include <gl.h> #else #include <GL/gl.h> #endif #include "Quaternions.h" - class Fog{ public: GLfloat fogColor[4]; @@ -18,11 +16,10 @@ class Fog{ GLfloat fogDensity; GLfloat fogStart; GLfloat fogEnd; - + void SetFog(float colorR, float colorG, float colorB, float fStart, float fEnd, float fogDensity); void TempFog(float colorR, float colorG, float colorB); void ResetFog(); }; #endif - diff --git a/src/Frustum.cpp b/src/Frustum.cpp index 0e617b8..79f0aa6 100644 --- a/src/Frustum.cpp +++ b/src/Frustum.cpp @@ -1,5 +1,5 @@ #include <cmath> -#ifdef OS9 +#ifdef OS9 #include "gl.h" #else #include <GL/gl.h> @@ -13,61 +13,61 @@ void FRUSTUM:: float mvmatrix[16]; float clip[16]; float t; - + glGetFloatv(GL_PROJECTION_MATRIX, projmatrix); glGetFloatv(GL_MODELVIEW_MATRIX, mvmatrix); - + // Combine the matrices clip[0] = mvmatrix[0] * projmatrix[0] + mvmatrix[1] * projmatrix[4] + mvmatrix[2] * projmatrix[8] + mvmatrix[3] * projmatrix[12]; clip[1] = mvmatrix[0] * projmatrix[1] + mvmatrix[1] * projmatrix[5] + mvmatrix[2] * projmatrix[9] + mvmatrix[3] * projmatrix[13]; clip[2] = mvmatrix[0] * projmatrix[2] + mvmatrix[1] * projmatrix[6] + mvmatrix[2] * projmatrix[10] + mvmatrix[3] * projmatrix[14]; clip[3] = mvmatrix[0] * projmatrix[3] + mvmatrix[1] * projmatrix[7] + mvmatrix[2] * projmatrix[11] + mvmatrix[3] * projmatrix[15]; - + clip[4] = mvmatrix[4] * projmatrix[0] + mvmatrix[5] * projmatrix[4] + mvmatrix[6] * projmatrix[8] + mvmatrix[7] * projmatrix[12]; clip[5] = mvmatrix[4] * projmatrix[1] + mvmatrix[5] * projmatrix[5] + mvmatrix[6] * projmatrix[9] + mvmatrix[7] * projmatrix[13]; clip[6] = mvmatrix[4] * projmatrix[2] + mvmatrix[5] * projmatrix[6] + mvmatrix[6] * projmatrix[10] + mvmatrix[7] * projmatrix[14]; clip[7] = mvmatrix[4] * projmatrix[3] + mvmatrix[5] * projmatrix[7] + mvmatrix[6] * projmatrix[11] + mvmatrix[7] * projmatrix[15]; - + clip[8] = mvmatrix[8] * projmatrix[0] + mvmatrix[9] * projmatrix[4] + mvmatrix[10] * projmatrix[8] + mvmatrix[11] * projmatrix[12]; clip[9] = mvmatrix[8] * projmatrix[1] + mvmatrix[9] * projmatrix[5] + mvmatrix[10] * projmatrix[9] + mvmatrix[11] * projmatrix[13]; clip[10] = mvmatrix[8] * projmatrix[2] + mvmatrix[9] * projmatrix[6] + mvmatrix[10] * projmatrix[10] + mvmatrix[11] * projmatrix[14]; clip[11] = mvmatrix[8] * projmatrix[3] + mvmatrix[9] * projmatrix[7] + mvmatrix[10] * projmatrix[11] + mvmatrix[11] * projmatrix[15]; - + clip[12] = mvmatrix[12] * projmatrix[0] + mvmatrix[13] * projmatrix[4] + mvmatrix[14] * projmatrix[8] + mvmatrix[15] * projmatrix[12]; clip[13] = mvmatrix[12] * projmatrix[1] + mvmatrix[13] * projmatrix[5] + mvmatrix[14] * projmatrix[9] + mvmatrix[15] * projmatrix[13]; clip[14] = mvmatrix[12] * projmatrix[2] + mvmatrix[13] * projmatrix[6] + mvmatrix[14] * projmatrix[10] + mvmatrix[15] * projmatrix[14]; clip[15] = mvmatrix[12] * projmatrix[3] + mvmatrix[13] * projmatrix[7] + mvmatrix[14] * projmatrix[11] + mvmatrix[15] * projmatrix[15]; - + // Right plane frustum[0][0] = clip[3] - clip[0]; frustum[0][1] = clip[7] - clip[4]; frustum[0][2] = clip[11] - clip[8]; frustum[0][3] = clip[15] - clip[12]; - + // Left plane frustum[1][0] = clip[3] + clip[0]; frustum[1][1] = clip[7] + clip[4]; frustum[1][2] = clip[11] + clip[8]; frustum[1][3] = clip[15] + clip[12]; - + // Bottom plane frustum[2][0] = clip[3] + clip[1]; frustum[2][1] = clip[7] + clip[5]; frustum[2][2] = clip[11] + clip[9]; frustum[2][3] = clip[15] + clip[13]; - + // Top plane frustum[3][0] = clip[3] - clip[1]; frustum[3][1] = clip[7] - clip[5]; frustum[3][2] = clip[11] - clip[9]; frustum[3][3] = clip[15] - clip[13]; - + // Far plane frustum[4][0] = clip[3] - clip[2]; frustum[4][1] = clip[7] - clip[6]; frustum[4][2] = clip[11] - clip[10]; frustum[4][3] = clip[15] - clip[14]; - + // Near plane frustum[5][0] = clip[3] + clip[2]; frustum[5][1] = clip[7] + clip[6]; @@ -75,14 +75,14 @@ void FRUSTUM:: frustum[5][3] = clip[15] + clip[14]; /* normalize the right plane */ - t = sqrt(frustum[0][0]*frustum[0][0] - + frustum[0][1]*frustum[0][1] + t = sqrt(frustum[0][0]*frustum[0][0] + + frustum[0][1]*frustum[0][1] + frustum[0][2]*frustum[0][2]); frustum[0][0] /= t; frustum[0][1] /= t; frustum[0][2] /= t; frustum[0][3] /= t; - + /* calculate left plane */ frustum[1][0] = clip[ 3] + clip[ 0]; frustum[1][1] = clip[ 7] + clip[ 4]; @@ -90,14 +90,14 @@ void FRUSTUM:: frustum[1][3] = clip[15] + clip[12]; /* normalize the left plane */ - t = sqrt(frustum[1][0]*frustum[1][0] - + frustum[1][1]*frustum[1][1] + t = sqrt(frustum[1][0]*frustum[1][0] + + frustum[1][1]*frustum[1][1] + frustum[1][2]*frustum[1][2]); frustum[1][0] /= t; frustum[1][1] /= t; frustum[1][2] /= t; frustum[1][3] /= t; - + /* calculate the bottom plane */ frustum[2][0] = clip[ 3] + clip[ 1]; frustum[2][1] = clip[ 7] + clip[ 5]; @@ -105,65 +105,64 @@ void FRUSTUM:: frustum[2][3] = clip[15] + clip[13]; /* normalize the bottom plane */ - t = sqrt(frustum[2][0]*frustum[2][0] - + frustum[2][1]*frustum[2][1] + t = sqrt(frustum[2][0]*frustum[2][0] + + frustum[2][1]*frustum[2][1] + frustum[2][2]*frustum[2][2]); frustum[2][0] /= t; frustum[2][1] /= t; frustum[2][2] /= t; frustum[2][3] /= t; - + /* calculate the top plane */ frustum[3][0] = clip[ 3] - clip[ 1]; frustum[3][1] = clip[ 7] - clip[ 5]; frustum[3][2] = clip[11] - clip[ 9]; frustum[3][3] = clip[15] - clip[13]; - + /* normalize the top plane */ - t = sqrt(frustum[3][0]*frustum[3][0] - + frustum[3][1]*frustum[3][1] + t = sqrt(frustum[3][0]*frustum[3][0] + + frustum[3][1]*frustum[3][1] + frustum[3][2]*frustum[3][2]); frustum[3][0] /= t; frustum[3][1] /= t; frustum[3][2] /= t; frustum[3][3] /= t; - + /* calculate the far plane */ frustum[4][0] = clip[ 3] - clip[ 2]; frustum[4][1] = clip[ 7] - clip[ 6]; frustum[4][2] = clip[11] - clip[10]; frustum[4][3] = clip[15] - clip[14]; - + /* normalize the far plane */ - t = sqrt(frustum[4][0]*frustum[4][0] - + frustum[4][1]*frustum[4][1] + t = sqrt(frustum[4][0]*frustum[4][0] + + frustum[4][1]*frustum[4][1] + frustum[4][2]*frustum[4][2]); frustum[4][0] /= t; frustum[4][1] /= t; frustum[4][2] /= t; frustum[4][3] /= t; - + /* calculate the near plane */ frustum[5][0] = clip[ 3] + clip[ 2]; frustum[5][1] = clip[ 7] + clip[ 6]; frustum[5][2] = clip[11] + clip[10]; frustum[5][3] = clip[15] + clip[14]; - + /* normalize the near plane */ - t = sqrt(frustum[5][0]*frustum[5][0] - + frustum[5][1]*frustum[5][1] + t = sqrt(frustum[5][0]*frustum[5][0] + + frustum[5][1]*frustum[5][1] + frustum[5][2]*frustum[5][2]); frustum[5][0] /= t; frustum[5][1] /= t; frustum[5][2] /= t; frustum[5][3] /= t; - } int FRUSTUM:: CubeInFrustum(float x, float y, float z, float size) { int c, c2; - + c2 = 0; for(int i=0; i<6; i++) { c=0; @@ -198,7 +197,7 @@ int FRUSTUM:: CubeInFrustum(float x, float y, float z, float size, float height) { int c, c2; - c2 = 0; + c2 = 0; for(int i=0; i<6; i++) { c=0; if(frustum[i][0] * (x-size) + frustum[i][1] * (y-height) + frustum[i][2] * (z-size) + frustum[i][3] > 0) @@ -232,7 +231,7 @@ int FRUSTUM:: SphereInFrustum(float x, float y, float z, float radius) { int c2; - c2 = 0; + c2 = 0; for(int i=0; i<6; i++) { if(frustum[i][0] * x + frustum[i][1] * y + frustum[i][2] * z + frustum[i][3] > -1*radius) c2++; diff --git a/src/Frustum.h b/src/Frustum.h index 1680226..2c5cea4 100644 --- a/src/Frustum.h +++ b/src/Frustum.h @@ -11,4 +11,3 @@ class FRUSTUM { }; #endif - diff --git a/src/Game.h b/src/Game.h index e7d5b53..c1127ea 100644 --- a/src/Game.h +++ b/src/Game.h @@ -1,7 +1,7 @@ #ifndef _GAME_H_ #define _GAME_H_ -#ifdef OS9 +#ifdef OS9 #include <gl.h> #include <glu.h> #include <tk.h> @@ -9,31 +9,31 @@ #include <GL/gl.h> #include <GL/glu.h> #endif -#include <stdlib.h> -#include <stdio.h> +#include <stdlib.h> +#include <stdio.h> #include <string.h> #include <ctype.h> -#ifdef OS9 +#ifdef OS9 #include <Sound.h> -#include <Resources.h> +#include <Resources.h> #endif #include <cstdarg> -#ifdef OS9 +#ifdef OS9 #include <glm.h> #include <TextUtils.h> #endif -#ifndef OS9 +#ifndef OS9 #include <SDL/SDL.h> #endif -#ifdef OS9 +#ifdef OS9 #include "alut.h" #else #include <AL/al.h> #include <AL/alut.h> #endif -#include "Timer.h" -#ifdef OS9 -#include "AGL_DSp.h" +#include "Timer.h" +#ifdef OS9 +#include "AGL_DSp.h" #endif #include "MacInput.h" #include "Quaternions.h" @@ -53,34 +53,33 @@ #define max_people 90 #define max_people_block 20 - -class Game +class Game { public: //Eventloop Boolean gQuit; float gamespeed; double multiplier2,multiplier3,multiplier4,multiplier5,end,start,timetaken,framespersecond; - timer theTimer; + timer theTimer; float sps; int maxfps; -#ifdef OS9 +#ifdef OS9 AGLContext gOpenGLContext; CGrafPtr theScreen; #endif //Graphics int screenwidth,screenheight; float viewdistance; - + //GL functions GLvoid ReSizeGLScene(float fov, float near); int DrawGLScene(void); int InitGL(void); void LoadingScreen(float percent); - + //Game Functions void HandleKeyDown( char theChar ); -#ifdef OS9 +#ifdef OS9 void DoEvent( EventRecord *event ); #endif void EventLoop( void ); @@ -88,7 +87,7 @@ class Game void Splat(int k); void InitGame(); void Dispose(); - + //Mouse Point mouseloc; Point oldmouseloc; @@ -97,11 +96,11 @@ class Game float oldmouserotation,oldmouserotation2; float mousesensitivity; float usermousesensitivity; - + //keyboard - + bool tabkeydown; - + //Project Specific int cityrotation[num_blocks][num_blocks]; int citytype[num_blocks][num_blocks]; @@ -111,22 +110,22 @@ class Game bool cubetest; bool disttest; bool oldbutton; - + bool initialized; - + float flashamount; float flashr,flashg,flashb; - + int enemystate; - + int cycle; - + bool whacked; - + float losedelay; - + XYZ bodycoords; - + FRUSTUM frustum; Model blocks[4]; Model blockwalls[4]; @@ -146,59 +145,59 @@ class Game int badkills; int civkills; int machinegunsoundloop; - + bool lasersight; bool debug; bool vblsync; - + bool blur; bool blurness; - + bool paused; - + int mainmenu; - + bool reloadtoggle; - + bool aimtoggle; Point olddrawmouse; - + XYZ vipgoal; - + XYZ aimer[2]; - + double eqn[4]; - + float oldrot,oldrot2; - + XYZ lastshot[2]; bool zoom; bool oldzoom; - + int numpeople; float spawndelay; - + bool customlevels; - + bool musictoggle; - + float psychicpower; - + int type; - + bool slomokeydown; - + int mouseoverbutton; int oldmouseoverbutton; - + Person person[max_people]; - + GLuint personspritetextureptr; GLuint deadpersonspritetextureptr; GLuint scopetextureptr; GLuint flaretextureptr; - + bool killedinnocent; bool gameinprogress; bool beatgame; @@ -217,14 +216,14 @@ class Game float difficulty; bool azertykeyboard; bool oldvisionkey; - + ~Game() { glDeleteTextures( 1, (const GLuint *)personspritetextureptr ); glDeleteTextures( 1, (const GLuint *)deadpersonspritetextureptr ); glDeleteTextures( 1, (const GLuint *)scopetextureptr ); glDeleteTextures( 1, (const GLuint *)flaretextureptr ); } - + }; #endif diff --git a/src/GameDraw.cpp b/src/GameDraw.cpp index 999b5e3..6ddfed8 100644 --- a/src/GameDraw.cpp +++ b/src/GameDraw.cpp @@ -1,4 +1,4 @@ -#include "Game.h" +#include "Game.h" extern int thirdperson; @@ -36,10 +36,9 @@ extern Decals decals; /*********************> DrawGLScene() <*****/ -int Game::DrawGLScene(void) - -{ +int Game::DrawGLScene(void) +{ //Main menu if(mainmenu==1){ @@ -50,8 +49,6 @@ int Game::DrawGLScene(void) sinefluctprog+=multiplier*1.5; - - glLoadIdentity(); glClearColor(0,0,0,1); @@ -62,8 +59,6 @@ int Game::DrawGLScene(void) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - //"Black Shades" glDisable(GL_TEXTURE_2D); @@ -178,12 +173,8 @@ int Game::DrawGLScene(void) glDepthMask(1); - - //Text - - glEnable(GL_TEXTURE_2D); glColor4f(0,0,0,1); @@ -194,8 +185,6 @@ int Game::DrawGLScene(void) text.glPrint(100,175,string,1,2,640,480); - - //"New Game" glDisable(GL_TEXTURE_2D); @@ -314,12 +303,8 @@ int Game::DrawGLScene(void) glDepthMask(1); - - //Text - - glEnable(GL_TEXTURE_2D); glColor4f(0,0,0,1); @@ -330,8 +315,6 @@ int Game::DrawGLScene(void) text.glPrint(190-gameinprogress*10,170,string,1,1.5,640,480); - - //"Quit" glDisable(GL_TEXTURE_2D); @@ -450,12 +433,8 @@ int Game::DrawGLScene(void) glDepthMask(1); - - //Text - - glEnable(GL_TEXTURE_2D); glColor4f(0,0,0,1); @@ -466,8 +445,6 @@ int Game::DrawGLScene(void) text.glPrint(197-gameinprogress*15,87,string,1,1.5,640,480); - - //High score glColor4f(.5+sinefluct/5,0,0,1); @@ -478,8 +455,6 @@ int Game::DrawGLScene(void) text.glPrint(0,0,string,1,.8,640,480); - - //Mandatory udg text glColor4f(.3-sinefluct/20,.3-sinefluct/20,.3-sinefluct/20,1); @@ -488,9 +463,6 @@ int Game::DrawGLScene(void) text.glPrint(500,750,string,1,.6,640,480); - - - //Mouse (draw) glMatrixMode(GL_PROJECTION); // Select The Projection Matrix @@ -501,26 +473,20 @@ int Game::DrawGLScene(void) glOrtho(0,screenwidth,0,screenheight,-100,100); // Set Up An Ortho Screen - glMatrixMode(GL_MODELVIEW); + glMatrixMode(GL_MODELVIEW); glDisable(GL_TEXTURE_2D); - Point mouseloc; GetMouse(&mouseloc); mouseloc.v=screenheight-mouseloc.v; - glColor4f(.1,0,0,1); - - float size=5; - - glBegin(GL_TRIANGLES); glVertex3f(mouseloc.h,mouseloc.v,0); @@ -531,12 +497,8 @@ int Game::DrawGLScene(void) glEnd(); - - glColor4f(1,0,0,1); - - glBegin(GL_QUADS); glVertex3f(olddrawmouse.h,olddrawmouse.v,0); @@ -547,8 +509,6 @@ int Game::DrawGLScene(void) glVertex3f(olddrawmouse.h+2*size,olddrawmouse.v-2*size,0); - - glVertex3f(olddrawmouse.h,olddrawmouse.v,0); glVertex3f(mouseloc.h,mouseloc.v,0); @@ -557,8 +517,6 @@ int Game::DrawGLScene(void) glVertex3f(olddrawmouse.h+.5*size,olddrawmouse.v-2*size,0); - - glVertex3f(olddrawmouse.h+2*size,olddrawmouse.v-2*size,0); glVertex3f(mouseloc.h+2*size,mouseloc.v-2*size,0); @@ -571,9 +529,7 @@ int Game::DrawGLScene(void) glPopMatrix(); - olddrawmouse=mouseloc; - //Flash @@ -642,8 +598,7 @@ int Game::DrawGLScene(void) glDisable(GL_BLEND); glDepthMask(1); - - } + } } @@ -675,7 +630,7 @@ int Game::DrawGLScene(void) if(environment==sunny_environment){ - viewdistance=2000; + viewdistance=2000; fogcolorr=.5; @@ -689,7 +644,7 @@ int Game::DrawGLScene(void) if(environment==foggy_environment){ - viewdistance=500; + viewdistance=500; fogcolorr=.5; @@ -703,7 +658,7 @@ int Game::DrawGLScene(void) if(environment==night_environment){ - viewdistance=500; + viewdistance=500; fogcolorr=.15; @@ -717,7 +672,7 @@ int Game::DrawGLScene(void) if(environment==snowy_environment){ - viewdistance=800; + viewdistance=800; fogcolorr=.5; @@ -731,7 +686,7 @@ int Game::DrawGLScene(void) if(environment==rainy_environment){ - viewdistance=700; + viewdistance=700; fogcolorr=.3; @@ -745,7 +700,7 @@ int Game::DrawGLScene(void) if(environment==firey_environment){ - viewdistance=600; + viewdistance=600; fogcolorr=.3; @@ -759,17 +714,15 @@ int Game::DrawGLScene(void) glClearColor(fogcolorr,fogcolorg,fogcolorb,1); - - if(environment==sunny_environment){ GLfloat LightAmbient[]= { fogcolorr/4, fogcolorg/4, fogcolorb/4, 1.0f}; GLfloat LightDiffuse[]= { fogcolorr*1.6f, fogcolorg*1.6f, fogcolorr*1.6f, 1.0f }; - glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); + glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); - glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse); + glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse); } @@ -779,17 +732,13 @@ int Game::DrawGLScene(void) GLfloat LightDiffuse[]= { fogcolorr*.8f, fogcolorg*.8f, fogcolorr*.8f, 1.0f }; - glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); - - glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse); + glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); - } + glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse); - - - glEnable(GL_LIGHT0); + } - + glEnable(GL_LIGHT0); //Change fov if zooming with scope @@ -801,8 +750,6 @@ int Game::DrawGLScene(void) } - - if(visions==1){ //light @@ -811,15 +758,11 @@ int Game::DrawGLScene(void) GLfloat LightDiffuse[]= { .1f+sinefluct/5.0f, 0, 0, 1.0f }; - - - glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); + glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); - glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse); + glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse); - glEnable(GL_LIGHT0); - - + glEnable(GL_LIGHT0); fogcolorr=(sinefluct/4+.5); @@ -845,8 +788,6 @@ int Game::DrawGLScene(void) } - - //Camera float bluramount=.1*blurness; @@ -899,8 +840,6 @@ int Game::DrawGLScene(void) camera.Apply(); - - glPushMatrix(); glClipPlane(GL_CLIP_PLANE0, eqn); @@ -909,18 +848,12 @@ int Game::DrawGLScene(void) glPopMatrix(); - - frustum.GetFrustum(); - - GLfloat LightPosition[]= { -.5, 1, -.8, 0.0f }; glLightfv(GL_LIGHT0, GL_POSITION, LightPosition); - - glDisable(GL_TEXTURE_2D); glEnable(GL_FOG); @@ -931,8 +864,6 @@ int Game::DrawGLScene(void) glDepthMask(1); - - //Draw street glPushMatrix(); @@ -957,14 +888,10 @@ int Game::DrawGLScene(void) glPopMatrix(); - - if(visions==0)glEnable(GL_LIGHTING); if(visions==1)glDisable(GL_LIGHTING); - - //Draw blocks glEnable(GL_BLEND); @@ -977,8 +904,6 @@ int Game::DrawGLScene(void) int distsquared; - - //Only nearby blocks beginx=(camera.position.x-viewdistance+block_spacing/2)/block_spacing-2; @@ -989,8 +914,6 @@ int Game::DrawGLScene(void) if(beginz<0)beginz=0; - - endx=(camera.position.x+viewdistance+block_spacing/2)/block_spacing+2; if(endx>num_blocks-1)endx=num_blocks-1; @@ -999,16 +922,12 @@ int Game::DrawGLScene(void) if(endz>num_blocks-1)endz=num_blocks-1; - - bool draw; int whichtri; XYZ collpoint; - - for(int i=beginx;i<=endx;i++){ for(int j=beginz;j<=endz;j++){ @@ -1019,8 +938,6 @@ int Game::DrawGLScene(void) } - - if(beginx<endx&&beginz<endz) for(int i=beginx;i<=endx;i++){ @@ -1069,14 +986,10 @@ int Game::DrawGLScene(void) } - - //Decals decals.draw(); - - //Occluding blocks beginx=(camera.position.x+block_spacing/2)/block_spacing-2; @@ -1087,8 +1000,6 @@ int Game::DrawGLScene(void) if(beginz<0)beginz=0; - - endx=(camera.position.x+block_spacing/2)/block_spacing+2; if(endx>num_blocks-1)endx=num_blocks-1; @@ -1097,16 +1008,12 @@ int Game::DrawGLScene(void) if(endz>num_blocks-1)endz=num_blocks-1; - - float M[16]; XYZ drawpoint; float size=20; - - //Draw people if(visions==1)fog.SetFog(fogcolorr,fogcolorg,fogcolorb,0,viewdistance*.8*.5*(-sinefluct/4+.3),-sinefluct/3+.7); @@ -1119,8 +1026,6 @@ int Game::DrawGLScene(void) for(int i=0;i<numpeople;i++){ - - draw=1; if(person[i].skeleton.free<1){ @@ -1253,7 +1158,7 @@ int Game::DrawGLScene(void) glTranslatef(person[i].playercoords.x,person[i].playercoords.y,person[i].playercoords.z); - glRotatef(person[i].playerrotation,0,1,0); + glRotatef(person[i].playerrotation,0,1,0); if(i!=0||visions==0)person[i].DoAnimations(i); @@ -1353,8 +1258,6 @@ int Game::DrawGLScene(void) if(person[i].skeleton.free<1&&!draw)person[i].DoAnimationslite(i); - - if(!person[i].existing) if(!draw||findDistancefast(person[i].playercoords,camera.position)>10000){person[i].existing=1;} @@ -1365,9 +1268,7 @@ int Game::DrawGLScene(void) glDisable(GL_BLEND); - - - //Attacker psychicness + //Attacker psychicness for(int i=0;i<numpeople;i++){ @@ -1385,28 +1286,20 @@ int Game::DrawGLScene(void) } - - //Sprites glEnable(GL_CLIP_PLANE0); sprites.draw(); - - glDisable(GL_CLIP_PLANE0); - - glDisable(GL_FOG); //Zoom glAlphaFunc(GL_GREATER, 0.01); - - if(zoom){ glDisable(GL_DEPTH_TEST); // Disables Depth Testing @@ -1481,9 +1374,7 @@ int Game::DrawGLScene(void) glDepthMask(1); - } - - + } //Flash @@ -1553,7 +1444,7 @@ int Game::DrawGLScene(void) glDepthMask(1); - } + } if(person[0].skeleton.free>0&&thirdperson!=2){ @@ -1615,9 +1506,7 @@ int Game::DrawGLScene(void) glDepthMask(1); - } - - + } //Text @@ -1701,8 +1590,6 @@ int Game::DrawGLScene(void) text.glPrint(580,440,string,1,1,640,480); - - glColor4f(1,1,0,1); sprintf (string, "Time Remaining"); @@ -1719,8 +1606,6 @@ int Game::DrawGLScene(void) } - - if(debug){ sprintf (string, "The framespersecond is %d out of maximum %d.",(int)framespersecond+1,maxfps); @@ -1753,10 +1638,9 @@ int Game::DrawGLScene(void) sprintf (string, ""); text.glPrint(10,80,string,0,.8,screenwidth,screenheight); - */ + */ } return 1; } - diff --git a/src/GameInitDispose.cpp b/src/GameInitDispose.cpp index 0f303fc..f4d898e 100644 --- a/src/GameInitDispose.cpp +++ b/src/GameInitDispose.cpp @@ -1,12 +1,11 @@ #include <ctype.h> #include "Textures.h" -#ifndef OS9 +#ifndef OS9 #include <time.h> #endif -#include "Game.h" - +#include "Game.h" extern unsigned int gSourceID[100]; @@ -56,8 +55,6 @@ extern float soundscalefactor; extern int slomo; - - extern int forwardskey; extern int backwardskey; @@ -72,8 +69,6 @@ extern int psychicaimkey; extern int psychickey; - - void LoadSounds(bool musictoggle); void LoadSounds(bool musictoggle) @@ -93,10 +88,6 @@ void LoadSounds(bool musictoggle) alutInit(NULL, 0); - - - - // load up some audio data... // generate ten OpenAL sample sets and two sources @@ -109,7 +100,7 @@ void LoadSounds(bool musictoggle) alGenBuffers(iNumSampleSets, &gSampleSet[0]); -#ifdef NOOGG +#ifdef NOOGG alutLoadWAVFile((char *)":Data:Sounds:underwater.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[visionsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -118,8 +109,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:soulin.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[soulinsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -128,8 +117,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:soulout.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[souloutsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -138,8 +125,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:footstep1.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[footstepsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -148,8 +133,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:footstep2.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[footstepsound+1], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -158,8 +141,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:footstep3.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[footstepsound+2], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -168,8 +149,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:footstep4.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[footstepsound+3], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -178,8 +157,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:footstep5.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[footstepsound+4], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -188,8 +165,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:bodyland.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[bodylandsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -198,8 +173,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:headland.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[headlandsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -208,8 +181,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:sniperrifle.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[riflesound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -218,8 +189,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:BodyHit.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[bodyhitsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -228,8 +197,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:WallHit.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[wallhitsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -238,8 +205,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:machinegun.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[machinegunsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -248,8 +213,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:Nearbullet.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[nearbulletsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -258,8 +221,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:riflewhack.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[headwhacksound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -268,8 +229,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:headshot.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[headshotsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -278,8 +237,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:reload.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[reloadsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -288,8 +245,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:click.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[clicksound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -298,8 +253,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:SW.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[pistol1sound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -308,8 +261,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:glock.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[pistol2sound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -318,8 +269,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:pinpull.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[pinpullsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -328,8 +277,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:pinreplace.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[pinreplacesound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -338,8 +285,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:handlerelease.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[grenadethrowsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -348,8 +293,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:bounce.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[bouncesound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -358,8 +301,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:bounce2.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[bounce2sound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -368,8 +309,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:explosion.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[explosionsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -378,8 +317,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:headland.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[bodywhacksound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -388,8 +325,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:rain.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[rainsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -398,8 +333,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:Lose.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[losesound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -408,8 +341,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:Disguisekill.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[disguisekillsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -418,8 +349,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:knifeslash.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[knifeslashsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -428,8 +357,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:shotgun.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[shotgunsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -438,10 +365,7 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - if(musictoggle){ - alutLoadWAVFile((char *)":Data:Sounds:mainmenusong.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[mainmenusong], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -450,8 +374,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:shootsong.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[shootsong], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -460,8 +382,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:zombiesong.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[zombiesong], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -470,8 +390,6 @@ void LoadSounds(bool musictoggle) alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - alutLoadWAVFile((char *)":Data:Sounds:knifesong.wav",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[knifesong], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -479,7 +397,6 @@ void LoadSounds(bool musictoggle) alSourcei(gSourceID[knifesong], AL_BUFFER, gSampleSet[knifesong]); alutUnloadWAV(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - } #else LoadOGG_CFH((char *)":Data:Sounds:underwater.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); @@ -490,8 +407,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:soulin.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[soulinsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -500,8 +415,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:soulout.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[souloutsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -510,17 +423,13 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:footstep1.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[footstepsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); alSourcei(gSourceID[footstepsound], AL_BUFFER, gSampleSet[footstepsound]); - FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - + FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); LoadOGG_CFH((char *)":Data:Sounds:footstep2.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); @@ -530,8 +439,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:footstep3.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[footstepsound+2], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -540,8 +447,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:footstep4.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[footstepsound+3], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -550,8 +455,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:footstep5.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[footstepsound+4], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -560,8 +463,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:bodyland.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[bodylandsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -570,8 +471,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:headland.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[headlandsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -580,8 +479,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:sniperrifle.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[riflesound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -590,8 +487,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:BodyHit.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[bodyhitsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -600,8 +495,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:WallHit.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[wallhitsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -610,8 +503,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:machinegun.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[machinegunsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -620,8 +511,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:Nearbullet.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[nearbulletsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -630,8 +519,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:riflewhack.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[headwhacksound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -640,8 +527,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:headshot.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[headshotsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -650,8 +535,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:reload.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[reloadsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -660,8 +543,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:click.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[clicksound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -670,8 +551,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:SW.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[pistol1sound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -680,8 +559,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:glock.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[pistol2sound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -690,8 +567,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:pinpull.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[pinpullsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -700,8 +575,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:pinreplace.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[pinreplacesound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -710,8 +583,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:handlerelease.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[grenadethrowsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -720,8 +591,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:bounce.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[bouncesound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -730,8 +599,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:bounce2.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[bounce2sound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -740,8 +607,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:explosion.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[explosionsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -750,8 +615,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:headland.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[bodywhacksound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -760,8 +623,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:rain.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[rainsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -770,8 +631,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:Lose.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[losesound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -780,8 +639,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:Disguisekill.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[disguisekillsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -790,8 +647,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:knifeslash.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[knifeslashsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -800,8 +655,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:shotgun.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[shotgunsound], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -810,8 +663,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - if(musictoggle){ LoadOGG_CFH((char *)":Data:Sounds:mainmenusong.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); @@ -822,8 +673,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:shootsong.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[shootsong], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -832,8 +681,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:zombiesong.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[zombiesong], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -842,8 +689,6 @@ void LoadSounds(bool musictoggle) FreeOGG(formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); - - LoadOGG_CFH((char *)":Data:Sounds:knifesong.ogg",&formatBuffer1, (void **) &pBuffer1,(unsigned int *)&lBuffer1Len,&freqBuffer1); alBufferData(gSampleSet[knifesong], formatBuffer1, pBuffer1, lBuffer1Len, freqBuffer1); @@ -854,46 +699,34 @@ void LoadSounds(bool musictoggle) } - #endif - float gLoc[3]; - - gLoc[0]=0; gLoc[1]=0; gLoc[2]=0; - - alSourcefv(gSourceID[visionsound], AL_POSITION, gLoc); alSourcei(gSourceID[visionsound], AL_LOOPING, 1); alSourcef(gSourceID[visionsound], AL_MIN_GAIN, 1); - - alSourcefv(gSourceID[soulinsound], AL_POSITION, gLoc); alSourcei(gSourceID[soulinsound], AL_LOOPING, 0); alSourcef(gSourceID[soulinsound], AL_MIN_GAIN, 1); - - alSourcefv(gSourceID[souloutsound], AL_POSITION, gLoc); alSourcei(gSourceID[souloutsound], AL_LOOPING, 0); alSourcef(gSourceID[souloutsound], AL_MIN_GAIN, 1); - - for(int i=0;i<5;i++){ alSourcefv(gSourceID[footstepsound+i], AL_POSITION, gLoc); @@ -902,9 +735,7 @@ void LoadSounds(bool musictoggle) alSourcef(gSourceID[footstepsound+i], AL_MIN_GAIN, 0); - } - - + } alSourcefv(gSourceID[bodylandsound], AL_POSITION, gLoc); @@ -912,32 +743,24 @@ void LoadSounds(bool musictoggle) alSourcef(gSourceID[bodylandsound], AL_MIN_GAIN, 0); - - alSourcefv(gSourceID[headlandsound], AL_POSITION, gLoc); alSourcei(gSourceID[headlandsound], AL_LOOPING, 0); alSourcef(gSourceID[headlandsound], AL_MIN_GAIN, 0); - - alSourcefv(gSourceID[riflesound], AL_POSITION, gLoc); alSourcei(gSourceID[riflesound], AL_LOOPING, 0); alSourcef(gSourceID[riflesound], AL_MIN_GAIN, 0); - - alSourcefv(gSourceID[bodyhitsound], AL_POSITION, gLoc); alSourcei(gSourceID[bodyhitsound], AL_LOOPING, 0); alSourcef(gSourceID[bodyhitsound], AL_MIN_GAIN, .1); - - alSourcefv(gSourceID[wallhitsound], AL_POSITION, gLoc); alSourcei(gSourceID[wallhitsound], AL_LOOPING, 0); @@ -946,207 +769,153 @@ void LoadSounds(bool musictoggle) alSourcef(gSourceID[wallhitsound], AL_MAX_GAIN, .6); - - alSourcefv(gSourceID[machinegunsound], AL_POSITION, gLoc); alSourcei(gSourceID[machinegunsound], AL_LOOPING, 0); alSourcef(gSourceID[machinegunsound], AL_MIN_GAIN,0); - - alSourcefv(gSourceID[nearbulletsound], AL_POSITION, gLoc); alSourcei(gSourceID[nearbulletsound], AL_LOOPING, 0); alSourcef(gSourceID[nearbulletsound], AL_MIN_GAIN,0); - - alSourcefv(gSourceID[headwhacksound], AL_POSITION, gLoc); alSourcei(gSourceID[headwhacksound], AL_LOOPING, 0); alSourcef(gSourceID[headwhacksound], AL_MIN_GAIN,0); - - alSourcefv(gSourceID[headshotsound], AL_POSITION, gLoc); alSourcei(gSourceID[headshotsound], AL_LOOPING, 0); alSourcef(gSourceID[headshotsound], AL_MIN_GAIN, 0); - - alSourcefv(gSourceID[reloadsound], AL_POSITION, gLoc); alSourcei(gSourceID[reloadsound], AL_LOOPING, 0); alSourcef(gSourceID[reloadsound], AL_MIN_GAIN, 0); - - alSourcefv(gSourceID[clicksound], AL_POSITION, gLoc); alSourcei(gSourceID[clicksound], AL_LOOPING, 0); alSourcef(gSourceID[clicksound], AL_MIN_GAIN, 0); - - alSourcefv(gSourceID[pistol1sound], AL_POSITION, gLoc); alSourcei(gSourceID[pistol1sound], AL_LOOPING, 0); alSourcef(gSourceID[pistol1sound], AL_MIN_GAIN, 0); - - alSourcefv(gSourceID[pistol2sound], AL_POSITION, gLoc); alSourcei(gSourceID[pistol2sound], AL_LOOPING, 0); alSourcef(gSourceID[pistol2sound], AL_MIN_GAIN, 0); - - alSourcefv(gSourceID[pinpullsound], AL_POSITION, gLoc); alSourcei(gSourceID[pinpullsound], AL_LOOPING, 0); alSourcef(gSourceID[pinpullsound], AL_MIN_GAIN,0); - - alSourcefv(gSourceID[pinreplacesound], AL_POSITION, gLoc); alSourcei(gSourceID[pinreplacesound], AL_LOOPING, 0); alSourcef(gSourceID[pinreplacesound], AL_MIN_GAIN,0); - - alSourcefv(gSourceID[grenadethrowsound], AL_POSITION, gLoc); alSourcei(gSourceID[grenadethrowsound], AL_LOOPING, 0); alSourcef(gSourceID[grenadethrowsound], AL_MIN_GAIN,0); - - alSourcefv(gSourceID[bouncesound], AL_POSITION, gLoc); alSourcei(gSourceID[bouncesound], AL_LOOPING, 0); alSourcef(gSourceID[bouncesound], AL_MIN_GAIN,0); - - alSourcefv(gSourceID[bounce2sound], AL_POSITION, gLoc); alSourcei(gSourceID[bounce2sound], AL_LOOPING, 0); alSourcef(gSourceID[bounce2sound], AL_MIN_GAIN,0); - - alSourcefv(gSourceID[explosionsound], AL_POSITION, gLoc); alSourcei(gSourceID[explosionsound], AL_LOOPING, 0); alSourcef(gSourceID[explosionsound], AL_MIN_GAIN,0); - - alSourcefv(gSourceID[bodywhacksound], AL_POSITION, gLoc); alSourcei(gSourceID[bodywhacksound], AL_LOOPING, 0); alSourcef(gSourceID[bodywhacksound], AL_MIN_GAIN, 0); - - alSourcefv(gSourceID[rainsound], AL_POSITION, gLoc); alSourcei(gSourceID[rainsound], AL_LOOPING, 1); alSourcef(gSourceID[rainsound], AL_MIN_GAIN, .3); - - alSourcefv(gSourceID[losesound], AL_POSITION, gLoc); alSourcei(gSourceID[losesound], AL_LOOPING, 0); alSourcef(gSourceID[losesound], AL_MIN_GAIN, 1); - - alSourcefv(gSourceID[disguisekillsound], AL_POSITION, gLoc); alSourcei(gSourceID[disguisekillsound], AL_LOOPING, 0); alSourcef(gSourceID[disguisekillsound], AL_MIN_GAIN, 1); - - alSourcefv(gSourceID[knifeslashsound], AL_POSITION, gLoc); alSourcei(gSourceID[knifeslashsound], AL_LOOPING, 0); alSourcef(gSourceID[knifeslashsound], AL_MIN_GAIN,0); - - alSourcefv(gSourceID[shotgunsound], AL_POSITION, gLoc); alSourcei(gSourceID[shotgunsound], AL_LOOPING, 0); alSourcef(gSourceID[shotgunsound], AL_MIN_GAIN, 0); - - alSourcefv(gSourceID[knifesong], AL_POSITION, gLoc); alSourcei(gSourceID[knifesong], AL_LOOPING, 1); alSourcef(gSourceID[knifesong], AL_MIN_GAIN, 1); - - alSourcefv(gSourceID[mainmenusong], AL_POSITION, gLoc); alSourcei(gSourceID[mainmenusong], AL_LOOPING, 1); alSourcef(gSourceID[mainmenusong], AL_MIN_GAIN, 1); - - alSourcefv(gSourceID[zombiesong], AL_POSITION, gLoc); alSourcei(gSourceID[zombiesong], AL_LOOPING, 1); alSourcef(gSourceID[zombiesong], AL_MIN_GAIN, 1); - - alSourcefv(gSourceID[shootsong], AL_POSITION, gLoc); alSourcei(gSourceID[shootsong], AL_LOOPING, 1); alSourcef(gSourceID[shootsong], AL_MIN_GAIN, 1); - - - - } - - -void Game::LoadingScreen(float percent) +void Game::LoadingScreen(float percent) { glLoadIdentity(); @@ -1221,12 +990,8 @@ void Game::LoadingScreen(float percent) glDepthMask(1); - - //Progress - - glDisable(GL_DEPTH_TEST); // Disables Depth Testing glDisable(GL_CULL_FACE); @@ -1291,12 +1056,8 @@ void Game::LoadingScreen(float percent) glDepthMask(1); - - //Text - - glEnable(GL_TEXTURE_2D); glColor4f(.6-.6*percent/100,0,0,1); @@ -1307,10 +1068,7 @@ void Game::LoadingScreen(float percent) text.glPrint(280,195,string,1,1,640,480); - - - -#ifdef OS9 +#ifdef OS9 aglSwapBuffers( gOpenGLContext ); #else SDL_GL_SwapBuffers( ); @@ -1318,8 +1076,6 @@ void Game::LoadingScreen(float percent) } - - void LoadPersonSpriteTexture(char *fileName, GLuint *textureid); void LoadPersonSpriteTexture(char *fileName, GLuint *textureid) @@ -1330,9 +1086,7 @@ void LoadPersonSpriteTexture(char *fileName, GLuint *textureid) glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); } - - -void Game::InitGame() +void Game::InitGame() { @@ -1344,12 +1098,8 @@ void Game::InitGame() if(initialized)loadingscreenamounttotal=20; - - if(!initialized)LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); - - //Set up rain and snow precipitationhorz=60; @@ -1358,8 +1108,6 @@ void Game::InitGame() precipitationdensity=25; - - //Bodyguard stats person[0].playercoords=camera.position; @@ -1376,14 +1124,10 @@ void Game::InitGame() } - - //Level setup killedinnocent=0; //Haven't shot any civilians yet... - - if(customlevels){ //Load custom levels nummissions=1; //Default level in case of load failure @@ -1402,7 +1146,7 @@ void Game::InitGame() person[0].whichgun=knife; - person[0].reloads[person[0].whichgun]=6; + person[0].reloads[person[0].whichgun]=6; if(!gameinprogress)score=0; @@ -1436,7 +1180,7 @@ void Game::InitGame() ipstream.ignore(256,'\n'); - ipstream >> environment; + ipstream >> environment; ipstream.ignore(256,'\n'); @@ -1494,11 +1238,9 @@ void Game::InitGame() } - - if(!customlevels){ //Setup hardcoded default levels - if(mission==0){ + if(mission==0){ environment=sunny_environment; @@ -1516,7 +1258,7 @@ void Game::InitGame() person[0].whichgun=assaultrifle; - person[0].reloads[person[0].whichgun]=6; + person[0].reloads[person[0].whichgun]=6; if(!gameinprogress)score=0; @@ -1526,7 +1268,7 @@ void Game::InitGame() } - if(mission==1){ + if(mission==1){ environment=snowy_environment; @@ -1542,7 +1284,7 @@ void Game::InitGame() person[0].whichgun=handgun2; - person[0].reloads[person[0].whichgun]=3; + person[0].reloads[person[0].whichgun]=3; if(!gameinprogress)score=0; @@ -1552,7 +1294,7 @@ void Game::InitGame() } - if(mission==2){ + if(mission==2){ environment=foggy_environment; @@ -1566,7 +1308,7 @@ void Game::InitGame() person[0].whichgun=sniperrifle; - person[0].reloads[person[0].whichgun]=4; + person[0].reloads[person[0].whichgun]=4; if(!gameinprogress)score=0; @@ -1576,7 +1318,7 @@ void Game::InitGame() } - if(mission==3){ + if(mission==3){ environment=firey_environment; @@ -1588,7 +1330,7 @@ void Game::InitGame() person[0].whichgun=shotgun; - person[0].reloads[person[0].whichgun]=5; + person[0].reloads[person[0].whichgun]=5; if(!gameinprogress)score=0; @@ -1598,7 +1340,7 @@ void Game::InitGame() } - if(mission==4){ + if(mission==4){ environment=snowy_environment; @@ -1614,7 +1356,7 @@ void Game::InitGame() person[0].whichgun=grenade; - person[0].reloads[person[0].whichgun]=20; + person[0].reloads[person[0].whichgun]=20; if(!gameinprogress)score=0; @@ -1624,7 +1366,7 @@ void Game::InitGame() } - if(mission==5){ + if(mission==5){ environment=rainy_environment; @@ -1642,7 +1384,7 @@ void Game::InitGame() person[0].whichgun=knife; - person[0].reloads[person[0].whichgun]=3; + person[0].reloads[person[0].whichgun]=3; if(!gameinprogress)score=0; @@ -1652,7 +1394,7 @@ void Game::InitGame() } - if(mission==6){ + if(mission==6){ environment=night_environment; @@ -1670,7 +1412,7 @@ void Game::InitGame() person[0].whichgun=handgun1; - person[0].reloads[person[0].whichgun]=4; + person[0].reloads[person[0].whichgun]=4; if(!gameinprogress)score=0; @@ -1680,7 +1422,7 @@ void Game::InitGame() } - if(mission==7){ + if(mission==7){ environment=firey_environment; @@ -1688,7 +1430,7 @@ void Game::InitGame() person[0].whichgun=assaultrifle; - person[0].reloads[person[0].whichgun]=5; + person[0].reloads[person[0].whichgun]=5; if(!gameinprogress)score=0; @@ -1698,7 +1440,7 @@ void Game::InitGame() } - if(mission==8){ + if(mission==8){ environment=rainy_environment; @@ -1720,7 +1462,7 @@ void Game::InitGame() person[0].whichgun=nogun; - person[0].reloads[person[0].whichgun]=3; + person[0].reloads[person[0].whichgun]=3; if(!gameinprogress)score=0; @@ -1730,7 +1472,7 @@ void Game::InitGame() } - if(mission==9){ + if(mission==9){ environment=snowy_environment; @@ -1754,7 +1496,7 @@ void Game::InitGame() person[0].whichgun=handgun1; - person[0].reloads[person[0].whichgun]=3; + person[0].reloads[person[0].whichgun]=3; if(!gameinprogress)score=0; @@ -1764,7 +1506,7 @@ void Game::InitGame() } - if(mission==10){ + if(mission==10){ environment=night_environment; @@ -1778,7 +1520,7 @@ void Game::InitGame() person[0].whichgun=sniperrifle; - person[0].reloads[person[0].whichgun]=4; + person[0].reloads[person[0].whichgun]=4; if(!gameinprogress)score=0; @@ -1788,7 +1530,7 @@ void Game::InitGame() } - if(mission==11){ + if(mission==11){ environment=sunny_environment; @@ -1812,7 +1554,7 @@ void Game::InitGame() } - if(mission==12){ + if(mission==12){ environment=firey_environment; @@ -1824,7 +1566,7 @@ void Game::InitGame() person[0].whichgun=handgun2; - person[0].reloads[person[0].whichgun]=10; + person[0].reloads[person[0].whichgun]=10; if(!gameinprogress)score=0; @@ -1834,29 +1576,21 @@ void Game::InitGame() } - - nummissions=13; } - - //Setup fast radian to degree conversion rad2deg= 56.54866776; visions=0; - - //Setup bounding cylinder model float boundingscale=3; - - - if(!initialized){ + if(!initialized){ boundingpoints[0]=0; @@ -1880,9 +1614,7 @@ void Game::InitGame() enemystate=2; - - - if(!initialized){ + if(!initialized){ if(!azertykeyboard){ @@ -1902,8 +1634,6 @@ void Game::InitGame() } - - if(azertykeyboard){ forwardskey=MAC_Z_KEY; @@ -1922,16 +1652,10 @@ void Game::InitGame() } - - soundscalefactor=soundscalefactordefault; //Setup sound falloff - - gQuit=false; - - //Sounds LoadSounds(musictoggle); @@ -1958,21 +1682,17 @@ void Game::InitGame() alSourcef(gSourceID[whichsong], AL_MIN_GAIN, 1); - alSourcef(gSourceID[whichsong], AL_MAX_GAIN, 1); + alSourcef(gSourceID[whichsong], AL_MAX_GAIN, 1); } - - loadingscreenamount+=5; if(!initialized)LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); - - //Setup random seed -#ifdef OS9 +#ifdef OS9 qd.randSeed = TickCount(); #else srand(time(NULL)); @@ -1980,8 +1700,6 @@ void Game::InitGame() gamespeed=1; - - //Setup camera camera.position=0; @@ -1996,8 +1714,6 @@ void Game::InitGame() numpeople=1; - - //Setup path to walk around blocks path.load((unsigned char *)":Data:Models:path.solid"); @@ -2008,34 +1724,22 @@ void Game::InitGame() path.CalculateNormals(); - - loadingscreenamount+=5; if(!initialized)LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); - - person[0].speedmult=1.3; - - - //Add vip + //Add vip person[numpeople].playerrotation=0; - - - person[numpeople].whichcostume=vipcostume; - - + person[numpeople].whichcostume=vipcostume; person[numpeople].whichblockx=((person[0].playercoords.x+block_spacing/2)/block_spacing); person[numpeople].whichblocky=((person[0].playercoords.x+block_spacing/2)/block_spacing); - - person[numpeople].pathnum=-1; person[numpeople].oldpathnum=-1; @@ -2052,7 +1756,7 @@ void Game::InitGame() person[numpeople].pathtarget.x=path.vertex[person[numpeople].pathnum].x; - person[numpeople].pathtarget.z=path.vertex[person[numpeople].pathnum].z; + person[numpeople].pathtarget.z=path.vertex[person[numpeople].pathnum].z; person[numpeople].pathsize=.98+float(abs(Random()%20))/400; @@ -2062,16 +1766,10 @@ void Game::InitGame() person[numpeople].pathtarget.z+=person[numpeople].whichblocky*block_spacing; - - - - person[numpeople].playercoords=person[numpeople].pathtarget; person[numpeople].oldplayercoords=person[numpeople].playercoords; - - person[0].playercoords=person[numpeople].playercoords; person[0].playercoords.x+=1; @@ -2080,12 +1778,8 @@ void Game::InitGame() person[0].oldplayercoords=person[0].playercoords; - - person[numpeople].skeleton.free=0; - - person[numpeople].targetanimation=walkanim; person[numpeople].speed=1; @@ -2096,36 +1790,26 @@ void Game::InitGame() if(type==zombie_type)person[numpeople].speedmult=.8; - person[numpeople].health=100; + person[numpeople].health=100; person[numpeople].playerrotation2=0;//20; - - person[numpeople].lastdistancevictim=200000; - - if(person[numpeople].skeleton.broken)person[numpeople].skeleton.Load((char *)":Data:Skeleton:Basic Figure"); - - person[numpeople].type=viptype; person[numpeople].whichgun=nogun; person[numpeople].aiming=0; person[numpeople].killtarget=-1; person[numpeople].existing=1; - - citypeoplenum[person[numpeople].whichblockx][person[numpeople].whichblocky]++; numpeople++; spawndelay=.1; - - XYZ vipdistance; vipdistance=0; @@ -2134,9 +1818,7 @@ void Game::InitGame() vipgoal=person[1].playercoords+DoRotation(vipdistance,0,Random()%360,0); - - - //Setup block models + //Setup block models if(!initialized){ @@ -2148,8 +1830,6 @@ void Game::InitGame() blocks[0].CalculateNormals(); - - blocks[1].load((unsigned char *)":Data:Models:Block2.solid"); blocks[1].Rotate(90,0,0); @@ -2158,14 +1838,10 @@ void Game::InitGame() blocks[1].CalculateNormals(); - - loadingscreenamount+=5; if(!initialized)LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); - - blocks[2].load((unsigned char *)":Data:Models:Block3.solid"); blocks[2].Rotate(90,0,0); @@ -2174,8 +1850,6 @@ void Game::InitGame() blocks[2].CalculateNormals(); - - blocks[3].load((unsigned char *)":Data:Models:Block4.solid"); blocks[3].Rotate(90,0,0); @@ -2184,14 +1858,10 @@ void Game::InitGame() blocks[3].CalculateNormals(); - - loadingscreenamount+=5; if(!initialized)LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); - - sidewalkcollide.load((unsigned char *)":Data:Models:Lowheightcollide.solid"); sidewalkcollide.Rotate(90,0,0); @@ -2200,8 +1870,6 @@ void Game::InitGame() sidewalkcollide.CalculateNormals(); - - blockwalls[0].load((unsigned char *)":Data:Models:Block1collide.solid"); blockwalls[0].Rotate(90,0,0); @@ -2210,8 +1878,6 @@ void Game::InitGame() blockwalls[0].CalculateNormals(); - - blockwalls[1].load((unsigned char *)":Data:Models:Block2collide.solid"); blockwalls[1].Rotate(90,0,0); @@ -2220,8 +1886,6 @@ void Game::InitGame() blockwalls[1].CalculateNormals(); - - blockwalls[2].load((unsigned char *)":Data:Models:Block3collide.solid"); blockwalls[2].Rotate(90,0,0); @@ -2230,8 +1894,6 @@ void Game::InitGame() blockwalls[2].CalculateNormals(); - - blockwalls[3].load((unsigned char *)":Data:Models:Block4collide.solid"); blockwalls[3].Rotate(90,0,0); @@ -2240,14 +1902,10 @@ void Game::InitGame() blockwalls[3].CalculateNormals(); - - loadingscreenamount+=5; if(!initialized)LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); - - blockroofs[0].load((unsigned char *)":Data:Models:Highblock1collide.solid"); blockroofs[0].Rotate(90,0,0); @@ -2256,8 +1914,6 @@ void Game::InitGame() blockroofs[0].CalculateNormals(); - - blockroofs[1].load((unsigned char *)":Data:Models:Highblock2collide.solid"); blockroofs[1].Rotate(90,0,0); @@ -2266,8 +1922,6 @@ void Game::InitGame() blockroofs[1].CalculateNormals(); - - blockroofs[2].load((unsigned char *)":Data:Models:Highblock3collide.solid"); blockroofs[2].Rotate(90,0,0); @@ -2276,8 +1930,6 @@ void Game::InitGame() blockroofs[2].CalculateNormals(); - - blockroofs[3].load((unsigned char *)":Data:Models:Highblock4collide.solid"); blockroofs[3].Rotate(90,0,0); @@ -2286,8 +1938,6 @@ void Game::InitGame() blockroofs[3].CalculateNormals(); - - blockcollide[0].load((unsigned char *)":Data:Models:block1complete.solid"); blockcollide[0].Rotate(90,0,0); @@ -2296,8 +1946,6 @@ void Game::InitGame() blockcollide[0].CalculateNormals(); - - blockcollide[1].load((unsigned char *)":Data:Models:block2complete.solid"); blockcollide[1].Rotate(90,0,0); @@ -2306,8 +1954,6 @@ void Game::InitGame() blockcollide[1].CalculateNormals(); - - blockcollide[2].load((unsigned char *)":Data:Models:block3complete.solid"); blockcollide[2].Rotate(90,0,0); @@ -2316,8 +1962,6 @@ void Game::InitGame() blockcollide[2].CalculateNormals(); - - blockcollide[3].load((unsigned char *)":Data:Models:block4complete.solid"); blockcollide[3].Rotate(90,0,0); @@ -2326,16 +1970,10 @@ void Game::InitGame() blockcollide[3].CalculateNormals(); - - loadingscreenamount+=5; if(!initialized)LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); - - - - blocksimplecollide[0].load((unsigned char *)":Data:Models:lowsimplecollide1.solid"); blocksimplecollide[0].Rotate(90,0,0); @@ -2344,8 +1982,6 @@ void Game::InitGame() blocksimplecollide[0].CalculateNormals(); - - blocksimplecollide[1].load((unsigned char *)":Data:Models:lowsimplecollide2.solid"); blocksimplecollide[1].Rotate(90,0,0); @@ -2354,8 +1990,6 @@ void Game::InitGame() blocksimplecollide[1].CalculateNormals(); - - blocksimplecollide[2].load((unsigned char *)":Data:Models:lowsimplecollide3.solid"); blocksimplecollide[2].Rotate(90,0,0); @@ -2364,8 +1998,6 @@ void Game::InitGame() blocksimplecollide[2].CalculateNormals(); - - blocksimplecollide[3].load((unsigned char *)":Data:Models:lowsimplecollide4.solid"); blocksimplecollide[3].Rotate(90,0,0); @@ -2374,14 +2006,10 @@ void Game::InitGame() blocksimplecollide[3].CalculateNormals(); - - loadingscreenamount+=5; if(!initialized)LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); - - blockocclude.load((unsigned char *)":Data:Models:blockocclude.solid"); blockocclude.Rotate(90,0,0); @@ -2390,8 +2018,6 @@ void Game::InitGame() blockocclude.CalculateNormals(); - - blocksimple.load((unsigned char *)":Data:Models:blocksimple.solid"); blocksimple.Rotate(90,0,0); @@ -2400,8 +2026,6 @@ void Game::InitGame() blocksimple.CalculateNormals(); - - street.load((unsigned char *)":Data:Models:streetsubdivided2.solid"); street.Rotate(90,0,0); @@ -2410,20 +2034,14 @@ void Game::InitGame() street.CalculateNormals(); - - Bigstreet=street; Bigstreet.Scale(10000,10000,10000); - - loadingscreenamount+=5; if(!initialized)LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); - - path.load((unsigned char *)":Data:Models:path.solid"); path.Rotate(90,0,0); @@ -2432,8 +2050,6 @@ void Game::InitGame() path.CalculateNormals(); - - //Fix block radius for(int i=0;i<4;i++){ @@ -2454,12 +2070,10 @@ void Game::InitGame() } - } + } mousesensitivity=1; - - //init city block rotations for(int i=0;i<num_blocks;i++){ @@ -2480,8 +2094,6 @@ void Game::InitGame() } - - if(!initialized){ //Load player model @@ -2494,8 +2106,6 @@ void Game::InitGame() skeletonmodels[0].CalculateNormals(); - - skeletonmodels[1].load((unsigned char *)":Data:Models:Chest.solid"); skeletonmodels[1].Rotate(90,0,0); @@ -2504,8 +2114,6 @@ void Game::InitGame() skeletonmodels[1].CalculateNormals(); - - skeletonmodels[2].load((unsigned char *)":Data:Models:Abdomen.solid"); skeletonmodels[2].Rotate(90,0,0); @@ -2514,8 +2122,6 @@ void Game::InitGame() skeletonmodels[2].CalculateNormals(); - - skeletonmodels[3].load((unsigned char *)":Data:Models:Upper arm.solid"); skeletonmodels[3].Rotate(90,0,0); @@ -2524,8 +2130,6 @@ void Game::InitGame() skeletonmodels[3].CalculateNormals(); - - skeletonmodels[4].load((unsigned char *)":Data:Models:Lower arm.solid"); skeletonmodels[4].Rotate(90,0,0); @@ -2534,8 +2138,6 @@ void Game::InitGame() skeletonmodels[4].CalculateNormals(); - - skeletonmodels[5].load((unsigned char *)":Data:Models:Hand.solid"); skeletonmodels[5].Rotate(90,0,0); @@ -2544,8 +2146,6 @@ void Game::InitGame() skeletonmodels[5].CalculateNormals(); - - skeletonmodels[6].load((unsigned char *)":Data:Models:Upper leg.solid"); skeletonmodels[6].Rotate(90,0,0); @@ -2554,8 +2154,6 @@ void Game::InitGame() skeletonmodels[6].CalculateNormals(); - - skeletonmodels[7].load((unsigned char *)":Data:Models:Lower leg.solid"); skeletonmodels[7].Rotate(90,0,0); @@ -2564,8 +2162,6 @@ void Game::InitGame() skeletonmodels[7].CalculateNormals(); - - skeletonmodels[8].load((unsigned char *)":Data:Models:Foot.solid"); skeletonmodels[8].Rotate(90,0,0); @@ -2574,8 +2170,6 @@ void Game::InitGame() skeletonmodels[8].CalculateNormals(); - - skeletonmodels[9].load((unsigned char *)":Data:Models:Shades.solid"); skeletonmodels[9].Rotate(90,0,0); @@ -2584,16 +2178,12 @@ void Game::InitGame() skeletonmodels[9].CalculateNormals(); - - //Load gun models loadingscreenamount+=5; if(!initialized)LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); - - gunmodels[sniperriflemodel].load((unsigned char *)":Data:Models:sniperrifle.solid"); gunmodels[sniperriflemodel].Rotate(0,0,90); @@ -2602,8 +2192,6 @@ void Game::InitGame() gunmodels[sniperriflemodel].CalculateNormals(); - - gunmodels[assaultriflemodel].load((unsigned char *)":Data:Models:assaultrifle.solid"); gunmodels[assaultriflemodel].Rotate(0,0,90); @@ -2612,8 +2200,6 @@ void Game::InitGame() gunmodels[assaultriflemodel].CalculateNormals(); - - gunmodels[handgunbasemodel].load((unsigned char *)":Data:Models:Handgunbase.solid"); gunmodels[handgunbasemodel].Rotate(0,0,90); @@ -2630,8 +2216,6 @@ void Game::InitGame() if(!initialized)LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); - - gunmodels[handgunslidemodel].load((unsigned char *)":Data:Models:Handgunslide.solid"); gunmodels[handgunslidemodel].Rotate(0,0,90); @@ -2644,8 +2228,6 @@ void Game::InitGame() gunmodels[handgunslidemodel].MultColor(.6); - - gunmodels[handgun2basemodel].load((unsigned char *)":Data:Models:glockbase.solid"); gunmodels[handgun2basemodel].Rotate(0,0,90); @@ -2658,8 +2240,6 @@ void Game::InitGame() gunmodels[handgun2basemodel].MultColor(.6); - - gunmodels[handgun2slidemodel].load((unsigned char *)":Data:Models:glockslide.solid"); gunmodels[handgun2slidemodel].Rotate(0,0,90); @@ -2676,8 +2256,6 @@ void Game::InitGame() if(!initialized)LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); - - gunmodels[grenadebasemodel].load((unsigned char *)":Data:Models:grenadebase.solid"); gunmodels[grenadebasemodel].Rotate(0,0,90); @@ -2688,8 +2266,6 @@ void Game::InitGame() gunmodels[grenadebasemodel].CalculateNormals(); - - gunmodels[grenadepinmodel].load((unsigned char *)":Data:Models:grenadepin.solid"); gunmodels[grenadepinmodel].Rotate(0,0,90); @@ -2700,8 +2276,6 @@ void Game::InitGame() gunmodels[grenadepinmodel].CalculateNormals(); - - gunmodels[grenadespoonmodel].load((unsigned char *)":Data:Models:grenadespoon.solid"); gunmodels[grenadespoonmodel].Rotate(0,0,90); @@ -2712,8 +2286,6 @@ void Game::InitGame() gunmodels[grenadespoonmodel].CalculateNormals(); - - gunmodels[knifemodel].load((unsigned char *)":Data:Models:Knife.solid"); gunmodels[knifemodel].Rotate(0,0,90); @@ -2724,8 +2296,6 @@ void Game::InitGame() gunmodels[knifemodel].CalculateNormals(); - - gunmodels[shotgunmodel].load((unsigned char *)":Data:Models:shotgun.solid"); gunmodels[shotgunmodel].Rotate(0,0,90); @@ -2738,14 +2308,10 @@ void Game::InitGame() } - - loadingscreenamount+=5; if(!initialized)LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); - - //Setup costumes float headcolor[3]; @@ -2766,40 +2332,30 @@ void Game::InitGame() headcolor[2]=(float)132/255; - - footcolor[0]=(float)119/255; footcolor[1]=(float)68/255; footcolor[2]=(float)18/255; - - handcolor[0]=(float)240/255; handcolor[1]=(float)183/255; handcolor[2]=(float)132/255; - - topcolor[0]=(float)14/255; topcolor[1]=(float)18/255; topcolor[2]=(float)195/255; - - bottomcolor[0]=(float)14/255; bottomcolor[1]=(float)18/255; bottomcolor[2]=(float)195/255; - - //Greenish skin if zombies if(type==zombie_type){ @@ -2810,8 +2366,6 @@ void Game::InitGame() headcolor[2]=(float)197/255; - - handcolor[0]=(float)223/255; handcolor[1]=(float)243/255; @@ -2820,80 +2374,60 @@ void Game::InitGame() } - - costume[policecostume].headcolor[0]=headcolor[0]; costume[policecostume].headcolor[1]=headcolor[1]; costume[policecostume].headcolor[2]=headcolor[2]; - - costume[policecostume].handcolor[0]=handcolor[0]; costume[policecostume].handcolor[1]=handcolor[1]; costume[policecostume].handcolor[2]=handcolor[2]; - - costume[policecostume].chestcolor[0]=topcolor[0]; costume[policecostume].chestcolor[1]=topcolor[1]; costume[policecostume].chestcolor[2]=topcolor[2]; - - costume[policecostume].abdomencolor[0]=topcolor[0]; costume[policecostume].abdomencolor[1]=topcolor[1]; costume[policecostume].abdomencolor[2]=topcolor[2]; - - costume[policecostume].upperarmcolor[0]=topcolor[0]; costume[policecostume].upperarmcolor[1]=topcolor[1]; costume[policecostume].upperarmcolor[2]=topcolor[2]; - - costume[policecostume].lowerarmcolor[0]=topcolor[0]; costume[policecostume].lowerarmcolor[1]=topcolor[1]; costume[policecostume].lowerarmcolor[2]=topcolor[2]; - - costume[policecostume].upperlegcolor[0]=bottomcolor[0]; costume[policecostume].upperlegcolor[1]=bottomcolor[1]; costume[policecostume].upperlegcolor[2]=bottomcolor[2]; - - costume[policecostume].lowerlegcolor[0]=bottomcolor[0]; costume[policecostume].lowerlegcolor[1]=bottomcolor[1]; costume[policecostume].lowerlegcolor[2]=bottomcolor[2]; - - costume[policecostume].footcolor[0]=footcolor[0]; costume[policecostume].footcolor[1]=footcolor[1]; costume[policecostume].footcolor[2]=footcolor[2]; - - //casual topcolor[0]=(float)14/255; @@ -2902,88 +2436,66 @@ void Game::InitGame() topcolor[2]=(float)30/255; - - bottomcolor[0]=(float)14/255; bottomcolor[1]=(float)18/255; bottomcolor[2]=(float)195/255; - - costume[casualcostumes].headcolor[0]=headcolor[0]; costume[casualcostumes].headcolor[1]=headcolor[1]; costume[casualcostumes].headcolor[2]=headcolor[2]; - - costume[casualcostumes].handcolor[0]=handcolor[0]; costume[casualcostumes].handcolor[1]=handcolor[1]; costume[casualcostumes].handcolor[2]=handcolor[2]; - - costume[casualcostumes].chestcolor[0]=topcolor[0]; costume[casualcostumes].chestcolor[1]=topcolor[1]; costume[casualcostumes].chestcolor[2]=topcolor[2]; - - costume[casualcostumes].abdomencolor[0]=topcolor[0]; costume[casualcostumes].abdomencolor[1]=topcolor[1]; costume[casualcostumes].abdomencolor[2]=topcolor[2]; - - costume[casualcostumes].upperarmcolor[0]=topcolor[0]; costume[casualcostumes].upperarmcolor[1]=topcolor[1]; costume[casualcostumes].upperarmcolor[2]=topcolor[2]; - - costume[casualcostumes].lowerarmcolor[0]=handcolor[0]; costume[casualcostumes].lowerarmcolor[1]=handcolor[1]; costume[casualcostumes].lowerarmcolor[2]=handcolor[2]; - - costume[casualcostumes].upperlegcolor[0]=bottomcolor[0]; costume[casualcostumes].upperlegcolor[1]=bottomcolor[1]; costume[casualcostumes].upperlegcolor[2]=bottomcolor[2]; - - costume[casualcostumes].lowerlegcolor[0]=bottomcolor[0]; costume[casualcostumes].lowerlegcolor[1]=bottomcolor[1]; costume[casualcostumes].lowerlegcolor[2]=bottomcolor[2]; - - costume[casualcostumes].footcolor[0]=footcolor[0]; costume[casualcostumes].footcolor[1]=footcolor[1]; costume[casualcostumes].footcolor[2]=footcolor[2]; - - //casual 2 topcolor[0]=(float)140/255; @@ -2992,88 +2504,66 @@ void Game::InitGame() topcolor[2]=(float)4/255; - - bottomcolor[0]=(float)14/255; bottomcolor[1]=(float)18/255; bottomcolor[2]=(float)135/255; - - costume[casualcostumes+1].headcolor[0]=headcolor[0]; costume[casualcostumes+1].headcolor[1]=headcolor[1]; costume[casualcostumes+1].headcolor[2]=headcolor[2]; - - costume[casualcostumes+1].handcolor[0]=handcolor[0]; costume[casualcostumes+1].handcolor[1]=handcolor[1]; costume[casualcostumes+1].handcolor[2]=handcolor[2]; - - costume[casualcostumes+1].chestcolor[0]=topcolor[0]; costume[casualcostumes+1].chestcolor[1]=topcolor[1]; costume[casualcostumes+1].chestcolor[2]=topcolor[2]; - - costume[casualcostumes+1].abdomencolor[0]=topcolor[0]; costume[casualcostumes+1].abdomencolor[1]=topcolor[1]; costume[casualcostumes+1].abdomencolor[2]=topcolor[2]; - - costume[casualcostumes+1].upperarmcolor[0]=topcolor[0]; costume[casualcostumes+1].upperarmcolor[1]=topcolor[1]; costume[casualcostumes+1].upperarmcolor[2]=topcolor[2]; - - costume[casualcostumes+1].lowerarmcolor[0]=topcolor[0]; costume[casualcostumes+1].lowerarmcolor[1]=topcolor[1]; costume[casualcostumes+1].lowerarmcolor[2]=topcolor[2]; - - costume[casualcostumes+1].upperlegcolor[0]=bottomcolor[0]; costume[casualcostumes+1].upperlegcolor[1]=bottomcolor[1]; costume[casualcostumes+1].upperlegcolor[2]=bottomcolor[2]; - - costume[casualcostumes+1].lowerlegcolor[0]=bottomcolor[0]; costume[casualcostumes+1].lowerlegcolor[1]=bottomcolor[1]; costume[casualcostumes+1].lowerlegcolor[2]=bottomcolor[2]; - - costume[casualcostumes+1].footcolor[0]=footcolor[0]; costume[casualcostumes+1].footcolor[1]=footcolor[1]; costume[casualcostumes+1].footcolor[2]=footcolor[2]; - - //casual 3 topcolor[0]=(float)134/255; @@ -3082,98 +2572,72 @@ void Game::InitGame() topcolor[2]=(float)3/255; - - bottomcolor[0]=(float)30/255; bottomcolor[1]=(float)30/255; bottomcolor[2]=(float)30/255; - - footcolor[0]=(float)20/255; footcolor[1]=(float)20/255; footcolor[2]=(float)20/255; - - - - costume[casualcostumes+2].headcolor[0]=headcolor[0]; costume[casualcostumes+2].headcolor[1]=headcolor[1]; costume[casualcostumes+2].headcolor[2]=headcolor[2]; - - costume[casualcostumes+2].handcolor[0]=handcolor[0]; costume[casualcostumes+2].handcolor[1]=handcolor[1]; costume[casualcostumes+2].handcolor[2]=handcolor[2]; - - costume[casualcostumes+2].chestcolor[0]=topcolor[0]; costume[casualcostumes+2].chestcolor[1]=topcolor[1]; costume[casualcostumes+2].chestcolor[2]=topcolor[2]; - - costume[casualcostumes+2].abdomencolor[0]=topcolor[0]; costume[casualcostumes+2].abdomencolor[1]=topcolor[1]; costume[casualcostumes+2].abdomencolor[2]=topcolor[2]; - - costume[casualcostumes+2].upperarmcolor[0]=topcolor[0]; costume[casualcostumes+2].upperarmcolor[1]=topcolor[1]; costume[casualcostumes+2].upperarmcolor[2]=topcolor[2]; - - costume[casualcostumes+2].lowerarmcolor[0]=topcolor[0]; costume[casualcostumes+2].lowerarmcolor[1]=topcolor[1]; costume[casualcostumes+2].lowerarmcolor[2]=topcolor[2]; - - costume[casualcostumes+2].upperlegcolor[0]=bottomcolor[0]; costume[casualcostumes+2].upperlegcolor[1]=bottomcolor[1]; costume[casualcostumes+2].upperlegcolor[2]=bottomcolor[2]; - - costume[casualcostumes+2].lowerlegcolor[0]=bottomcolor[0]; costume[casualcostumes+2].lowerlegcolor[1]=bottomcolor[1]; costume[casualcostumes+2].lowerlegcolor[2]=bottomcolor[2]; - - costume[casualcostumes+2].footcolor[0]=footcolor[0]; costume[casualcostumes+2].footcolor[1]=footcolor[1]; costume[casualcostumes+2].footcolor[2]=footcolor[2]; - - //casual 4 topcolor[0]=(float)228/255; @@ -3182,96 +2646,72 @@ void Game::InitGame() topcolor[2]=(float)0/255; - - bottomcolor[0]=(float)20/255; bottomcolor[1]=(float)20/255; bottomcolor[2]=(float)20/255; - - footcolor[0]=(float)119/255; footcolor[1]=(float)68/255; footcolor[2]=(float)18/255; - - costume[casualcostumes+3].headcolor[0]=headcolor[0]; costume[casualcostumes+3].headcolor[1]=headcolor[1]; costume[casualcostumes+3].headcolor[2]=headcolor[2]; - - costume[casualcostumes+3].handcolor[0]=handcolor[0]; costume[casualcostumes+3].handcolor[1]=handcolor[1]; costume[casualcostumes+3].handcolor[2]=handcolor[2]; - - costume[casualcostumes+3].chestcolor[0]=topcolor[0]; costume[casualcostumes+3].chestcolor[1]=topcolor[1]; costume[casualcostumes+3].chestcolor[2]=topcolor[2]; - - costume[casualcostumes+3].abdomencolor[0]=topcolor[0]; costume[casualcostumes+3].abdomencolor[1]=topcolor[1]; costume[casualcostumes+3].abdomencolor[2]=topcolor[2]; - - costume[casualcostumes+3].upperarmcolor[0]=topcolor[0]; costume[casualcostumes+3].upperarmcolor[1]=topcolor[1]; costume[casualcostumes+3].upperarmcolor[2]=topcolor[2]; - - costume[casualcostumes+3].lowerarmcolor[0]=handcolor[0]; costume[casualcostumes+3].lowerarmcolor[1]=handcolor[1]; costume[casualcostumes+3].lowerarmcolor[2]=handcolor[2]; - - costume[casualcostumes+3].upperlegcolor[0]=bottomcolor[0]; costume[casualcostumes+3].upperlegcolor[1]=bottomcolor[1]; costume[casualcostumes+3].upperlegcolor[2]=bottomcolor[2]; - - costume[casualcostumes+3].lowerlegcolor[0]=bottomcolor[0]; costume[casualcostumes+3].lowerlegcolor[1]=bottomcolor[1]; costume[casualcostumes+3].lowerlegcolor[2]=bottomcolor[2]; - - costume[casualcostumes+3].footcolor[0]=footcolor[0]; costume[casualcostumes+3].footcolor[1]=footcolor[1]; costume[casualcostumes+3].footcolor[2]=footcolor[2]; - - if(!initialized){ //vip @@ -3282,120 +2722,90 @@ void Game::InitGame() topcolor[2]=(float)235/255; - - bottomcolor[0]=(float)200/255; bottomcolor[1]=(float)200/255; bottomcolor[2]=(float)200/255; - - footcolor[0]=(float)119/255; footcolor[1]=(float)68/255; footcolor[2]=(float)18/255; - - headcolor[0]=(float)240/255; headcolor[1]=(float)183/255; headcolor[2]=(float)132/255; - - footcolor[0]=(float)119/255; footcolor[1]=(float)68/255; footcolor[2]=(float)18/255; - - handcolor[0]=(float)240/255; handcolor[1]=(float)183/255; handcolor[2]=(float)132/255; - - costume[vipcostume].headcolor[0]=headcolor[0]; costume[vipcostume].headcolor[1]=headcolor[1]; costume[vipcostume].headcolor[2]=headcolor[2]; - - costume[vipcostume].handcolor[0]=handcolor[0]; costume[vipcostume].handcolor[1]=handcolor[1]; costume[vipcostume].handcolor[2]=handcolor[2]; - - costume[vipcostume].chestcolor[0]=topcolor[0]; costume[vipcostume].chestcolor[1]=topcolor[1]; costume[vipcostume].chestcolor[2]=topcolor[2]; - - costume[vipcostume].abdomencolor[0]=topcolor[0]; costume[vipcostume].abdomencolor[1]=topcolor[1]; costume[vipcostume].abdomencolor[2]=topcolor[2]; - - costume[vipcostume].upperarmcolor[0]=topcolor[0]; costume[vipcostume].upperarmcolor[1]=topcolor[1]; costume[vipcostume].upperarmcolor[2]=topcolor[2]; - - costume[vipcostume].lowerarmcolor[0]=topcolor[0]; costume[vipcostume].lowerarmcolor[1]=topcolor[1]; costume[vipcostume].lowerarmcolor[2]=topcolor[2]; - - costume[vipcostume].upperlegcolor[0]=bottomcolor[0]; costume[vipcostume].upperlegcolor[1]=bottomcolor[1]; costume[vipcostume].upperlegcolor[2]=bottomcolor[2]; - - costume[vipcostume].lowerlegcolor[0]=bottomcolor[0]; costume[vipcostume].lowerlegcolor[1]=bottomcolor[1]; costume[vipcostume].lowerlegcolor[2]=bottomcolor[2]; - - costume[vipcostume].footcolor[0]=footcolor[0]; costume[vipcostume].footcolor[1]=footcolor[1]; costume[vipcostume].footcolor[2]=footcolor[2]; - - //Bodyguard topcolor[0]=(float)50/255; @@ -3404,104 +2814,78 @@ void Game::InitGame() topcolor[2]=(float)50/255; - - bottomcolor[0]=(float)30/255; bottomcolor[1]=(float)30/255; bottomcolor[2]=(float)30/255; - - footcolor[0]=(float)20/255; footcolor[1]=(float)20/255; footcolor[2]=(float)20/255; - - costume[bodyguardcostume].headcolor[0]=headcolor[0]; costume[bodyguardcostume].headcolor[1]=headcolor[1]; costume[bodyguardcostume].headcolor[2]=headcolor[2]; - - costume[bodyguardcostume].handcolor[0]=handcolor[0]; costume[bodyguardcostume].handcolor[1]=handcolor[1]; costume[bodyguardcostume].handcolor[2]=handcolor[2]; - - costume[bodyguardcostume].chestcolor[0]=topcolor[0]; costume[bodyguardcostume].chestcolor[1]=topcolor[1]; costume[bodyguardcostume].chestcolor[2]=topcolor[2]; - - costume[bodyguardcostume].abdomencolor[0]=topcolor[0]; costume[bodyguardcostume].abdomencolor[1]=topcolor[1]; costume[bodyguardcostume].abdomencolor[2]=topcolor[2]; - - costume[bodyguardcostume].upperarmcolor[0]=topcolor[0]; costume[bodyguardcostume].upperarmcolor[1]=topcolor[1]; costume[bodyguardcostume].upperarmcolor[2]=topcolor[2]; - - costume[bodyguardcostume].lowerarmcolor[0]=topcolor[0]; costume[bodyguardcostume].lowerarmcolor[1]=topcolor[1]; costume[bodyguardcostume].lowerarmcolor[2]=topcolor[2]; - - costume[bodyguardcostume].upperlegcolor[0]=bottomcolor[0]; costume[bodyguardcostume].upperlegcolor[1]=bottomcolor[1]; costume[bodyguardcostume].upperlegcolor[2]=bottomcolor[2]; - - costume[bodyguardcostume].lowerlegcolor[0]=bottomcolor[0]; costume[bodyguardcostume].lowerlegcolor[1]=bottomcolor[1]; costume[bodyguardcostume].lowerlegcolor[2]=bottomcolor[2]; - - costume[bodyguardcostume].footcolor[0]=footcolor[0]; costume[bodyguardcostume].footcolor[1]=footcolor[1]; costume[bodyguardcostume].footcolor[2]=footcolor[2]; - - //Load animations loadingscreenamount+=5; if(!initialized)LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); - - testskeleton.Load((char *)":Data:Skeleton:Basic Figure"); animation[idleanim].Load((char *)":Data:Animations:Breathe"); @@ -3580,8 +2964,6 @@ void Game::InitGame() } - - //Setup people for(int i=0;i<max_people;i++){ @@ -3590,15 +2972,13 @@ void Game::InitGame() person[i].whichcostume=bodyguardcostume; - } - - + } if(i>1){ person[i].whichcostume=casualcostumes+abs(Random())%numcasual; - } + } //person[i].firstlongdead=0; @@ -3616,8 +2996,6 @@ void Game::InitGame() if(!initialized)person[i].skeleton.Load((char *)":Data:Skeleton:Basic Figure"); - - if(i%5==0){ loadingscreenamount+=5; @@ -3628,66 +3006,40 @@ void Game::InitGame() } - - loadingscreenamount+=5; if(!initialized)LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); - - if(initialized)person[0].skeleton.Load((char *)":Data:Skeleton:Basic Figure"); - - person[0].attackframe=-1; - - spawndelay=0; - - fog.SetFog(fogcolorr,fogcolorg,fogcolorb,0,viewdistance*.8,.1); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - - - //light GLfloat LightAmbient[]= { .3, .3, .3, 1.0f}; GLfloat LightDiffuse[]= { 1, 1, 1, 1.0f }; - - - glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); + glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient); - glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse); + glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse); - glEnable(GL_LIGHT0); - - + glEnable(GL_LIGHT0); loadingscreenamount+=5; - - //Load some textures if(!initialized){ LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); - - - - LoadPersonSpriteTexture(":Data:Textures:Personsprite.png",&personspritetextureptr); LoadPersonSpriteTexture(":Data:Textures:DeadPersonsprite.png",&deadpersonspritetextureptr); @@ -3696,8 +3048,6 @@ void Game::InitGame() LoadPersonSpriteTexture(":Data:Textures:Flare.png",&flaretextureptr); - - sprites.LoadFlareTexture(":Data:Textures:HitFlash.png"); sprites.LoadMuzzleFlareTexture(":Data:Textures:MuzzleFlash.png"); @@ -3738,8 +3088,6 @@ void Game::InitGame() } - - //Setup clip plane equation eqn[0]=0; @@ -3750,22 +3098,14 @@ void Game::InitGame() eqn[3]=0; - - glClearColor(fogcolorr,fogcolorg,fogcolorb,1); - - if(!initialized)InitMouse(); - - //Draw city one frame to fix evil menu bug if(!initialized)mainmenu=2; - - if(!initialized){ LoadingScreen(loadingscreenamount/loadingscreenamounttotal*100); @@ -3778,30 +3118,21 @@ void Game::InitGame() } - - initialized=1; - - loadingscreenamount+=5; - - //Sync to refresh rate - if(vblsync){ + if(vblsync){ GLint swapInt = 1; -#ifdef OS9 +#ifdef OS9 aglSetInteger(gOpenGLContext, AGL_SWAP_INTERVAL, &swapInt); #else - -#endif - - +#endif } @@ -3813,8 +3144,6 @@ void Game::InitGame() } - - for(int i=0;i<decals.howmanydecals;i++){ decals.DeleteDecal(0); @@ -3825,25 +3154,15 @@ void Game::InitGame() sprites.howmanysprites=0; - - losedelay=1; - - oldscore=score; } - - /*********************> InitGL() <*****/ - - - - -int Game::InitGL(void) +int Game::InitGL(void) { @@ -3851,8 +3170,8 @@ int Game::InitGL(void) if(!initialized){ - //Default config in case config is not found -#ifdef OS9 + //Default config in case config is not found +#ifdef OS9 HideCursor(); #else STUB_FUNCTION; @@ -3878,15 +3197,13 @@ int Game::InitGL(void) musictoggle=1; - - //If no config, write one ifstream ipstream("config.txt"); if(!ipstream) { - ofstream opstream("config.txt"); + ofstream opstream("config.txt"); opstream << "Screenwidth:\n"; @@ -4008,10 +3325,8 @@ int Game::InitGL(void) } - - //Read high score -#ifdef OS9 +#ifdef OS9 ifstream ipstream2(":Data:Highscore"); #else /* TODO */ @@ -4023,8 +3338,8 @@ int Game::InitGL(void) beatgame=0; -#ifdef OS9 - ofstream opstream(":Data:Highscore"); +#ifdef OS9 + ofstream opstream(":Data:Highscore"); #else /* TODO */ ofstream opstream("Data/Highscore"); @@ -4051,24 +3366,18 @@ int Game::InitGL(void) } - - sps=40; maxfps=90; - - disttest=1; cubetest=1; } - - //Setup screen -#ifdef OS9 +#ifdef OS9 if(screenwidth<640||screenheight<480) theScreen = SetupScreen( 640, 480 ); @@ -4077,8 +3386,6 @@ int Game::InitGL(void) theScreen = SetupScreen( screenwidth, screenheight ); - - gOpenGLContext = SetupAGL( ( AGLDrawable )theScreen ); if ( !gOpenGLContext ) @@ -4089,7 +3396,7 @@ int Game::InitGL(void) fprintf(stderr, "SDL Init Video failed: %s\n", SDL_GetError()); exit(EXIT_FAILURE); } - + atexit(SDL_Quit); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); @@ -4099,7 +3406,7 @@ int Game::InitGL(void) SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); if(screenwidth<640||screenheight<480) { -#ifdef FULLSCREEN +#ifdef FULLSCREEN if (SDL_SetVideoMode(640, 480, 0, SDL_OPENGL | SDL_FULLSCREEN) == NULL) { #else if (SDL_SetVideoMode(640, 480, 0, SDL_OPENGL) == NULL) { @@ -4117,9 +3424,9 @@ int Game::InitGL(void) exit(EXIT_FAILURE); } } - + SDL_WM_SetCaption("Black Shades", "Black Shades"); - + SDL_EnableUNICODE(1); /* toggle it to ON */ #ifdef FULLSCREEN @@ -4128,7 +3435,6 @@ int Game::InitGL(void) #endif #endif - text.LoadFontTexture(":Data:Textures:Font.png"); @@ -4138,77 +3444,56 @@ int Game::InitGL(void) glDepthFunc(GL_LESS); - - glPolygonOffset(-8,0); glPolygonMode( GL_FRONT_AND_BACK, GL_FILL ); - - return TRUE; } - - //***************> Dispose() <******/ -void Game::Dispose() +void Game::Dispose() { -#ifdef OS9 +#ifdef OS9 CleanupAGL( gOpenGLContext ); ShutdownScreen( theScreen ); ShowCursor(); #endif - //Delete sound sources alDeleteSources(100, gSourceID); - - } - - //***************> ResizeGLScene() <******/ -GLvoid Game::ReSizeGLScene(float fov, float near) +GLvoid Game::ReSizeGLScene(float fov, float near) { - if (screenheight==0) + if (screenheight==0) { - screenheight=1; + screenheight=1; } + glViewport(0,0,screenwidth,screenheight); + glMatrixMode(GL_PROJECTION); - glViewport(0,0,screenwidth,screenheight); - - - - glMatrixMode(GL_PROJECTION); - - glLoadIdentity(); - - + glLoadIdentity(); gluPerspective(fov,(GLfloat)screenwidth/(GLfloat)screenheight,near,viewdistance); + glMatrixMode(GL_MODELVIEW); - - glMatrixMode(GL_MODELVIEW); - - glLoadIdentity(); - + glLoadIdentity(); } - diff --git a/src/GameLoop.cpp b/src/GameLoop.cpp index 8a72b4b..eec916c 100644 --- a/src/GameLoop.cpp +++ b/src/GameLoop.cpp @@ -1,6 +1,4 @@ -#include "Game.h" - - +#include "Game.h" extern double multiplier; @@ -25,20 +23,17 @@ extern int slomo; void Game::HandleKeyDown( char theChar ) { - XYZ facing; - - if(!mainmenu){ switch( theChar ) { - case 'l': - if(!lasersight==1){lasersight=1;}else{lasersight=0;} - + case 'l': + if(!lasersight==1){lasersight=1;}else{lasersight=0;} + break; case 'k': @@ -47,8 +42,6 @@ void Game::HandleKeyDown( char theChar ) break; - - case 'b': if(debug){ @@ -66,7 +59,6 @@ void Game::HandleKeyDown( char theChar ) alSourcef(gSourceID[shootsong], AL_PITCH, (ALfloat)(.5)); alSourcef(gSourceID[zombiesong], AL_PITCH, (ALfloat)(.5)); - } if(!slomo){ @@ -103,13 +95,11 @@ void Game::HandleKeyDown( char theChar ) facing.z=-1; - - facing=DoRotation(facing,-camera.rotation2,0,0); facing=DoRotation(facing,0,0-camera.rotation,0); - for(int i=1;i<numpeople;i++){ + for(int i=1;i<numpeople;i++){ if(person[i].skeleton.free!=1){ @@ -171,21 +161,15 @@ void Game::HandleKeyDown( char theChar ) } - - /********************> DoEvent() <*****/ -#ifdef OS9 +#ifdef OS9 void Game::DoEvent( EventRecord *event ) { - - char theChar; - - switch ( event->what ) { @@ -202,14 +186,10 @@ void Game::DoEvent( EventRecord *event ) } - - - - } #endif -#ifndef OS9 +#ifndef OS9 static int mapinit = 0; static int sdlkeymap[SDLK_LAST]; @@ -218,11 +198,11 @@ static unsigned char ourkeys[16]; static void init_sdlkeymap() { int i; - + for (i = 0; i < SDLK_LAST; i++) { sdlkeymap[i] = -1; } - + sdlkeymap[SDLK_1] = MAC_1_KEY; sdlkeymap[SDLK_2] = MAC_2_KEY; sdlkeymap[SDLK_3] = MAC_3_KEY; @@ -306,7 +286,7 @@ static void init_sdlkeymap() sdlkeymap[SDLK_DOWN] = MAC_ARROW_DOWN_KEY; sdlkeymap[SDLK_LEFT] = MAC_ARROW_LEFT_KEY; sdlkeymap[SDLK_RIGHT] = MAC_ARROW_RIGHT_KEY; - + mapinit = 1; } @@ -322,39 +302,37 @@ static void DoSDLKey(Game *g, SDL_Event *event) int mackey; int index; int mask; - if (mapinit == 0) { init_sdlkeymap(); } - + mackey = sdlkeymap[event->key.keysym.sym]; - + if (mackey != -1) { index = mackey / 8; mask = 1 << (mackey % 8); - + if (press) { ourkeys[index] |= mask; } else { ourkeys[index] &= ~mask; } } - - if (event->key.keysym.unicode && + + if (event->key.keysym.unicode && !(event->key.keysym.unicode & 0xFF80)) { - + /* hey, at least it was aleady public */ g->HandleKeyDown(event->key.keysym.unicode); } - - + } static void ProcessSDLEvents(Game *g) { SDL_Event event; - + if (SDL_PollEvent(&event)) { do { switch(event.type) { @@ -388,7 +366,7 @@ static void ProcessSDLEvents(Game *g) } } while (SDL_PollEvent(&event)); } -} +} #endif @@ -398,7 +376,7 @@ void Game::EventLoop( void ) { -#ifdef OS9 +#ifdef OS9 EventRecord event; #endif @@ -414,25 +392,20 @@ void Game::EventLoop( void ) { -#ifdef OS9 +#ifdef OS9 if ( GetNextEvent( everyEvent, &event ) ) DoEvent( &event ); #else ProcessSDLEvents(this); #endif - start=TimerGetTime(&theTimer); - - colaccuracy=sps/framespersecond+1; if(colaccuracy>sps){colaccuracy=sps;} - - oldmult=multiplier; multiplier/=colaccuracy; @@ -445,11 +418,9 @@ void Game::EventLoop( void ) multiplier=oldmult; - - if ( DrawGLScene()) -#ifdef OS9 +#ifdef OS9 aglSwapBuffers( gOpenGLContext ); #else SDL_GL_SwapBuffers(); @@ -459,9 +430,7 @@ void Game::EventLoop( void ) gQuit = true; - oldmult=multiplier; - - + oldmult=multiplier; end=TimerGetTime(&theTimer); @@ -509,8 +478,8 @@ void Game::EventLoop( void ) highscore=score; -#ifdef OS9 - ofstream opstream(":Data:Highscore"); +#ifdef OS9 + ofstream opstream(":Data:Highscore"); #else /* TODO */ ofstream opstream("Data/Highscore"); @@ -532,8 +501,6 @@ void Game::EventLoop( void ) alSourcePause(gSourceID[rainsound]); - - mainmenu=1; alSourcePlay(gSourceID[souloutsound]); @@ -569,5 +536,4 @@ void Game::EventLoop( void ) } } - } diff --git a/src/GameTick.cpp b/src/GameTick.cpp index 6b28436..4249b05 100644 --- a/src/GameTick.cpp +++ b/src/GameTick.cpp @@ -1,6 +1,4 @@ -#include "Game.h" - - +#include "Game.h" extern double multiplier; @@ -10,8 +8,6 @@ extern int visions; extern Sprites sprites; - - extern unsigned int gSourceID[100]; extern unsigned int gSampleSet[100]; @@ -36,8 +32,6 @@ extern float soundscalefactor; extern int slomo; - - extern int forwardskey; extern int backwardskey; @@ -52,18 +46,13 @@ extern int psychicaimkey; extern int psychickey; - - extern Decals decals; /********************> Tick() <*****/ #define maxfallvel 40 - - void Game::Splat(int k){ - if(k!=0||visions==0){ person[k].health=0; @@ -76,8 +65,6 @@ void Game::Splat(int k){ person[k].longdead=1; - - person[k].bleeding=1; person[k].bleeddelay=1; @@ -86,8 +73,6 @@ void Game::Splat(int k){ person[k].bjoint2=&person[k].skeleton.joints[person[k].skeleton.jointlabels[neck]]; - - for(int j=0;j<person[k].skeleton.num_joints;j++){ person[k].skeleton.joints[j].position+=person[k].skeleton.joints[j].offset; @@ -101,11 +86,8 @@ void Game::Splat(int k){ person[k].skeleton.joints[j].velocity=0; person[k].skeleton.joints[j].velocity.y+=person[k].velocity.y; - } - - float gLoc[3]; gLoc[0]=person[k].skeleton.joints[person[k].skeleton.jointlabels[head]].position.x/soundscalefactor; @@ -118,32 +100,24 @@ void Game::Splat(int k){ alSourcePlay(gSourceID[headwhacksound]); - } + } } - - void Game::Tick(){ if(mainmenu){ - - unsigned char theKeyMap[16]; GetKeys( ( unsigned long * )theKeyMap ); - - if(IsKeyDown(theKeyMap, MAC_SPACE_KEY)){ mainmenu=0; } - - GetMouse(&mouseloc); float mousex=mouseloc.h; @@ -153,7 +127,6 @@ void Game::Tick(){ mousex=(float)mouseloc.h*640/screenwidth; mousey=480-(float)mouseloc.v*480/screenheight; - oldmouseoverbutton=mouseoverbutton; @@ -269,8 +242,8 @@ void Game::Tick(){ highscore=score; -#ifdef OS9 - ofstream opstream(":Data:Highscore"); +#ifdef OS9 + ofstream opstream(":Data:Highscore"); #else /* TODO */ ofstream opstream("Data/Highscore"); @@ -301,8 +274,8 @@ void Game::Tick(){ highscore=score; -#ifdef OS9 - ofstream opstream(":Data:Highscore"); +#ifdef OS9 + ofstream opstream(":Data:Highscore"); #else /* TODO */ ofstream opstream("Data/Highscore"); @@ -319,8 +292,6 @@ void Game::Tick(){ } - - if(Button())oldbutton=1; if(!Button())oldbutton=0; @@ -335,8 +306,6 @@ void Game::Tick(){ losedelay-=multiplier/6; } - - if(person[1].health>0&&person[0].health>0&&!killedinnocent)timeremaining-=multiplier*25/40; if(timeremaining<=0){ @@ -361,8 +330,6 @@ void Game::Tick(){ alSourcePause(gSourceID[rainsound]); - - alSourceStop(gSourceID[visionsound]); alSourceStop(gSourceID[whichsong]); @@ -387,8 +354,8 @@ void Game::Tick(){ highscore=score; -#ifdef OS9 - ofstream opstream(":Data:Highscore"); +#ifdef OS9 + ofstream opstream(":Data:Highscore"); #else /* TODO */ ofstream opstream("Data/Highscore"); @@ -467,48 +434,34 @@ void Game::Tick(){ } - - unsigned char theKeyMap[16]; GetKeys( ( unsigned long * )theKeyMap ); - - //Sprites sprites.DoStuff(); - - //Decals decals.DoStuff(); - - //Facing facing=0; facing.z=-1; - - facing=DoRotation(facing,-camera.rotation2,0,0); facing=DoRotation(facing,0,0-camera.rotation,0); - - flatfacing=facing; flatfacing.y=0; Normalise(&flatfacing); - - if(IsKeyDown(theKeyMap, psychickey)&&!oldvisionkey){ oldvisionkey=1; @@ -543,9 +496,7 @@ void Game::Tick(){ } - - - person[0].playercoords=bodycoords; + person[0].playercoords=bodycoords; person[0].oldplayercoords=bodycoords; @@ -553,7 +504,7 @@ void Game::Tick(){ alSourcePlay(gSourceID[soulinsound]); - alSourceStop(gSourceID[visionsound]); + alSourceStop(gSourceID[visionsound]); alSourcef(gSourceID[knifesong], AL_PITCH, (ALfloat)(1)); @@ -593,8 +544,6 @@ void Game::Tick(){ } - - if(IsKeyDown(theKeyMap, MAC_TAB_KEY)&&!tabkeydown&&debug){ thirdperson++; @@ -605,14 +554,10 @@ void Game::Tick(){ } - - if(!IsKeyDown(theKeyMap, MAC_TAB_KEY)) tabkeydown=0; - - if(IsKeyDown(theKeyMap, aimkey)&&!aimtoggle){ person[0].aiming=1-person[0].aiming; @@ -621,14 +566,10 @@ void Game::Tick(){ } - - if(!IsKeyDown(theKeyMap, aimkey)) aimtoggle=0; - - if(IsKeyDown(theKeyMap, MAC_R_KEY)&&!reloadtoggle){ if(person[0].reloads[person[0].whichgun]>0&&person[0].reloading<=0)person[0].ammo=-1; @@ -637,14 +578,10 @@ void Game::Tick(){ } - - if(!IsKeyDown(theKeyMap, MAC_R_KEY)) reloadtoggle=0; - - if(IsKeyDown(theKeyMap, psychicaimkey)&&!slomokeydown&&slomo==0){ alSourcePlay(gSourceID[souloutsound]); @@ -667,18 +604,12 @@ void Game::Tick(){ } - - if(!IsKeyDown(theKeyMap, psychicaimkey)) slomokeydown=0; - - //Mouse look - - if((person[0].aimamount<=0&&person[0].targetanimation!=crouchanim)){ camera.rotation=camera.visrotation; @@ -720,8 +651,6 @@ void Game::Tick(){ GetMouseRel(&mouseloc); #endif - - #if 0 // DDOI oldmouserotation=(oldmouseloc.h/1.3888)*mousesensitivity; @@ -732,8 +661,6 @@ void Game::Tick(){ mouserotation2=(mouseloc.v/1.3888)*mousesensitivity; - - #if 0 // DDOI if(abs(oldmouseloc.h-mouseloc.h)<400)camera.rotation+=mouserotation-oldmouserotation; @@ -757,22 +684,16 @@ void Game::Tick(){ if(mouseloc.v<-200)camera.rotation2+=mouserotation2+(300/1.3888*mousesensitivity); #endif - - if(camera.rotation2>89){camera.rotation2=89;} if(camera.rotation2<-89){camera.rotation2=-89;} - - //Smooth camera.rotation=(camera.oldoldrotation+((camera.rotation-camera.oldoldrotation)*.7+(camera.oldrotation-camera.oldoldrotation)*.3)); camera.rotation2=(camera.oldoldrotation2+((camera.rotation2-camera.oldoldrotation2)*.7+(camera.oldrotation2-camera.oldoldrotation2)*.3)); - - if(camera.visrotation<camera.rotation-7)camera.visrotation=camera.rotation-7; if(camera.visrotation>camera.rotation+7)camera.visrotation=camera.rotation+7; @@ -781,8 +702,6 @@ void Game::Tick(){ if(camera.visrotation2>camera.rotation2+15)camera.visrotation2=camera.rotation2+15; - - if(zoom||person[0].aimamount<=0||person[0].whichgun==nogun||visions||person[0].whichgun==grenade||person[0].whichgun==knife){ camera.visrotation=camera.rotation; @@ -793,8 +712,6 @@ void Game::Tick(){ oldzoom=zoom; - - camera.oldoldrotation=camera.oldrotation; camera.oldoldrotation2=camera.oldrotation2; @@ -803,12 +720,8 @@ void Game::Tick(){ camera.oldrotation2=camera.rotation2; - - //Check collision with buildings - - int beginx,endx; int beginz,endz; @@ -831,21 +744,15 @@ void Game::Tick(){ bool inblock; - - - - person[0].playerrotation=180-camera.rotation; - - //Check people collisions for(int k=0;k<numpeople;k++){ // SBF - backing up the old coordinates makes // the most sense here. person[k].oldplayercoords=person[k].playercoords; - + person[k].DoStuff(k); if(person[k].skeleton.free<1){ @@ -862,8 +769,6 @@ void Game::Tick(){ underpoint.y-=3000; - - beginx=(person[k].playercoords.x+block_spacing/2)/block_spacing; if(beginx<0)beginx=0; @@ -872,8 +777,6 @@ void Game::Tick(){ if(beginz<0)beginz=0; - - endx=(person[k].playercoords.x+block_spacing/2)/block_spacing+1; if(endx>num_blocks-1)endx=num_blocks-1; @@ -882,8 +785,6 @@ void Game::Tick(){ if(endz>num_blocks-1)endz=num_blocks-1; - - if(k!=0){ /* TODO: huh? */ beginx==person[k].whichblockx; @@ -896,8 +797,6 @@ void Game::Tick(){ } - - if(beginx<=endx&&beginz<=endz) for(int i=beginx;i<=endx;i++) @@ -1047,8 +946,6 @@ void Game::Tick(){ } - - if(IsKeyDown( theKeyMap, MAC_SPACE_KEY )){ if(visions==0&&person[0].targetanimation==joganim&&person[0].currentanimation==joganim&&person[0].backwardsanim==0&&person[0].playerrotation==person[0].playerlowrotation){ @@ -1065,8 +962,6 @@ void Game::Tick(){ } - - //Camera camera.oldposition=camera.position; @@ -1075,10 +970,6 @@ void Game::Tick(){ camera.targetoffset.z=-5; - - - - //Spawn people spawndelay-=multiplier; @@ -1103,7 +994,7 @@ void Game::Tick(){ } - if(cyclenum<10){ + if(cyclenum<10){ if(spawndelay<0&&numpeople<max_people){ @@ -1121,8 +1012,6 @@ void Game::Tick(){ } - - if(person[numpeople].type!=civiliantype&&blockspawnx==person[1].whichblockx&&blockspawny==person[1].whichblocky){ while((citypeoplenum[blockspawnx][blockspawny]>=max_people_block&&cyclenum<10)||blockspawnx==0||(blockspawnx==person[1].whichblockx&&blockspawny==person[1].whichblocky)){ @@ -1137,22 +1026,14 @@ void Game::Tick(){ } - - person[numpeople].playerrotation=0; - - person[numpeople].whichcostume=casualcostumes+abs(Random())%numcasual; - - person[numpeople].whichblockx=blockspawnx; person[numpeople].whichblocky=blockspawny; - - person[numpeople].pathnum=-1; person[numpeople].oldpathnum=-1; @@ -1169,7 +1050,7 @@ void Game::Tick(){ person[numpeople].pathtarget.x=path.vertex[person[numpeople].pathnum].x; - person[numpeople].pathtarget.z=path.vertex[person[numpeople].pathnum].z; + person[numpeople].pathtarget.z=path.vertex[person[numpeople].pathnum].z; person[numpeople].pathsize=.98+float(abs(Random()%20))/400; @@ -1179,18 +1060,12 @@ void Game::Tick(){ person[numpeople].pathtarget.z+=person[numpeople].whichblocky*block_spacing; - - - - person[numpeople].playercoords=person[numpeople].pathtarget; person[numpeople].oldplayercoords=person[numpeople].playercoords; person[numpeople].skeleton.free=0; - - person[numpeople].targetanimation=walkanim; if(person[numpeople].type==zombietype)person[numpeople].targetanimation=zombiewalkanim; @@ -1201,48 +1076,30 @@ void Game::Tick(){ person[numpeople].speedmult=.8+float(abs(Random()%20))/50; - person[numpeople].health=100; + person[numpeople].health=100; - person[numpeople].maxhealth=100; + person[numpeople].maxhealth=100; person[numpeople].playerrotation2=0; - - person[numpeople].lastdistancevictim=200000; - - if(person[numpeople].skeleton.broken)person[numpeople].skeleton.Load((char *)":Data:Skeleton:Basic Figure"); - - if(numpeople==1)person[numpeople].type=viptype; - - person[numpeople].killtarget=-1; - - if(person[numpeople].type==eviltype){person[numpeople].existing=1; person[numpeople].pathsize=1.04; person[numpeople].whichgun=nogun; person[numpeople].aiming=1; person[numpeople].killtarget=-1; person[numpeople].speedmult=1+.3*difficulty;} if(person[numpeople].type==zombietype){person[numpeople].existing=1; person[numpeople].pathsize=1.04; person[numpeople].whichgun=nogun; person[numpeople].aiming=0; person[numpeople].killtarget=-1; person[numpeople].speedmult=0.7+.2*difficulty;} else {person[numpeople].whichgun=nogun; person[numpeople].aiming=0; person[numpeople].killtarget=-1;} - - if(person[numpeople].type==viptype){person[numpeople].existing=1;} - - - - if(enemystate==2)person[numpeople].killtarget=1; - - numpeople++; citypeoplenum[blockspawnx][blockspawny]++; @@ -1299,20 +1156,14 @@ void Game::Tick(){ person[cycle].playerrotation=0; - - person[cycle].whichcostume=casualcostumes+abs(Random())%numcasual; - - citypeoplenum[person[cycle].whichblockx][person[cycle].whichblocky]--; person[cycle].whichblockx=blockspawnx; person[cycle].whichblocky=blockspawny; - - person[cycle].pathnum=-1; person[cycle].oldpathnum=-1; @@ -1329,7 +1180,7 @@ void Game::Tick(){ person[cycle].pathtarget.x=path.vertex[person[cycle].pathnum].x; - person[cycle].pathtarget.z=path.vertex[person[cycle].pathnum].z; + person[cycle].pathtarget.z=path.vertex[person[cycle].pathnum].z; person[cycle].pathsize=.98+float(abs(Random()%20))/400; @@ -1339,16 +1190,12 @@ void Game::Tick(){ person[cycle].pathtarget.z+=person[cycle].whichblocky*block_spacing; - - person[cycle].playercoords=person[cycle].pathtarget; person[cycle].oldplayercoords=person[cycle].playercoords; person[cycle].skeleton.free=0; - - person[cycle].targetanimation=walkanim; if(person[cycle].type==zombietype)person[cycle].targetanimation=zombiewalkanim; @@ -1365,48 +1212,32 @@ void Game::Tick(){ person[cycle].playerrotation2=0; - - if(person[cycle].skeleton.broken)person[cycle].skeleton.Load((char *)":Data:Skeleton:Basic Figure"); - - if(enemystate==1)person[cycle].killtarget=-1; - - if(person[cycle].type==eviltype){person[cycle].existing=1; person[cycle].pathsize=1.04; person[cycle].whichgun=nogun; person[cycle].aiming=1; person[cycle].killtarget=-1; person[cycle].speedmult=1+.3*difficulty;} if(person[cycle].type==zombietype){person[cycle].existing=1; person[cycle].pathsize=1.04; person[cycle].whichgun=nogun; person[cycle].aiming=0; person[cycle].killtarget=-1; person[cycle].speedmult=.7+.2*difficulty;} else {person[cycle].whichgun=nogun; person[cycle].aiming=0; person[cycle].killtarget=-1;} - - person[cycle].lastdistancevictim=200000; - - if(enemystate==2)person[cycle].killtarget=1; - - if(numpeople<max_people)numpeople++; citypeoplenum[blockspawnx][blockspawny]++; cycle++; - - spawndelay=.1; } }} - - XYZ towards; XYZ finaltarget; @@ -1417,22 +1248,14 @@ void Game::Tick(){ float leastdistance = 0.0; - - - - XYZ bleedloc; XYZ vel; - - float tooclose; float toofar; - - //People for(int i=0;i<numpeople;i++){ @@ -1539,8 +1362,6 @@ void Game::Tick(){ } - - if(person[i].maxhealth<100&&person[i].type==zombietype){ person[i].maxhealth+=multiplier*2; @@ -1675,14 +1496,10 @@ void Game::Tick(){ person[person[i].killtarget].skeleton.joints[person[person[i].killtarget].skeleton.jointlabels[rightshoulder]].locked=0; - - person[person[i].killtarget].longdead=1; } - - if(i>0&&enemystate!=1&&person[i].type==zombietype&&person[i].speedmult>.7){ if(findDistancefast(person[i].playercoords,person[1].playercoords)<20000)person[i].killtarget=1; @@ -1697,8 +1514,6 @@ void Game::Tick(){ } - - bool realcheck = false; //Pathfinding @@ -1711,7 +1526,7 @@ void Game::Tick(){ // b) we're moving away from our target realcheck=(abs(person[i].playercoords.x-person[i].pathtarget.x)<1&&abs(person[i].playercoords.z-person[i].pathtarget.z)<1) ||findDistancefast(person[i].playercoords,person[i].pathtarget)>findDistancefast(person[i].oldplayercoords,person[i].pathtarget); - + if(person[i].targetanimation==idleanim&&person[i].killtargetvisible==0){ person[i].targetanimation=walkanim; @@ -1736,9 +1551,9 @@ void Game::Tick(){ person[i].pathtarget.x=path.vertex[j].x; - person[i].pathtarget.z=path.vertex[j].z; + person[i].pathtarget.z=path.vertex[j].z; - person[i].pathtarget.y=path.vertex[j].y; + person[i].pathtarget.y=path.vertex[j].y; person[i].pathtarget*=person[i].pathsize; @@ -1752,7 +1567,7 @@ void Game::Tick(){ closesttarget=j; - } + } } @@ -1768,7 +1583,7 @@ void Game::Tick(){ person[i].pathtarget.x=path.vertex[person[i].pathnum].x; - person[i].pathtarget.z=path.vertex[person[i].pathnum].z; + person[i].pathtarget.z=path.vertex[person[i].pathnum].z; person[i].pathtarget*=person[i].pathsize; @@ -1796,8 +1611,6 @@ void Game::Tick(){ person[i].killtarget=1; - - //If pathfind if(realcheck){ @@ -1824,8 +1637,6 @@ void Game::Tick(){ if(beginz<0)beginz=0; - - endx=person[i].whichblockx+2; if(endx>num_blocks-1)endx=num_blocks-1; @@ -1834,8 +1645,6 @@ void Game::Tick(){ if(endz>num_blocks-1)endz=num_blocks-1; - - leastdistance=2000000; for(int l=beginx;l<=endx;l++){ @@ -1848,7 +1657,7 @@ void Game::Tick(){ person[i].pathtarget.y=path.vertex[j].y; - person[i].pathtarget.z=path.vertex[j].z; + person[i].pathtarget.z=path.vertex[j].z; person[i].pathtarget*=person[i].pathsize; @@ -1958,8 +1767,6 @@ void Game::Tick(){ } - - //If pathfind if(realcheck){ @@ -1976,9 +1783,9 @@ void Game::Tick(){ person[i].pathtarget.x=path.vertex[j].x; - person[i].pathtarget.z=path.vertex[j].z; + person[i].pathtarget.z=path.vertex[j].z; - person[i].pathtarget.y=path.vertex[j].y; + person[i].pathtarget.y=path.vertex[j].y; person[i].pathtarget*=person[i].pathsize; @@ -1996,7 +1803,7 @@ void Game::Tick(){ finaltarget=person[i].pathtarget; - } + } } @@ -2006,9 +1813,9 @@ void Game::Tick(){ person[i].pathtarget.x=path.vertex[j].x; - person[i].pathtarget.z=path.vertex[j].z; + person[i].pathtarget.z=path.vertex[j].z; - person[i].pathtarget.y=path.vertex[j].y; + person[i].pathtarget.y=path.vertex[j].y; person[i].pathtarget*=person[i].pathsize; @@ -2026,7 +1833,7 @@ void Game::Tick(){ finaltarget=person[i].pathtarget; - } + } } @@ -2042,8 +1849,6 @@ void Game::Tick(){ if(beginz<0)beginz=0; - - endx=person[i].whichblockx+2; if(endx>num_blocks-1)endx=num_blocks-1; @@ -2052,8 +1857,6 @@ void Game::Tick(){ if(endz>num_blocks-1)endz=num_blocks-1; - - leastdistance=2000000; for(int l=beginx;l<=endx;l++){ @@ -2068,7 +1871,7 @@ void Game::Tick(){ person[i].pathtarget.y=path.vertex[j].y; - person[i].pathtarget.z=path.vertex[j].z; + person[i].pathtarget.z=path.vertex[j].z; person[i].pathtarget*=person[i].pathsize; @@ -2132,8 +1935,6 @@ void Game::Tick(){ if(beginz<0)beginz=0; - - endx=person[i].whichblockx+2; if(endx>num_blocks-1)endx=num_blocks-1; @@ -2142,8 +1943,6 @@ void Game::Tick(){ if(endz>num_blocks-1)endz=num_blocks-1; - - for(int l=beginx;l<=endx;l++){ for(int m=beginx;m<=endx;m++){ @@ -2366,14 +2165,12 @@ void Game::Tick(){ if(person[i].killtargetvisible||realcheck)person[i].pathtarget=finaltarget; - if(realcheck)person[i].lastdistancevictim=findDistancefast(person[i].pathtarget,person[person[i].killtarget].playercoords); + if(realcheck)person[i].lastdistancevictim=findDistancefast(person[i].pathtarget,person[person[i].killtarget].playercoords); } } - - if(person[i].targetanimation!=zombieeatanim||person[i].type!=zombietype){ towards=person[i].playercoords-person[i].pathtarget; @@ -2394,8 +2191,6 @@ void Game::Tick(){ person[i].whichblocky=((person[i].playercoords.z+block_spacing/2)/block_spacing); - - if(!person[i].onground)person[i].velocity.y+=multiplier*gravity; if(!person[i].onground&&(i!=0||visions!=1))person[i].playercoords+=person[i].velocity*multiplier; @@ -2534,8 +2329,6 @@ void Game::Tick(){ } - - //Grenade if(Button()&&person[0].whichgun==grenade&&person[0].ammo>0&&person[0].reloading<=0&&person[0].attackframe<0&&person[0].targetanimation!=crouchanim){ @@ -2602,8 +2395,6 @@ void Game::Tick(){ } - - //Get gun int temp; @@ -2626,14 +2417,10 @@ void Game::Tick(){ gLoc[2]=person[0].playercoords.z/soundscalefactor; - - alSourcefv(gSourceID[clicksound], AL_POSITION, gLoc); alSourcePlay(gSourceID[clicksound]); - - temp=person[0].whichgun; temp2=person[0].ammo; @@ -2650,8 +2437,6 @@ void Game::Tick(){ person[0].aimamount=0; - - switched=1; } @@ -2660,8 +2445,6 @@ void Game::Tick(){ } - - //Throw if(Button()&&person[0].attackframe<0&&((person[0].whichgun==nogun||person[0].aiming==0)&&person[0].whichgun!=knife)&&person[0].currentanimation!=crouchanim&&person[0].targetanimation!=crouchanim&&person[0].targetanimation!=throwanim&&visions==0){ @@ -2674,7 +2457,7 @@ void Game::Tick(){ float closedistance=-1; - for(int i=1;i<numpeople;i++){ + for(int i=1;i<numpeople;i++){ if(person[i].skeleton.free<1&&(person[i].whichgun!=nogun)&&findDistancefast(person[i].playercoords,person[0].playercoords+flatfacing)<12){ @@ -2734,8 +2517,6 @@ void Game::Tick(){ } - - //Gun whacking if(Button()&&(person[0].aiming==0||person[0].ammo<=0||person[0].whichgun==nogun||person[0].whichgun==knife||person[0].targetanimation==joganim)&&person[0].currentanimation!=crouchanim&&person[0].targetanimation!=throwanim&&person[0].whichgun!=grenade&&person[0].targetanimation!=crouchanim&&visions==0){ @@ -2748,7 +2529,7 @@ void Game::Tick(){ float closedistance=-1; - for(int i=1;i<numpeople;i++){ + for(int i=1;i<numpeople;i++){ if(person[i].existing&&person[i].type!=viptype&&person[i].skeleton.free<1&&findDistancefast(person[i].playercoords,person[0].playercoords+flatfacing)<12+(person[0].whichgun==knife)*10){ @@ -2780,12 +2561,8 @@ void Game::Tick(){ } - - XYZ velocity; - - if(person[0].attackframe>1||(person[0].attackframe>=0&&person[0].currentanimation==joganim)){ if(person[person[0].killtarget].skeleton.free<1&&person[0].killtarget!=0&&(person[0].aiming<1||person[0].whichgun==nogun||person[0].whichgun==knife||person[0].targetanimation==joganim)){ @@ -2840,7 +2617,7 @@ void Game::Tick(){ sprites.MakeSprite(bloodspritedown, .8, 1, .2, .2,DoRotation(person[person[0].killtarget].skeleton.joints[person[person[0].killtarget].skeleton.jointlabels[neck]].position,0,person[person[0].killtarget].playerrotation,0)+person[person[0].killtarget].playercoords, velocity*.2, 3); - sprites.MakeSprite(bloodspritedown, .8, 1, .2, .2,DoRotation(person[person[0].killtarget].skeleton.joints[person[person[0].killtarget].skeleton.jointlabels[neck]].position,0,person[person[0].killtarget].playerrotation,0)+person[person[0].killtarget].playercoords, velocity*.1, 4); + sprites.MakeSprite(bloodspritedown, .8, 1, .2, .2,DoRotation(person[person[0].killtarget].skeleton.joints[person[person[0].killtarget].skeleton.jointlabels[neck]].position,0,person[person[0].killtarget].playerrotation,0)+person[person[0].killtarget].playercoords, velocity*.1, 4); } @@ -2924,7 +2701,7 @@ void Game::Tick(){ sprites.MakeSprite(bloodspritedown, .8, 1, .2, .2,DoRotation(person[person[0].killtarget].skeleton.joints[person[person[0].killtarget].skeleton.jointlabels[neck]].position,0,person[person[0].killtarget].playerrotation,0)+person[person[0].killtarget].playercoords, velocity*.2, 3); - sprites.MakeSprite(bloodspritedown, .8, 1, .2, .2,DoRotation(person[person[0].killtarget].skeleton.joints[person[person[0].killtarget].skeleton.jointlabels[neck]].position,0,person[person[0].killtarget].playerrotation,0)+person[person[0].killtarget].playercoords, velocity*.1, 4); + sprites.MakeSprite(bloodspritedown, .8, 1, .2, .2,DoRotation(person[person[0].killtarget].skeleton.joints[person[person[0].killtarget].skeleton.jointlabels[neck]].position,0,person[person[0].killtarget].playerrotation,0)+person[person[0].killtarget].playercoords, velocity*.1, 4); } @@ -2970,13 +2747,11 @@ void Game::Tick(){ } - - //Tackle if(person[0].currentanimation==diveanim&&visions==0){ - for(int i=1;i<numpeople;i++){ + for(int i=1;i<numpeople;i++){ if(person[i].skeleton.free<1&&findDistancefast(person[i].playercoords,person[0].playercoords+flatfacing)<22){ @@ -3022,8 +2797,6 @@ void Game::Tick(){ } - - //Fire/wing XYZ wallhit; @@ -3094,8 +2867,6 @@ void Game::Tick(){ gLoc[2]=person[0].playercoords.z/soundscalefactor; - - alSourcefv(gSourceID[clicksound], AL_POSITION, gLoc); alSourcePlay(gSourceID[clicksound]); @@ -3124,8 +2895,6 @@ void Game::Tick(){ if(person[person[j].killtarget].skeleton.free==1)inaccuracy*=3; - - person[j].shotdelay=shotdelayamount/difficulty; if(person[j].aiming>=1&&person[j].recoil<=0){ @@ -3198,12 +2967,8 @@ void Game::Tick(){ float gLoc[3]; - - start-=DoRotation(DoRotation(DoRotation(aim,0,-person[j].playerrotation,0),90,0,0),0,person[j].playerrotation,0)*.35; - - gLoc[0]=(camera.position.x+(start.x-camera.position.x)/4)/soundscalefactor; gLoc[1]=(camera.position.y+(start.y-camera.position.y)/4)/soundscalefactor; @@ -3230,12 +2995,8 @@ void Game::Tick(){ float gLoc[3]; - - start-=DoRotation(DoRotation(DoRotation(aim,0,-person[j].playerrotation,0),90,0,0),0,person[j].playerrotation,0)*.35; - - if(p==numshots-1){ gLoc[0]=(camera.position.x+(start.x-camera.position.x)/4)/soundscalefactor; @@ -3266,12 +3027,8 @@ void Game::Tick(){ start-=DoRotation(DoRotation(DoRotation(aim,0,-person[j].playerrotation,0),90,0,0),0,person[j].playerrotation,0)*.55; - - float gLoc[3]; - - gLoc[0]=(camera.position.x+(start.x-camera.position.x)/4)/soundscalefactor; gLoc[1]=(camera.position.y+(start.y-camera.position.y)/4)/soundscalefactor; @@ -3298,12 +3055,8 @@ void Game::Tick(){ start-=DoRotation(DoRotation(DoRotation(aim,0,-person[j].playerrotation,0),90,0,0),0,person[j].playerrotation,0)*.55; - - float gLoc[3]; - - gLoc[0]=(camera.position.x+(start.x-camera.position.x)/4)/soundscalefactor; gLoc[1]=(camera.position.y+(start.y-camera.position.y)/4)/soundscalefactor; @@ -3330,8 +3083,6 @@ void Game::Tick(){ start-=DoRotation(DoRotation(DoRotation(aim,0,-person[j].playerrotation,0),90,0,0),0,person[j].playerrotation,0)*.25; - - float gLoc[3]; gLoc[0]=(camera.position.x+(start.x-camera.position.x)/4)/soundscalefactor; @@ -3396,7 +3147,7 @@ void Game::Tick(){ if(i!=j&&i!=firstpass&&person[i].existing){ - temphitstruct=person[i].BulletCollideWithPlayer(i, start, end); + temphitstruct=person[i].BulletCollideWithPlayer(i, start, end); if(temphitstruct.collision){ @@ -3432,8 +3183,6 @@ void Game::Tick(){ if(beginz<0)beginz=0; - - endx=(person[j].playercoords.x+block_spacing/2)/block_spacing+3; if(endx>num_blocks-1)endx=num_blocks-1; @@ -3442,8 +3191,6 @@ void Game::Tick(){ if(endz>num_blocks-1)endz=num_blocks-1; - - if(beginx<endx&&beginz<endz) finalwallhit=0; @@ -3664,8 +3411,6 @@ void Game::Tick(){ person[whichhit].longdead=1; - - if(person[whichhit].health<=0){ person[whichhit].skeleton.offset=0; @@ -3814,8 +3559,6 @@ void Game::Tick(){ } - - XYZ velocity; velocity=aim*-8; @@ -3854,8 +3597,6 @@ void Game::Tick(){ } - - person[whichhit].bjoint1=hitstruct.joint1; person[whichhit].bjoint2=hitstruct.joint2; @@ -3976,7 +3717,7 @@ void Game::Tick(){ if(j!=0||zoom==0)sprites.MakeSprite(bullet, .07, 1, 1, .7, lastshot[0]+aim*1, lastshot[1], .2); - //Nearby bullet whoosh + //Nearby bullet whoosh long dot_ta,dot_tb; @@ -3998,8 +3739,6 @@ void Game::Tick(){ if (!dot_ta <= 0&&!dot_tb <= 0){ - - nearest.x = a->x + ((b->x - a->x) * dot_ta)/(dot_ta + dot_tb); nearest.y = a->y + ((b->y - a->y) * dot_ta)/(dot_ta +dot_tb); @@ -4008,16 +3747,12 @@ void Game::Tick(){ } - - if(nearest.x){ if(findDistancefast(nearest,camera.position)<10&&(thirdperson==2||j!=0)){ float gLoc[3]; - - gLoc[0]=(camera.position.x+(nearest.x-camera.position.x))/soundscalefactor; gLoc[1]=(camera.position.y+(nearest.y-camera.position.y))/soundscalefactor; @@ -4046,12 +3781,8 @@ void Game::Tick(){ } - - if(!Button())oldbutton=0; - - if(lasersight&&person[0].whichgun!=grenade){ for(int j=0;j<numpeople;j++){ @@ -4154,8 +3885,6 @@ void Game::Tick(){ if(beginz<0)beginz=0; - - endx=(person[j].playercoords.x+block_spacing/2)/block_spacing+2; if(endx>num_blocks-1)endx=num_blocks-1; @@ -4164,8 +3893,6 @@ void Game::Tick(){ if(endz>num_blocks-1)endz=num_blocks-1; - - if(beginx<endx&&beginz<endz) finalwallhit=0; @@ -4216,7 +3943,7 @@ void Game::Tick(){ if(i!=j&&findDistancefast(person[j].playercoords,person[i].playercoords)<20000){ - temphitstruct=person[i].BulletCollideWithPlayer(i, start, end); + temphitstruct=person[i].BulletCollideWithPlayer(i, start, end); if(temphitstruct.collision){ @@ -4246,8 +3973,6 @@ void Game::Tick(){ sprites.MakeSprite(bulletinstant, .4, 1, 0, 0, aimer[0], aimer[1], .2); - - } } @@ -4256,8 +3981,6 @@ void Game::Tick(){ } - - //Snow snowdelay-=multiplier; @@ -4300,9 +4023,7 @@ void Game::Tick(){ sprites.MakeSprite(rainsprite, .5, 1, 1, 1, start, velocity, 2.00); - } - - + } //Grenade collision @@ -4322,8 +4043,6 @@ void Game::Tick(){ } - - if(findLengthfast(sprites.velocity[i])>0){ wherex=(sprites.location[i].x+block_spacing/2)/block_spacing; @@ -4366,7 +4085,7 @@ void Game::Tick(){ alSourcefv(gSourceID[bouncesound+whichsound], AL_POSITION, gLoc); - if(sprites.size[i]<=1)alSourcePlay(gSourceID[bouncesound+whichsound]); + if(sprites.size[i]<=1)alSourcePlay(gSourceID[bouncesound+whichsound]); } @@ -4414,7 +4133,7 @@ void Game::Tick(){ alSourcefv(gSourceID[bouncesound+whichsound], AL_POSITION, gLoc); - if(sprites.size[i]<=1)alSourcePlay(gSourceID[bouncesound+whichsound]); + if(sprites.size[i]<=1)alSourcePlay(gSourceID[bouncesound+whichsound]); } @@ -4430,7 +4149,7 @@ void Game::Tick(){ if((j!=0||sprites.brightness[i]<.9)&&person[j].existing){ - hitstruct=person[j].BulletCollideWithPlayer(j, sprites.oldlocation[i], sprites.location[i]); + hitstruct=person[j].BulletCollideWithPlayer(j, sprites.oldlocation[i], sprites.location[i]); if(hitstruct.collision){ @@ -4622,9 +4341,9 @@ void Game::Tick(){ //} - for(int k=0;k<numpeople;k++){ + for(int k=0;k<numpeople;k++){ - if(person[k].existing&&(person[k].longdead!=-1||person[k].skeleton.free<1)){ + if(person[k].existing&&(person[k].longdead!=-1||person[k].skeleton.free<1)){ if((findDistancefast(person[k].playercoords,sprites.location[i])<700&&person[k].skeleton.free<1)||(findDistancefast(person[k].averageloc,sprites.location[i])<700&&person[k].skeleton.free>=1)){ @@ -4650,18 +4369,12 @@ void Game::Tick(){ person[k].longdead=1; - - person[k].bleeddelay=1; person[k].bjoint1=&person[k].skeleton.joints[person[k].skeleton.jointlabels[head]]; person[k].bjoint2=&person[k].skeleton.joints[person[k].skeleton.jointlabels[neck]]; - - - - for(int j=0;j<person[k].skeleton.num_joints;j++){ person[k].skeleton.joints[j].position=DoRotation(person[k].skeleton.joints[j].position,0,person[k].playerrotation,0); @@ -4722,8 +4435,6 @@ void Game::Tick(){ } - - } } @@ -4732,16 +4443,12 @@ void Game::Tick(){ } - - //camera shake camerashake-=multiplier; if(camerashake<0)camerashake=0; - - //camera position XYZ average; @@ -4750,20 +4457,14 @@ void Game::Tick(){ if(zoom)average=person[0].skeleton.joints[(person[0].skeleton.jointlabels[righthand])].position; - - if(person[0].skeleton.free==0&&thirdperson!=2)camera.position=person[0].playercoords+DoRotation(average,0,person[0].playerrotation,0); if(person[0].skeleton.free==1&&thirdperson!=2)camera.position=average; - - //Restraints if(camera.position.y<.1)camera.position.y=.1; - - if(thirdperson!=2){ oldrot=camera.visrotation; @@ -4772,27 +4473,25 @@ void Game::Tick(){ } - - //Kill count for(int i=0;i<numpeople;i++){ if(person[i].oldhealth>0&&person[i].health<=0){ - if(i==1)alSourcePlay(gSourceID[losesound]); + if(i==1)alSourcePlay(gSourceID[losesound]); if(person[i].type==civiliantype){ alSourcePlay(gSourceID[disguisekillsound]); - score-=300; + score-=300; } if(person[i].type==eviltype){ - alSourcePlay(gSourceID[soulinsound]); + alSourcePlay(gSourceID[soulinsound]); score+=75; @@ -4808,8 +4507,6 @@ void Game::Tick(){ } - - if(slomo==2){ psychicpower-=multiplier*15; @@ -4856,8 +4553,6 @@ void Game::Tick(){ if(psychicpower>10)psychicpower=10; - - //3d sound float gLoc[3]; @@ -4871,8 +4566,6 @@ void Game::Tick(){ alListenerfv(AL_POSITION, gLoc); - - //Set orientation with forward and up vectors XYZ upvector; @@ -4881,14 +4574,10 @@ void Game::Tick(){ upvector.z=-1; - - upvector=DoRotation(upvector,-camera.rotation2+90,0,0); upvector=DoRotation(upvector,0,0-camera.rotation,0); - - float ori[6]; ori[0] = -facing.x; @@ -4905,8 +4594,6 @@ void Game::Tick(){ alListenerfv(AL_ORIENTATION, ori); - - if(person[0].currentanimation==throwanim||person[0].currentanimation==diveanim||paused){ MoveMouse(oldmouseloc.h,oldmouseloc.v,&mouseloc); @@ -4917,10 +4604,7 @@ void Game::Tick(){ oldmouseloc=mouseloc; - - if(score<0)score=0; } - } diff --git a/src/MacInput.cpp b/src/MacInput.cpp index 512200d..5b7aeda 100644 --- a/src/MacInput.cpp +++ b/src/MacInput.cpp @@ -2,7 +2,7 @@ #include "MacInput.h" /**> Mouse Stuff <**/ -#ifdef OS9 +#ifdef OS9 CursorDevicePtr theCursor; #endif @@ -12,22 +12,21 @@ Boolean IsKeyDown( unsigned char *keyMap, unsigned short theKey ) long keyMapIndex; Boolean isKeyDown; short bitToCheck; - + // Calculate the key map index keyMapIndex = keyMap[theKey/8]; - + // Calculate the individual bit to check bitToCheck = theKey%8; - + // Check the status of the key isKeyDown = ( keyMapIndex >> bitToCheck ) & 0x01; - + // Return the status of the key return isKeyDown; - } -#ifdef OS9 +#ifdef OS9 void InitMouse() { CursorDeviceNewDevice( &theCursor ); //Mouse diff --git a/src/MacInput.h b/src/MacInput.h index 0c741aa..43b3dc0 100644 --- a/src/MacInput.h +++ b/src/MacInput.h @@ -4,7 +4,7 @@ /**> HEADER FILES <**/ #include <stdlib.h> #include <stdio.h> -#ifdef OS9 +#ifdef OS9 #include <CursorDevices.h> //Mouse #endif @@ -94,7 +94,6 @@ #define MAC_ARROW_LEFT_KEY 0x7B #define MAC_ARROW_RIGHT_KEY 0x7C - /**> FUNCTION PROTOTYPES <**/ Boolean IsKeyDown( unsigned char *keyMap, unsigned short theKey ); void InitMouse(); diff --git a/src/Main.cpp b/src/Main.cpp index 2c8f381..a4899a9 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -2,63 +2,38 @@ #include "Game.h" - - /********************> Globals <*****/ - - Game game; - - /********************> main() <*****/ int main( int argc, char *argv[] ) { - - -#ifdef OS9 +#ifdef OS9 ToolboxInit(); - - if ( HasAppearance() ) RegisterAppearanceClient(); #endif - - - game.InitGL(); - - game.InitGame(); - - game.EventLoop(); - - game.Dispose(); - -#ifdef OS9 +#ifdef OS9 if ( HasAppearance() ) UnregisterAppearanceClient(); - - FlushEvents( everyEvent, 0 ); ExitToShell(); #endif - - } - diff --git a/src/Models.cpp b/src/Models.cpp index b4fbb82..60330c2 100644 --- a/src/Models.cpp +++ b/src/Models.cpp @@ -15,7 +15,7 @@ void Model::UpdateVertexArray(){ vArray[i*27+6]=Triangles[i].r; vArray[i*27+7]=Triangles[i].g; vArray[i*27+8]=Triangles[i].b; - + vArray[i*27+9]=vertex[Triangles[i].vertex[1]].x; vArray[i*27+10]=vertex[Triangles[i].vertex[1]].y; vArray[i*27+11]=vertex[Triangles[i].vertex[1]].z; @@ -25,7 +25,7 @@ void Model::UpdateVertexArray(){ vArray[i*27+15]=Triangles[i].r; vArray[i*27+16]=Triangles[i].g; vArray[i*27+17]=Triangles[i].b; - + vArray[i*27+18]=vertex[Triangles[i].vertex[2]].x; vArray[i*27+19]=vertex[Triangles[i].vertex[2]].y; vArray[i*27+20]=vertex[Triangles[i].vertex[2]].z; @@ -36,7 +36,7 @@ void Model::UpdateVertexArray(){ vArray[i*27+25]=Triangles[i].g; vArray[i*27+26]=Triangles[i].b; } - + XYZ average; int howmany; average=0; @@ -67,24 +67,24 @@ bool Model::load(Str255 Name) short tfile; long err; Files file; - + tfile=file.OpenFile(Name); SetFPos(tfile,fsFromStart,0); // read model settings - + err=ReadShort(tfile,1,&vertexNum); err=ReadShort(tfile,1,&TriangleNum); - + // read the model data - + err=ReadXYZ(tfile,vertexNum,vertex); err=ReadTexturedTriangle(tfile,TriangleNum,Triangles); FSClose(tfile); - + UpdateVertexArray(); - + XYZ average; int howmany; average=0; @@ -100,7 +100,7 @@ bool Model::load(Str255 Name) if(findDistancefast(average,vertex[i])>boundingsphereradius)boundingsphereradius=findDistancefast(average,vertex[i]); } boundingsphereradius=sqrt(boundingsphereradius); - + return 1; } @@ -157,7 +157,6 @@ void Model::Rotate(float xang,float yang,float zang) UpdateVertexArray(); } - void Model::CalculateNormals() { int i; @@ -191,7 +190,6 @@ void Model::draw() } } - void Model::draw(float r, float g, float b) { if(!nocolors)glColor4f(r,g,b,1); @@ -234,7 +232,6 @@ void Model::draw(float r, float g, float b, float x, float y, float z) glDrawArrays(GL_TRIANGLES, 0, TriangleNum*3); } - int Model::LineCheck(XYZ p1,XYZ p2, XYZ *p) { int j; @@ -278,7 +275,7 @@ int Model::LineCheck2(XYZ p1,XYZ p2, XYZ *p, XYZ move, float rotate) distance=(point.x-p1.x)*(point.x-p1.x)+(point.y-p1.y)*(point.y-p1.y)+(point.z-p1.z)*(point.z-p1.z); if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;} } - + if(rotate)*p=DoRotation(*p,0,rotate,0); *p=*p+move; return firstintersecting; @@ -306,7 +303,7 @@ int Model::LineCheck2(XYZ *p1,XYZ *p2, XYZ *p, XYZ *move, float *rotate) distance=(point.x-p1->x)*(point.x-p1->x)+(point.y-p1->y)*(point.y-p1->y)+(point.z-p1->z)*(point.z-p1->z); if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;} } - + if(*rotate)*p=DoRotation(*p,0,*rotate,0); *p=*p+*move; return firstintersecting; diff --git a/src/Models.h b/src/Models.h index e49b8f1..d0a2575 100644 --- a/src/Models.h +++ b/src/Models.h @@ -6,7 +6,7 @@ // Model Maximums // #include "Quaternions.h" -#ifdef OS9 +#ifdef OS9 #include <gl.h> #include <glu.h> #else @@ -19,11 +19,10 @@ #define max_textured_triangle 400 // maximum number of texture-filled triangles in a model #define max_model_vertex max_textured_triangle*3 // maximum number of vertexs - // // Model Structures // - + class TexturedTriangle{ public: short vertex[3]; @@ -33,19 +32,19 @@ class TexturedTriangle{ class Model{ public: short vertexNum,TriangleNum; - + XYZ vertex[max_model_vertex]; XYZ normals[max_textured_triangle]; TexturedTriangle Triangles[max_textured_triangle]; GLfloat vArray[max_textured_triangle*27]; - + XYZ boundingspherecenter; float boundingsphereradius; int LineCheck(XYZ p1,XYZ p2, XYZ *p); int LineCheck2(XYZ p1,XYZ p2, XYZ *p,XYZ move,float rotate); int LineCheck2(XYZ *p1,XYZ *p2, XYZ *p,XYZ *move,float *rotate); int LineCheck3(XYZ p1,XYZ p2, XYZ *p,XYZ move,float rotate,float *d); - + void UpdateVertexArray(); bool load(Str255 Name); void Scale(float xscale,float yscale,float zscale); @@ -58,9 +57,8 @@ class Model{ void draw(float r,float g,float b, float x, float y, float z); void Rotate(float xang,float yang,float zang); void MultColor(float howmuch); - + XYZ boundingboxmin,boundingboxmax; }; #endif - diff --git a/src/Person.cpp b/src/Person.cpp index bc77ad9..597aba3 100644 --- a/src/Person.cpp +++ b/src/Person.cpp @@ -144,7 +144,7 @@ HitStruct Person::BulletCollideWithPlayer(int who, XYZ start, XYZ end){ glRotatef(skeleton.muscles[j].rotate3,0,1,0); glRotatef(skeleton.muscles[j].rotate2-90,0,0,1); glRotatef(skeleton.muscles[j].rotate1-90,0,1,0); - + glTranslatef( (-(skeleton.muscles[j].parent1->position.x+skeleton.muscles[j].parent2->position.x)/2), (-(skeleton.muscles[j].parent1->position.y+skeleton.muscles[j].parent2->position.y)/2), (-(skeleton.muscles[j].parent1->position.z+skeleton.muscles[j].parent2->position.z)/2)); @@ -189,8 +189,7 @@ HitStruct Person::BulletCollideWithPlayer(int who, XYZ start, XYZ end){ extern float camerashake; extern int cycle; -void Person::DoAnimations(int who){ - +void Person::DoAnimations(int who){ if(target>1&&!skeleton.free){ //Footstep sounds if(who==0&&slomo==0&&(targetanimation==joganim||targetanimation==walkanim)&&(targetframe==0||targetframe==8)&&visions==0&&(onground||abs(velocity.y)<1)){ @@ -251,7 +250,7 @@ void Person::DoAnimations(int who){ } } } - + if(!skeleton.free){ if(currentanimation!=lyinganim){ if(animation[targetanimation].speed[currentframe]>animation[currentanimation].speed[currentframe]) @@ -261,12 +260,12 @@ void Person::DoAnimations(int who){ } if(currentanimation==lyinganim){ target+=multiplier*animation[targetanimation].speed[targetframe]*speed; - } + } if(((currentanimation==crouchanim)&&(targetanimation!=crouchanim))||((currentanimation!=crouchanim)&&(targetanimation==crouchanim)))target+=multiplier*animation[crouchanim].speed[0]*2; if(currentanimation==idleanim&&targetanimation==idleanim)target-=multiplier*animation[idleanim].speed[0]/2; - + if(target>1)currentframe=targetframe; - + for(int i=0;i<skeleton.num_joints;i++){ if(currentanimation!=lyinganim){ skeleton.joints[i].velocity=((animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target))-(skeleton.joints[i].position))/multiplier; @@ -290,9 +289,9 @@ void Person::DoAnimations(int who){ } } } - + //Look up+down - if(!skeleton.free&&(whichgun!=nogun||who==0)&&health==100&¤tanimation!=lyinganim&¤tanimation!=getupfrontanim&¤tanimation!=getupbackanim&¤tanimation!=diveanim&&targetanimation!=diveanim&&targetanimation!=throwanim&&targetanimation!=thrownanim){ + if(!skeleton.free&&(whichgun!=nogun||who==0)&&health==100&¤tanimation!=lyinganim&¤tanimation!=getupfrontanim&¤tanimation!=getupbackanim&¤tanimation!=diveanim&&targetanimation!=diveanim&&targetanimation!=throwanim&&targetanimation!=thrownanim){ XYZ facing; XYZ facingdown; XYZ facinghalf; @@ -302,7 +301,7 @@ void Person::DoAnimations(int who){ //Facing facing=0; facing.z=1; - + facinghalf=DoRotation(facing,playerrotation2/2,0,0); facinghalf=DoRotation(facinghalf,0,-7,0); facing=DoRotation(facing,playerrotation2,0,0); @@ -313,7 +312,7 @@ void Person::DoAnimations(int who){ //Facing facing=0; facing.z=1; - + facinghalf=DoRotation(facing,playerrotation2/2,0,0); facinghalf=DoRotation(facinghalf,0,-7,0); facing=DoRotation(facing,playerrotation2,0,0); @@ -321,7 +320,7 @@ void Person::DoAnimations(int who){ facingdown=DoRotation(facing,90,0,0); } XYZ rotatearound; - XYZ oldpos; + XYZ oldpos; if(whichgun==sniperrifle){ for(int i=0;i<skeleton.num_joints;i++){ if(skeleton.joints[i].label!=righthand&&skeleton.joints[i].label!=rightelbow&&skeleton.joints[i].label!=rightwrist&&skeleton.joints[i].label!=lefthand&&skeleton.joints[i].label!=leftelbow&&skeleton.joints[i].label!=leftwrist){ @@ -339,7 +338,7 @@ void Person::DoAnimations(int who){ if(currentanimation==crouchanim||targetanimation==crouchanim)skeleton.joints[i].position-=(animation[idleanim].position[skeleton.jointlabels[neck]][0]-skeleton.joints[skeleton.jointlabels[neck]].position); } } - } + } if(whichgun==assaultrifle){ for(int i=0;i<skeleton.num_joints;i++){ if(skeleton.joints[i].label!=righthand&&skeleton.joints[i].label!=rightelbow&&skeleton.joints[i].label!=rightwrist&&skeleton.joints[i].label!=lefthand&&skeleton.joints[i].label!=leftelbow&&skeleton.joints[i].label!=leftwrist){ @@ -348,7 +347,7 @@ void Person::DoAnimations(int who){ if(currentanimation==crouchanim||targetanimation==crouchanim)skeleton.joints[i].position-=(animation[idleanim].position[skeleton.jointlabels[neck]][0]-skeleton.joints[skeleton.jointlabels[neck]].position); } } - } + } if((aiming||aimamount>0||whichgun==grenade)&&whichgun!=nogun){ if(aiming&&targetanimation!=joganim){ if(aimamount<1)aimamount+=multiplier*4; @@ -486,7 +485,7 @@ void Person::DoAnimations(int who){ } } } - + rotatearound=skeleton.joints[skeleton.jointlabels[abdomen]].position; if(who==0) for(int i=0;i<skeleton.num_joints;i++){ @@ -503,9 +502,9 @@ void Person::DoAnimations(int who){ rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position; skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,playerrotation2/2,0,0); } - + skeleton.DoConstraints(); - + //Reload if(whichgun!=nogun&&whichgun!=knife){ if(reloading>0){ @@ -519,9 +518,9 @@ void Person::DoAnimations(int who){ gLoc[0]=playercoords.x/soundscalefactor; gLoc[1]=playercoords.y/soundscalefactor; gLoc[2]=playercoords.z/soundscalefactor; -#ifdef DEBIAN_NEEDS_TO_UPDATE_THEIR_OPENAL +#ifdef DEBIAN_NEEDS_TO_UPDATE_THEIR_OPENAL alGetSourceiv(gSourceID[reloadsound], AL_SOURCE_STATE, &tempint); -#else +#else alGetSourcei(gSourceID[reloadsound], AL_SOURCE_STATE, &tempint); #endif @@ -541,7 +540,7 @@ void Person::DoAnimations(int who){ reloads[whichgun]--; } if(reloads[whichgun]==0&&whichgun==grenade&&ammo<=0){ - whichgun=nogun; + whichgun=nogun; } if(reloading<0){ reloading=0; @@ -587,7 +586,7 @@ void Person::DoAnimationslite(int who){ targetanimation=idleanim; } } - + if(!skeleton.free){ if(currentanimation!=lyinganim){ if(animation[targetanimation].speed[currentframe]>animation[currentanimation].speed[currentframe]) @@ -597,10 +596,10 @@ void Person::DoAnimationslite(int who){ } if(currentanimation==lyinganim){ target+=multiplier*animation[targetanimation].speed[targetframe]*speed; - } + } if(((currentanimation==crouchanim)&&(targetanimation!=crouchanim))||((currentanimation!=crouchanim)&&(targetanimation==crouchanim)))target+=multiplier*animation[crouchanim].speed[0]*2; if(currentanimation==idleanim&&targetanimation==idleanim)target-=multiplier*animation[idleanim].speed[0]/2; - + if(target>1)currentframe=targetframe; } } @@ -618,13 +617,13 @@ void Person::DoStuff(int who){ if(playerrotation<playerlowrotation-70){playerrotation=playerlowrotation-70;} } if(who==0)camera.rotation=180-playerrotation; - + if(who!=0&&visions==0){ if(targetanimation!=walkanim&&targetanimation!=zombiewalkanim)speed=1.0*speedmult; if(targetanimation==walkanim||targetanimation==zombiewalkanim)speed=1.8*speedmult; playerlowrotation=playerrotation; } - + //Do controls if(who==0&&targetanimation!=diveanim&&targetanimation!=throwanim&&targetanimation!=thrownanim&¤tanimation!=diveanim&¤tanimation!=getupfrontanim){ backwardsanim=0; @@ -634,7 +633,7 @@ void Person::DoStuff(int who){ if(visions==0&&targetanimation==walkanim)speed=2.5; unsigned char theKeyMap[16]; GetKeys( ( unsigned long * )theKeyMap ); - + if(IsKeyDown( theKeyMap, MAC_SHIFT_KEY )||visions==1){ moveanim=joganim; }else{ @@ -651,7 +650,7 @@ void Person::DoStuff(int who){ if((onground||(who==0&&visions==1))&¤tanimation!=crouchanim){ if ( IsKeyDown( theKeyMap, forwardskey )&&!( IsKeyDown( theKeyMap, backwardskey ))){ if(targetanimation!=moveanim)targetframe=0; - targetanimation=moveanim; + targetanimation=moveanim; } if ( IsKeyDown( theKeyMap, rightkey )&&!( IsKeyDown( theKeyMap, leftkey ))){ if(targetanimation!=moveanim)targetframe=0; @@ -678,7 +677,7 @@ void Person::DoStuff(int who){ float oldplayerrotation=playerrotation; if ( IsKeyDown( theKeyMap, forwardskey )&&!( IsKeyDown( theKeyMap, backwardskey ))){ facing=0; - facing.z=1; + facing.z=1; facing=DoRotation(facing,0,playerrotation,0); velocity=velocity+facing*multiplier*4; } @@ -687,7 +686,7 @@ void Person::DoStuff(int who){ if(IsKeyDown( theKeyMap, forwardskey ))playerrotation+=45; if(IsKeyDown( theKeyMap, backwardskey ))playerrotation-=45; facing=0; - facing.z=1; + facing.z=1; facing=DoRotation(facing,0,playerrotation,0); velocity=velocity+facing*multiplier*4; } @@ -696,14 +695,14 @@ void Person::DoStuff(int who){ if(IsKeyDown( theKeyMap, forwardskey ))playerrotation-=45; if(IsKeyDown( theKeyMap, backwardskey ))playerrotation+=45; facing=0; - facing.z=1; + facing.z=1; facing=DoRotation(facing,0,playerrotation,0); velocity=velocity+facing*multiplier*4; } if ( IsKeyDown( theKeyMap, backwardskey )&&!IsKeyDown( theKeyMap, forwardskey )&&!IsKeyDown( theKeyMap, leftkey )&&!IsKeyDown( theKeyMap, rightkey )){ playerrotation+=180; facing=0; - facing.z=1; + facing.z=1; facing=DoRotation(facing,0,playerrotation,0); velocity=velocity+facing*multiplier*4; } @@ -717,14 +716,13 @@ void Person::DoStuff(int who){ } } } - - + facing=0; facing.z=1; - + facing=DoRotation(facing,0,playerlowrotation,0); if(backwardsanim)facing*=-1; - + if(onground){ velocity=0; } @@ -744,7 +742,7 @@ void Person::FindRotationGun(XYZ start, XYZ target) { XYZ temppoint1,temppoint2,tempforward; float distance; - + temppoint1=start; temppoint2=target; distance=findDistance(temppoint1,temppoint2); @@ -779,7 +777,7 @@ int Person::DrawSkeleton(int who){ gunmodels[sniperriflemodel].draw(); glPopMatrix(); } - + if(whichgun==shotgun){ FindRotationGun(skeleton.joints[skeleton.jointlabels[righthand]].position,skeleton.joints[skeleton.jointlabels[lefthand]].position); glPushMatrix(); @@ -794,7 +792,7 @@ int Person::DrawSkeleton(int who){ gunmodels[shotgunmodel].draw(); glPopMatrix(); } - + if(whichgun==assaultrifle){ FindRotationGun(skeleton.joints[skeleton.jointlabels[righthand]].position,skeleton.joints[skeleton.jointlabels[lefthand]].position); glPushMatrix(); @@ -807,7 +805,7 @@ int Person::DrawSkeleton(int who){ gunmodels[assaultriflemodel].draw(); glPopMatrix(); } - + if(whichgun==handgun1){ if(!thirdperson&&who==0)FindRotationGun(skeleton.joints[skeleton.jointlabels[righthand]].position,(skeleton.joints[skeleton.jointlabels[head]].position*.65+skeleton.joints[skeleton.jointlabels[neck]].position*.35)); if(thirdperson||who!=0)FindRotationGun(skeleton.joints[skeleton.jointlabels[righthand]].position,(skeleton.joints[skeleton.jointlabels[head]].position*.35+skeleton.joints[skeleton.jointlabels[neck]].position*.65)); @@ -824,7 +822,7 @@ int Person::DrawSkeleton(int who){ gunmodels[handgunslidemodel].draw(); glPopMatrix(); } - + if(whichgun==handgun2){ if(!thirdperson&&who==0)FindRotationGun(skeleton.joints[skeleton.jointlabels[righthand]].position,(skeleton.joints[skeleton.jointlabels[head]].position*.65+skeleton.joints[skeleton.jointlabels[neck]].position*.35)); if(thirdperson||who!=0)FindRotationGun(skeleton.joints[skeleton.jointlabels[righthand]].position,(skeleton.joints[skeleton.jointlabels[head]].position*.35+skeleton.joints[skeleton.jointlabels[neck]].position*.65)); @@ -841,7 +839,7 @@ int Person::DrawSkeleton(int who){ gunmodels[handgun2slidemodel].draw(); glPopMatrix(); } - + if(whichgun==grenade){ glPushMatrix(); glTranslatef( skeleton.joints[skeleton.jointlabels[righthand]].position.x, @@ -857,7 +855,7 @@ int Person::DrawSkeleton(int who){ } glPopMatrix(); } - + if(whichgun==grenade){ glPushMatrix(); glTranslatef( skeleton.joints[skeleton.jointlabels[lefthand]].position.x, @@ -880,13 +878,13 @@ int Person::DrawSkeleton(int who){ lightpoint=skeleton.joints[skeleton.jointlabels[lefthand]].position; GLfloat LightPosition[]= {lightpoint.x,lightpoint.y,lightpoint.z,0}; glLightfv(GL_LIGHT1, GL_POSITION, LightPosition); - glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); - glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); + glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); + glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); glEnable(GL_LIGHT1); - + litup=0; } - + //Find forward vectors if(who==0||skeleton.free!=0||skeleton.offset!=0||whichgun!=nogun||currentanimation==lyinganim||((currentanimation==getupfrontanim||currentanimation==getupbackanim)&&targetanimation==idleanim)){ if(!(skeleton.free==1&&longdead<=0)){ @@ -908,13 +906,13 @@ int Person::DrawSkeleton(int who){ } CrossProduct(skeleton.joints[skeleton.forwardjoints[1]].position-skeleton.joints[skeleton.forwardjoints[0]].position,skeleton.joints[skeleton.forwardjoints[2]].position-skeleton.joints[skeleton.forwardjoints[0]].position,&skeleton.forward); Normalise(&skeleton.forward); - + CrossProduct(skeleton.joints[skeleton.lowforwardjoints[1]].position-skeleton.joints[skeleton.lowforwardjoints[0]].position,skeleton.joints[skeleton.lowforwardjoints[2]].position-skeleton.joints[skeleton.lowforwardjoints[0]].position,&skeleton.lowforward); Normalise(&skeleton.lowforward); - + //Special forwards skeleton.specialforward[0]=skeleton.forward; - + skeleton.specialforward[1]=skeleton.joints[skeleton.jointlabels[rightshoulder]].position+skeleton.joints[skeleton.jointlabels[rightwrist]].position; skeleton.specialforward[1]=skeleton.joints[skeleton.jointlabels[rightelbow]].position-skeleton.specialforward[1]/2; skeleton.specialforward[1]+=skeleton.forward*.2; @@ -931,13 +929,13 @@ int Person::DrawSkeleton(int who){ //Facing facing=0; facing.z=1; - + facing=DoRotation(facing,camera.rotation2,0,0); facingdown=DoRotation(facing,90,0,0); skeleton.specialforward[1]=skeleton.specialforward[1]*(1-aimamount)+facingdown*aimamount; skeleton.specialforward[2]=skeleton.specialforward[2]*(1-aimamount)+facingdown*aimamount; } - + skeleton.specialforward[3]=skeleton.joints[skeleton.jointlabels[righthip]].position+skeleton.joints[skeleton.jointlabels[rightankle]].position; skeleton.specialforward[3]=skeleton.specialforward[3]/2-skeleton.joints[skeleton.jointlabels[rightknee]].position; skeleton.specialforward[3]+=skeleton.lowforward*.2; @@ -983,7 +981,7 @@ int Person::DrawSkeleton(int who){ glPopMatrix(); } } - + for(int i=0;i<skeleton.num_muscles;i++){ if(skeleton.muscles[i].visible) { @@ -1004,7 +1002,7 @@ int Person::DrawSkeleton(int who){ if(skeleton.muscles[i].parent1->modelnum==6)skeletonmodels[skeleton.muscles[i].parent1->modelnum].draw(costume[whichcostume].upperlegcolor[0],costume[whichcostume].upperlegcolor[1],costume[whichcostume].upperlegcolor[2]); if(skeleton.muscles[i].parent1->modelnum==7)skeletonmodels[skeleton.muscles[i].parent1->modelnum].draw(costume[whichcostume].lowerlegcolor[0],costume[whichcostume].lowerlegcolor[1],costume[whichcostume].lowerlegcolor[2]); if(skeleton.muscles[i].parent1->modelnum==8)skeletonmodels[skeleton.muscles[i].parent1->modelnum].draw(costume[whichcostume].footcolor[0],costume[whichcostume].footcolor[1],costume[whichcostume].footcolor[2]); - + glPopMatrix(); } } @@ -1025,9 +1023,8 @@ int Person::DrawSkeleton(int who){ skeleton.joints[i].position=skeleton.joints[i].oldposition; } } - + glDisable(GL_LIGHT1); - + return 0; } - diff --git a/src/Person.h b/src/Person.h index e7542b0..8257e13 100644 --- a/src/Person.h +++ b/src/Person.h @@ -3,12 +3,12 @@ /**> HEADER FILES <**/ #include <cmath> -#ifdef OS9 +#ifdef OS9 #include <gl.h> #else #include <GL/gl.h> #endif -#ifdef OS9 +#ifdef OS9 #include "alut.h" #else #include <AL/al.h> @@ -62,16 +62,16 @@ class Person XYZ velocity; float shotdelay; bool litup; - + bool existing; - + int type; - + int whichcostume; - + Skeleton skeleton; Animation tempanimation; - + bool freshshootkey; bool freshkickkey; int bufferattack; @@ -82,7 +82,7 @@ class Person int shoot_key; int kick_key; int block_key; - + float speed; bool aiming; int grenphase; @@ -90,7 +90,7 @@ class Person float aimamount; float speedmult; float pathsize; - + int pathnum; int oldpathnum; int oldoldpathnum; @@ -98,26 +98,26 @@ class Person XYZ pathtarget; int whichblockx; int whichblocky; - + bool dead; - + XYZ averageloc; XYZ oldaverageloc; - + float lastdistancevictim; - + bool firstlongdead; float longdead; - + Joint *bjoint1,*bjoint2; float bleeding; float bleeddelay; - + float attacktarget; int attackframe; int killtarget; bool killtargetvisible; - + float gunrotate1, gunrotate2, gunrotate3; float recoil; int whichgun; @@ -129,14 +129,14 @@ class Person int reloads[10]; bool running; bool onpath; - + void FindRotationGun(XYZ start, XYZ target); - + int DrawSkeleton(int who); void DoStuff(int who); - void DoAnimations(int who); - void DoAnimationslite(int who); - HitStruct BulletCollideWithPlayer(int who, XYZ start, XYZ end); + void DoAnimations(int who); + void DoAnimationslite(int who); + HitStruct BulletCollideWithPlayer(int who, XYZ start, XYZ end); }; class Costume @@ -153,5 +153,4 @@ class Costume float chestcolor[3]; }; - #endif diff --git a/src/PhysicsMath.h b/src/PhysicsMath.h index 99ef76f..758931b 100644 --- a/src/PhysicsMath.h +++ b/src/PhysicsMath.h @@ -2,33 +2,23 @@ #define _PHYSICSMATH_H_ - - #include <cmath> #include "Quaternions.h" - - //------------------------------------------------------------------------// // Misc. Constants //------------------------------------------------------------------------// - - float const pi = 3.14159265f; float const g = -32.174f; // acceleration due to gravity, ft/s^2 float const rho = 0.0023769f; // desity of air at sea level, slugs/ft^3 -float const tol = 0.0000000001f; // float type tolerance - - - - +float const tol = 0.0000000001f; // float type tolerance //------------------------------------------------------------------------// @@ -40,28 +30,20 @@ inline float DegreesToRadians(float deg); inline float RadiansToDegrees(float rad); - - inline float DegreesToRadians(float deg) { - return deg * pi / 180.0f; - } - - inline float RadiansToDegrees(float rad) -{ +{ return rad * 180.0f / pi; } - - //------------------------------------------------------------------------// // Vector Class and vector functions @@ -78,22 +60,16 @@ public: float z; - - Vector(void); Vector(float xi, float yi, float zi); - - float Magnitude(void); void Normalize(void); void Reverse(void); - - Vector& operator+=(Vector u); // vector addition Vector& operator-=(Vector u); // vector subtraction @@ -102,16 +78,10 @@ public: Vector& operator/=(float s); // scalar divide - - Vector operator-(void); - - }; - - inline Vector operator+(Vector u, Vector v); inline Vector operator-(Vector u, Vector v); @@ -128,8 +98,6 @@ inline Vector operator/(Vector u, float s); inline float TripleScalarProduct(Vector u, Vector v, Vector w); - - inline Vector::Vector(void) { @@ -142,8 +110,6 @@ inline Vector::Vector(void) } - - inline Vector::Vector(float xi, float yi, float zi) { @@ -156,8 +122,6 @@ inline Vector::Vector(float xi, float yi, float zi) } - - inline float Vector::Magnitude(void) { @@ -166,8 +130,6 @@ inline float Vector::Magnitude(void) } - - inline void Vector::Normalize(void) { @@ -180,9 +142,7 @@ inline void Vector::Normalize(void) y /= m; - z /= m; - - + z /= m; if (fabs(x) < tol) x = 0.0f; @@ -192,8 +152,6 @@ inline void Vector::Normalize(void) } - - inline void Vector::Reverse(void) { @@ -206,8 +164,6 @@ inline void Vector::Reverse(void) } - - inline Vector& Vector::operator+=(Vector u) { @@ -222,8 +178,6 @@ inline Vector& Vector::operator+=(Vector u) } - - inline Vector& Vector::operator-=(Vector u) { @@ -238,8 +192,6 @@ inline Vector& Vector::operator-=(Vector u) } - - inline Vector& Vector::operator*=(float s) { @@ -254,8 +206,6 @@ inline Vector& Vector::operator*=(float s) } - - inline Vector& Vector::operator/=(float s) { @@ -270,8 +220,6 @@ inline Vector& Vector::operator/=(float s) } - - inline Vector Vector::operator-(void) { @@ -280,10 +228,6 @@ inline Vector Vector::operator-(void) } - - - - inline Vector operator+(Vector u, Vector v) { @@ -292,8 +236,6 @@ inline Vector operator+(Vector u, Vector v) } - - inline Vector operator-(Vector u, Vector v) { @@ -302,8 +244,6 @@ inline Vector operator-(Vector u, Vector v) } - - // Vector cross product (u cross v) inline Vector operator^(Vector u, Vector v) @@ -318,8 +258,6 @@ inline Vector operator^(Vector u, Vector v) } - - // Vector dot product inline float operator*(Vector u, Vector v) @@ -330,8 +268,6 @@ inline float operator*(Vector u, Vector v) } - - inline Vector operator*(float s, Vector u) { @@ -340,8 +276,6 @@ inline Vector operator*(float s, Vector u) } - - inline Vector operator*(Vector u, float s) { @@ -350,8 +284,6 @@ inline Vector operator*(Vector u, float s) } - - inline Vector operator/(Vector u, float s) { @@ -360,8 +292,6 @@ inline Vector operator/(Vector u, float s) } - - // triple scalar product (u dot (v cross w)) inline float TripleScalarProduct(Vector u, Vector v, Vector w) @@ -376,52 +306,36 @@ inline float TripleScalarProduct(Vector u, Vector v, Vector w) //return u*(v^w); - - } - - - - - - //------------------------------------------------------------------------// // Matrix Class and matrix functions //------------------------------------------------------------------------// - - class Matrix3x3 { public: // elements eij: i -> row, j -> column - float e11, e12, e13, e21, e22, e23, e31, e32, e33; - - + float e11, e12, e13, e21, e22, e23, e31, e32, e33; Matrix3x3(void); - Matrix3x3( float r1c1, float r1c2, float r1c3, + Matrix3x3( float r1c1, float r1c2, float r1c3, - float r2c1, float r2c2, float r2c3, + float r2c1, float r2c2, float r2c3, float r3c1, float r3c2, float r3c3 ); - - float det(void); Matrix3x3 Transpose(void); Matrix3x3 Inverse(void); - - Matrix3x3& operator+=(Matrix3x3 m); Matrix3x3& operator-=(Matrix3x3 m); @@ -432,8 +346,6 @@ public: }; - - inline Matrix3x3 operator+(Matrix3x3 m1, Matrix3x3 m2); inline Matrix3x3 operator-(Matrix3x3 m1, Matrix3x3 m2); @@ -450,16 +362,6 @@ inline Vector operator*(Matrix3x3 m, Vector u); inline Vector operator*(Vector u, Matrix3x3 m); - - - - - - - - - - inline Matrix3x3::Matrix3x3(void) { @@ -484,11 +386,9 @@ inline Matrix3x3::Matrix3x3(void) } +inline Matrix3x3::Matrix3x3( float r1c1, float r1c2, float r1c3, - -inline Matrix3x3::Matrix3x3( float r1c1, float r1c2, float r1c3, - - float r2c1, float r2c2, float r2c3, + float r2c1, float r2c2, float r2c3, float r3c1, float r3c2, float r3c3 ) @@ -514,28 +414,24 @@ inline Matrix3x3::Matrix3x3( float r1c1, float r1c2, float r1c3, } - - inline float Matrix3x3::det(void) { - return e11*e22*e33 - + return e11*e22*e33 - - e11*e32*e23 + + e11*e32*e23 + - e21*e32*e13 - + e21*e32*e13 - - e21*e12*e33 + + e21*e12*e33 + - e31*e12*e23 - + e31*e12*e23 - - e31*e22*e13; + e31*e22*e13; } - - inline Matrix3x3 Matrix3x3::Transpose(void) { @@ -544,30 +440,24 @@ inline Matrix3x3 Matrix3x3::Transpose(void) } - - inline Matrix3x3 Matrix3x3::Inverse(void) { - float d = e11*e22*e33 - + float d = e11*e22*e33 - - e11*e32*e23 + + e11*e32*e23 + - e21*e32*e13 - + e21*e32*e13 - - e21*e12*e33 + + e21*e12*e33 + - e31*e12*e23 - + e31*e12*e23 - e31*e22*e13; - - if (d == 0) d = 1; - - return Matrix3x3( (e22*e33-e23*e32)/d, -(e12*e33-e13*e32)/d, @@ -584,12 +474,10 @@ inline Matrix3x3 Matrix3x3::Inverse(void) -(e11*e32-e12*e31)/d, - (e11*e22-e12*e21)/d ); + (e11*e22-e12*e21)/d ); } - - inline Matrix3x3& Matrix3x3::operator+=(Matrix3x3 m) { @@ -616,8 +504,6 @@ inline Matrix3x3& Matrix3x3::operator+=(Matrix3x3 m) } - - inline Matrix3x3& Matrix3x3::operator-=(Matrix3x3 m) { @@ -644,8 +530,6 @@ inline Matrix3x3& Matrix3x3::operator-=(Matrix3x3 m) } - - inline Matrix3x3& Matrix3x3::operator*=(float s) { @@ -672,8 +556,6 @@ inline Matrix3x3& Matrix3x3::operator*=(float s) } - - inline Matrix3x3& Matrix3x3::operator/=(float s) { @@ -700,8 +582,6 @@ inline Matrix3x3& Matrix3x3::operator/=(float s) } - - inline Matrix3x3 operator+(Matrix3x3 m1, Matrix3x3 m2) { @@ -726,8 +606,6 @@ inline Matrix3x3 operator+(Matrix3x3 m1, Matrix3x3 m2) } - - inline Matrix3x3 operator-(Matrix3x3 m1, Matrix3x3 m2) { @@ -752,11 +630,9 @@ inline Matrix3x3 operator-(Matrix3x3 m1, Matrix3x3 m2) } - - inline Matrix3x3 operator/(Matrix3x3 m, float s) -{ +{ return Matrix3x3( m.e11/s, @@ -778,8 +654,6 @@ inline Matrix3x3 operator/(Matrix3x3 m, float s) } - - inline Matrix3x3 operator*(Matrix3x3 m1, Matrix3x3 m2) { @@ -804,8 +678,6 @@ inline Matrix3x3 operator*(Matrix3x3 m1, Matrix3x3 m2) } - - inline Matrix3x3 operator*(Matrix3x3 m, float s) { @@ -830,8 +702,6 @@ inline Matrix3x3 operator*(Matrix3x3 m, float s) } - - inline Matrix3x3 operator*(float s, Matrix3x3 m) { @@ -856,8 +726,6 @@ inline Matrix3x3 operator*(float s, Matrix3x3 m) } - - inline Vector operator*(Matrix3x3 m, Vector u) { @@ -866,12 +734,10 @@ inline Vector operator*(Matrix3x3 m, Vector u) m.e21*u.x + m.e22*u.y + m.e23*u.z, - m.e31*u.x + m.e32*u.y + m.e33*u.z); + m.e31*u.x + m.e32*u.y + m.e33*u.z); } - - inline Vector operator*(Vector u, Matrix3x3 m) { @@ -884,16 +750,12 @@ inline Vector operator*(Vector u, Matrix3x3 m) } - - //------------------------------------------------------------------------// // Quaternion Class and Quaternion functions //------------------------------------------------------------------------// - - class Quaternion { public: @@ -902,14 +764,10 @@ public: Vector v; // vector part: v.x, v.y, v.z - - Quaternion(void); Quaternion(float e0, float e1, float e2, float e3); - - float Magnitude(void); Vector GetVector(void); @@ -928,8 +786,6 @@ public: }; - - inline Quaternion operator+(Quaternion q1, Quaternion q2); inline Quaternion operator-(Quaternion q1, Quaternion q2); @@ -958,10 +814,6 @@ inline Quaternion MakeQFromEulerAngles(float x, float y, float z); inline Vector MakeEulerAnglesFromQ(Quaternion q); - - - - inline Quaternion::Quaternion(void) { @@ -976,8 +828,6 @@ inline Quaternion::Quaternion(void) } - - inline Quaternion::Quaternion(float e0, float e1, float e2, float e3) { @@ -992,8 +842,6 @@ inline Quaternion::Quaternion(float e0, float e1, float e2, float e3) } - - inline float Quaternion::Magnitude(void) { @@ -1002,8 +850,6 @@ inline float Quaternion::Magnitude(void) } - - inline Vector Quaternion::GetVector(void) { @@ -1012,8 +858,6 @@ inline Vector Quaternion::GetVector(void) } - - inline float Quaternion::GetScalar(void) { @@ -1022,8 +866,6 @@ inline float Quaternion::GetScalar(void) } - - inline Quaternion Quaternion::operator+=(Quaternion q) { @@ -1040,8 +882,6 @@ inline Quaternion Quaternion::operator+=(Quaternion q) } - - inline Quaternion Quaternion::operator-=(Quaternion q) { @@ -1058,8 +898,6 @@ inline Quaternion Quaternion::operator-=(Quaternion q) } - - inline Quaternion Quaternion::operator*=(float s) { @@ -1076,8 +914,6 @@ inline Quaternion Quaternion::operator*=(float s) } - - inline Quaternion Quaternion::operator/=(float s) { @@ -1094,8 +930,6 @@ inline Quaternion Quaternion::operator/=(float s) } - - /*inline Quaternion Quaternion::operator~() { @@ -1104,8 +938,6 @@ inline Quaternion Quaternion::operator/=(float s) }*/ - - inline Quaternion operator+(Quaternion q1, Quaternion q2) { @@ -1120,8 +952,6 @@ inline Quaternion operator+(Quaternion q1, Quaternion q2) } - - inline Quaternion operator-(Quaternion q1, Quaternion q2) { @@ -1136,8 +966,6 @@ inline Quaternion operator-(Quaternion q1, Quaternion q2) } - - inline Quaternion operator*(Quaternion q1, Quaternion q2) { @@ -1148,12 +976,10 @@ inline Quaternion operator*(Quaternion q1, Quaternion q2) q1.n*q2.v.y + q1.v.y*q2.n + q1.v.z*q2.v.x - q1.v.x*q2.v.z, - q1.n*q2.v.z + q1.v.z*q2.n + q1.v.x*q2.v.y - q1.v.y*q2.v.x); + q1.n*q2.v.z + q1.v.z*q2.n + q1.v.x*q2.v.y - q1.v.y*q2.v.x); } - - inline Quaternion operator*(Quaternion q, float s) { @@ -1162,8 +988,6 @@ inline Quaternion operator*(Quaternion q, float s) } - - inline Quaternion operator*(float s, Quaternion q) { @@ -1172,8 +996,6 @@ inline Quaternion operator*(float s, Quaternion q) } - - inline Quaternion operator*(Quaternion q, Vector v) { @@ -1188,8 +1010,6 @@ inline Quaternion operator*(Quaternion q, Vector v) } - - inline Quaternion operator*(Vector v, Quaternion q) { @@ -1204,8 +1024,6 @@ inline Quaternion operator*(Vector v, Quaternion q) } - - inline Quaternion operator/(Quaternion q, float s) { @@ -1214,8 +1032,6 @@ inline Quaternion operator/(Quaternion q, float s) } - - inline float QGetAngle(Quaternion q) { @@ -1224,8 +1040,6 @@ inline float QGetAngle(Quaternion q) } - - inline Vector QGetAxis(Quaternion q) { @@ -1234,26 +1048,20 @@ inline Vector QGetAxis(Quaternion q) float m; - - v = q.GetVector(); m = v.Magnitude(); - - if (m <= tol) return Vector(); else - return v/m; + return v/m; } - - inline Quaternion QRotate(Quaternion q1, Quaternion q2) { @@ -1262,28 +1070,18 @@ inline Quaternion QRotate(Quaternion q1, Quaternion q2) } - - inline Vector QVRotate(Quaternion q, Vector v) { Quaternion t; - - - - t = q*v*(~q); - - return t.GetVector(); } - - inline Quaternion MakeQFromEulerAngles(float x, float y, float z) { @@ -1296,14 +1094,10 @@ inline Quaternion MakeQFromEulerAngles(float x, float y, float z) double yaw = DegreesToRadians(z); - - double cyaw, cpitch, croll, syaw, spitch, sroll; double cyawcpitch, syawspitch, cyawspitch, syawcpitch; - - cyaw = cos(0.5f * yaw); cpitch = cos(0.5f * pitch); @@ -1316,8 +1110,6 @@ inline Quaternion MakeQFromEulerAngles(float x, float y, float z) sroll = sin(0.5f * roll); - - cyawcpitch = cyaw*cpitch; syawspitch = syaw*spitch; @@ -1326,24 +1118,18 @@ inline Quaternion MakeQFromEulerAngles(float x, float y, float z) syawcpitch = syaw*cpitch; - - q.n = (float) (cyawcpitch * croll + syawspitch * sroll); - q.v.x = (float) (cyawcpitch * sroll - syawspitch * croll); + q.v.x = (float) (cyawcpitch * sroll - syawspitch * croll); q.v.y = (float) (cyawspitch * croll + syawcpitch * sroll); q.v.z = (float) (syawcpitch * croll - cyawspitch * sroll); - - return q; } - - inline Vector MakeEulerAnglesFromQ(Quaternion q) { @@ -1356,8 +1142,6 @@ inline Vector MakeEulerAnglesFromQ(Quaternion q) Vector u; - - q00 = q.n * q.n; q11 = q.v.x * q.v.x; @@ -1366,8 +1150,6 @@ inline Vector MakeEulerAnglesFromQ(Quaternion q) q33 = q.v.z * q.v.z; - - r11 = q00 + q11 - q22 - q33; r21 = 2 * (q.v.x*q.v.y + q.n*q.v.z); @@ -1378,8 +1160,6 @@ inline Vector MakeEulerAnglesFromQ(Quaternion q) r33 = q00 - q11 - q22 + q33; - - tmp = fabs(r31); if(tmp > 0.999999) @@ -1390,8 +1170,6 @@ inline Vector MakeEulerAnglesFromQ(Quaternion q) r13 = 2 * (q.v.x*q.v.z + q.n*q.v.y); - - u.x = RadiansToDegrees(0.0f); //roll u.y = RadiansToDegrees((float) (-(pi/2) * r31/tmp)); // pitch @@ -1402,8 +1180,6 @@ inline Vector MakeEulerAnglesFromQ(Quaternion q) } - - u.x = RadiansToDegrees((float) atan2(r32, r33)); // roll u.y = RadiansToDegrees((float) asin(-r31)); // pitch @@ -1412,21 +1188,6 @@ inline Vector MakeEulerAnglesFromQ(Quaternion q) return u; - - - - } - - - - - - - - - - #endif - diff --git a/src/Quaternions.cpp b/src/Quaternions.cpp index 9ce344f..90c7502 100644 --- a/src/Quaternions.cpp +++ b/src/Quaternions.cpp @@ -113,10 +113,10 @@ quaternion To_Quat(Matrix_t m) { // From Jason Shankel, (C) 2000. quaternion Quat; - + double Tr = m[0][0] + m[1][1] + m[2][2] + 1.0, fourD; double q[4]; - + int i,j,k; if (Tr >= 1.0) { @@ -148,7 +148,7 @@ quaternion To_Quat(Matrix_t m) q[k] = (m[k][i] + m[i][k]) / fourD; q[3] = (m[j][k] - m[k][j]) / fourD; } - + Quat.x = q[0]; Quat.y = q[1]; Quat.z = q[2]; @@ -186,7 +186,7 @@ quaternion To_Quat(angle_axis Ang_Ax) { // From the Quaternion Powers article on gamedev.net quaternion Quat; - + Quat.x = Ang_Ax.x * sin(Ang_Ax.angle / 2); Quat.y = Ang_Ax.y * sin(Ang_Ax.angle / 2); Quat.z = Ang_Ax.z * sin(Ang_Ax.angle / 2); @@ -202,7 +202,7 @@ angle_axis Quat_2_AA(quaternion Quat) Ang_Ax.x = Quat.x / scale; Ang_Ax.y = Quat.y / scale; Ang_Ax.z = Quat.z / scale; - + Ang_Ax.angle = 2.0 * acos(Quat.w)/(float)PI*180; return Ang_Ax; } @@ -226,23 +226,23 @@ quaternion To_Quat(int In_Degrees, euler Euler) sr = float(sin(Euler.x/2)); sp = float(sin(Euler.y/2)); sy = float(sin(Euler.z/2)); - + cpcy = cp * cy; spsy = sp * sy; Quat.w = cr * cpcy + sr * spsy; Quat.x = sr * cpcy - cr * spsy; Quat.y = cr * sp * cy + sr * cp * sy; Quat.z = cr * cp * sy - sr * sp * cy; - + return Quat; } - + quaternion QNormalize(quaternion Quat) { float norm; - norm = Quat.x * Quat.x + - Quat.y * Quat.y + - Quat.z * Quat.z + + norm = Quat.x * Quat.x + + Quat.y * Quat.y + + Quat.z * Quat.z + Quat.w * Quat.w; Quat.x = float(Quat.x / norm); Quat.y = float(Quat.y / norm); @@ -259,13 +259,13 @@ XYZ Quat2Vector(quaternion Quat) float fX = Quat.x; float fY = Quat.y; float fZ = Quat.z; - + XYZ tempvec; tempvec.x = 2.0f*(fX*fZ-fW*fY); tempvec.y = 2.0f*(fY*fZ+fW*fX); tempvec.z = 1.0f-2.0f*(fX*fX+fY*fY); - + return tempvec; } @@ -305,37 +305,36 @@ extern float normalv[3]; bool PointInTriangle(Vector *p, Vector normal, float p11, float p12, float p13, float p21, float p22, float p23, float p31, float p32, float p33) { bInter=0; - + pointv[0]=p->x; pointv[1]=p->y; pointv[2]=p->z; - - + p1v[0]=p11; p1v[1]=p12; p1v[2]=p13; - + p2v[0]=p21; p2v[1]=p22; p2v[2]=p23; - + p3v[0]=p31; p3v[1]=p32; p3v[2]=p33; - + normalv[0]=normal.x; normalv[1]=normal.y; normalv[2]=normal.z; - + #define ABS(X) (((X)<0.f)?-(X):(X) ) -#define MAX(A, B) (((A)<(B))?(B):(A)) +#define MAX(A, B) (((A)<(B))?(B):(A)) float max = MAX(MAX(ABS(normalv[0]), ABS(normalv[1])), ABS(normalv[2])); #undef MAX if (max == ABS(normalv[0])) {i = 1; j = 2;} // y, z if (max == ABS(normalv[1])) {i = 0; j = 2;} // x, z if (max == ABS(normalv[2])) {i = 0; j = 1;} // x, y #undef ABS - + u0 = pointv[i] - p1v[i]; v0 = pointv[j] - p1v[j]; u1 = p2v[i] - p1v[i]; @@ -373,63 +372,62 @@ bool LineFacet(Vector p1,Vector p2,Vector pa,Vector pb,Vector pc,Vector *p) float denom, mu; Vector n, pa1, pa2, pa3; - //Calculate the parameters for the plane + //Calculate the parameters for the plane n.x = (pb.y - pa.y)*(pc.z - pa.z) - (pb.z - pa.z)*(pc.y - pa.y); n.y = (pb.z - pa.z)*(pc.x - pa.x) - (pb.x - pa.x)*(pc.z - pa.z); n.z = (pb.x - pa.x)*(pc.y - pa.y) - (pb.y - pa.y)*(pc.x - pa.x); n.Normalize(); d = - n.x * pa.x - n.y * pa.y - n.z * pa.z; - //Calculate the position on the line that intersects the plane + //Calculate the position on the line that intersects the plane denom = n.x * (p2.x - p1.x) + n.y * (p2.y - p1.y) + n.z * (p2.z - p1.z); - if (abs(denom) < 0.0000001) // Line and plane don't intersect + if (abs(denom) < 0.0000001) // Line and plane don't intersect return 0; mu = - (d + n.x * p1.x + n.y * p1.y + n.z * p1.z) / denom; p->x = p1.x + mu * (p2.x - p1.x); p->y = p1.y + mu * (p2.y - p1.y); p->z = p1.z + mu * (p2.z - p1.z); - if (mu < 0 || mu > 1) // Intersection not along line segment + if (mu < 0 || mu > 1) // Intersection not along line segment return 0; - + if(!PointInTriangle( p, n, pa.x, pa.y, pa.z, pb.x, pb.y, pb.z, pc.x, pc.y, pc.z)){return 0;} - + return 1; } bool PointInTriangle(XYZ *p, XYZ normal, XYZ *p1, XYZ *p2, XYZ *p3) { bInter=0; - + pointv[0]=p->x; pointv[1]=p->y; pointv[2]=p->z; - - + p1v[0]=p1->x; p1v[1]=p1->y; p1v[2]=p1->z; - + p2v[0]=p2->x; p2v[1]=p2->y; p2v[2]=p2->z; - + p3v[0]=p3->x; p3v[1]=p3->y; p3v[2]=p3->z; - + normalv[0]=normal.x; normalv[1]=normal.y; normalv[2]=normal.z; - + #define ABS(X) (((X)<0.f)?-(X):(X) ) -#define MAX(A, B) (((A)<(B))?(B):(A)) +#define MAX(A, B) (((A)<(B))?(B):(A)) float max = MAX(MAX(ABS(normalv[0]), ABS(normalv[1])), ABS(normalv[2])); #undef MAX if (max == ABS(normalv[0])) {i = 1; j = 2;} // y, z if (max == ABS(normalv[1])) {i = 0; j = 2;} // x, z if (max == ABS(normalv[2])) {i = 0; j = 1;} // x, y #undef ABS - + u0 = pointv[i] - p1v[i]; v0 = pointv[j] - p1v[j]; u1 = p2v[i] - p1v[i]; @@ -467,26 +465,26 @@ bool LineFacet(XYZ p1,XYZ p2,XYZ pa,XYZ pb,XYZ pc,XYZ *p) float denom, mu; XYZ n; - //Calculate the parameters for the plane + //Calculate the parameters for the plane n.x = (pb.y - pa.y)*(pc.z - pa.z) - (pb.z - pa.z)*(pc.y - pa.y); n.y = (pb.z - pa.z)*(pc.x - pa.x) - (pb.x - pa.x)*(pc.z - pa.z); n.z = (pb.x - pa.x)*(pc.y - pa.y) - (pb.y - pa.y)*(pc.x - pa.x); Normalise(&n); d = - n.x * pa.x - n.y * pa.y - n.z * pa.z; - //Calculate the position on the line that intersects the plane + //Calculate the position on the line that intersects the plane denom = n.x * (p2.x - p1.x) + n.y * (p2.y - p1.y) + n.z * (p2.z - p1.z); - if (abs(denom) < 0.0000001) // Line and plane don't intersect + if (abs(denom) < 0.0000001) // Line and plane don't intersect return 0; mu = - (d + n.x * p1.x + n.y * p1.y + n.z * p1.z) / denom; p->x = p1.x + mu * (p2.x - p1.x); p->y = p1.y + mu * (p2.y - p1.y); p->z = p1.z + mu * (p2.z - p1.z); - if (mu < 0 || mu > 1) // Intersection not along line segment + if (mu < 0 || mu > 1) // Intersection not along line segment return 0; - + if(!PointInTriangle( p, n, &pa, &pb, &pc)){return 0;} - + return 1; } @@ -497,47 +495,46 @@ extern XYZ pa1,pa2,pa3,n; float LineFacetd(XYZ p1,XYZ p2,XYZ pa,XYZ pb,XYZ pc,XYZ *p) { - - //Calculate the parameters for the plane + //Calculate the parameters for the plane n.x = (pb.y - pa.y)*(pc.z - pa.z) - (pb.z - pa.z)*(pc.y - pa.y); n.y = (pb.z - pa.z)*(pc.x - pa.x) - (pb.x - pa.x)*(pc.z - pa.z); n.z = (pb.x - pa.x)*(pc.y - pa.y) - (pb.y - pa.y)*(pc.x - pa.x); Normalise(&n); d = - n.x * pa.x - n.y * pa.y - n.z * pa.z; - //Calculate the position on the line that intersects the plane + //Calculate the position on the line that intersects the plane denom = n.x * (p2.x - p1.x) + n.y * (p2.y - p1.y) + n.z * (p2.z - p1.z); - if (abs(denom) < 0.0000001) // Line and plane don't intersect + if (abs(denom) < 0.0000001) // Line and plane don't intersect return 0; mu = - (d + n.x * p1.x + n.y * p1.y + n.z * p1.z) / denom; p->x = p1.x + mu * (p2.x - p1.x); p->y = p1.y + mu * (p2.y - p1.y); p->z = p1.z + mu * (p2.z - p1.z); - if (mu < 0 || mu > 1) // Intersection not along line segment + if (mu < 0 || mu > 1) // Intersection not along line segment return 0; - + if(!PointInTriangle( p, n, &pa, &pb, &pc)){return 0;} - + return 1; } float LineFacetd(XYZ p1,XYZ p2,XYZ pa,XYZ pb,XYZ pc, XYZ n, XYZ *p) { - //Calculate the parameters for the plane + //Calculate the parameters for the plane d = - n.x * pa.x - n.y * pa.y - n.z * pa.z; - //Calculate the position on the line that intersects the plane + //Calculate the position on the line that intersects the plane denom = n.x * (p2.x - p1.x) + n.y * (p2.y - p1.y) + n.z * (p2.z - p1.z); - if (abs(denom) < 0.0000001) // Line and plane don't intersect + if (abs(denom) < 0.0000001) // Line and plane don't intersect return 0; mu = - (d + n.x * p1.x + n.y * p1.y + n.z * p1.z) / denom; p->x = p1.x + mu * (p2.x - p1.x); p->y = p1.y + mu * (p2.y - p1.y); p->z = p1.z + mu * (p2.z - p1.z); - if (mu < 0 || mu > 1) // Intersection not along line segment + if (mu < 0 || mu > 1) // Intersection not along line segment return 0; - + if(!PointInTriangle( p, n, &pa, &pb, &pc)){return 0;} return 1; } @@ -545,20 +542,20 @@ float LineFacetd(XYZ p1,XYZ p2,XYZ pa,XYZ pb,XYZ pc, XYZ n, XYZ *p) float LineFacetd(XYZ *p1,XYZ *p2,XYZ *pa,XYZ *pb,XYZ *pc, XYZ *n, XYZ *p) { - //Calculate the parameters for the plane + //Calculate the parameters for the plane d = - n->x * pa->x - n->y * pa->y - n->z * pa->z; - //Calculate the position on the line that intersects the plane + //Calculate the position on the line that intersects the plane denom = n->x * (p2->x - p1->x) + n->y * (p2->y - p1->y) + n->z * (p2->z - p1->z); - if (abs(denom) < 0.0000001) // Line and plane don't intersect + if (abs(denom) < 0.0000001) // Line and plane don't intersect return 0; mu = - (d + n->x * p1->x + n->y * p1->y + n->z * p1->z) / denom; p->x = p1->x + mu * (p2->x - p1->x); p->y = p1->y + mu * (p2->y - p1->y); p->z = p1->z + mu * (p2->z - p1->z); - if (mu < 0 || mu > 1) // Intersection not along line segment + if (mu < 0 || mu > 1) // Intersection not along line segment return 0; - + if(!PointInTriangle( p, *n, pa, pb, pc)){return 0;} return 1; } @@ -568,7 +565,7 @@ void ReflectVector(XYZ *vel, XYZ *n) XYZ vn; XYZ vt; float dotprod; - + dotprod=dotproduct(*n,*vel); vn.x=n->x*dotprod; vn.y=n->y*dotprod; @@ -577,7 +574,7 @@ void ReflectVector(XYZ *vel, XYZ *n) vt.x=vel->x-vn.x; vt.y=vel->y-vn.y; vt.z=vel->z-vn.z; - + vel->x = vt.x - vn.x; vel->y = vt.y - vn.y; vel->z = vt.z - vn.z; @@ -597,7 +594,6 @@ float findLength(XYZ point1){ return sqrt((point1.x)*(point1.x)+(point1.y)*(point1.y)+(point1.z)*(point1.z)); } - float findLengthfast(XYZ point1){ return((point1.x)*(point1.x)+(point1.y)*(point1.y)+(point1.z)*(point1.z)); } @@ -620,29 +616,28 @@ XYZ DoRotation(XYZ thePoint, float xang, float yang, float zang){ zang*=6.283185; zang/=360; } - - + if(yang){ newpoint.z=thePoint.z*cos(yang)-thePoint.x*sin(yang); newpoint.x=thePoint.z*sin(yang)+thePoint.x*cos(yang); thePoint.z=newpoint.z; thePoint.x=newpoint.x; } - + if(zang){ newpoint.x=thePoint.x*cos(zang)-thePoint.y*sin(zang); newpoint.y=thePoint.y*cos(zang)+thePoint.x*sin(zang); thePoint.x=newpoint.x; thePoint.y=newpoint.y; } - + if(xang){ newpoint.y=thePoint.y*cos(xang)-thePoint.z*sin(xang); newpoint.z=thePoint.y*sin(xang)+thePoint.z*cos(xang); thePoint.z=newpoint.z; - thePoint.y=newpoint.y; + thePoint.y=newpoint.y; } - + return thePoint; } @@ -692,31 +687,30 @@ bool sphere_line_intersection ( XYZ DoRotationRadian(XYZ thePoint, float xang, float yang, float zang){ XYZ newpoint; XYZ oldpoint; - + oldpoint=thePoint; - + if(yang!=0){ newpoint.z=oldpoint.z*cos(yang)-oldpoint.x*sin(yang); newpoint.x=oldpoint.z*sin(yang)+oldpoint.x*cos(yang); oldpoint.z=newpoint.z; oldpoint.x=newpoint.x; } - + if(zang!=0){ newpoint.x=oldpoint.x*cos(zang)-oldpoint.y*sin(zang); newpoint.y=oldpoint.y*cos(zang)+oldpoint.x*sin(zang); oldpoint.x=newpoint.x; oldpoint.y=newpoint.y; } - + if(xang!=0){ newpoint.y=oldpoint.y*cos(xang)-oldpoint.z*sin(xang); newpoint.z=oldpoint.y*sin(xang)+oldpoint.z*cos(xang); oldpoint.z=newpoint.z; - oldpoint.y=newpoint.y; + oldpoint.y=newpoint.y; } - + return oldpoint; - -} +} diff --git a/src/Quaternions.h b/src/Quaternions.h index 1678b79..2b46db9 100644 --- a/src/Quaternions.h +++ b/src/Quaternions.h @@ -2,11 +2,11 @@ #ifndef _QUATERNIONS_H_ #define _QUATERNIONS_H_ -#ifdef OS9 +#ifdef OS9 #pragma mark - #endif -#ifdef OS9 +#ifdef OS9 #include <gl.h> #else #include <GL/gl.h> @@ -89,4 +89,3 @@ bool sphere_line_intersection ( float x3, float y3 , float z3, float r ); #endif - diff --git a/src/SConstruct b/src/SConstruct index 70fa779..f764f34 100644 --- a/src/SConstruct +++ b/src/SConstruct @@ -1,6 +1,6 @@ Program( 'blackshades', - Split('Camera.cpp Decals.cpp Fog.cpp Frustum.cpp GameDraw.cpp GameInitDispose.cpp GameLoop.cpp GameTick.cpp ' + + Split('Camera.cpp Decals.cpp Fog.cpp Frustum.cpp GameDraw.cpp GameInitDispose.cpp GameLoop.cpp GameTick.cpp ' + 'Globals.cpp MacInput.cpp Main.cpp Maths.cpp Models.cpp Person.cpp Quaternions.cpp Serialize.cpp Skeleton.cpp ' + 'Sprites.cpp Support.cpp Text.cpp Timer.cpp Textures.cpp'), CPPDEFS=['GNUSOURCE=1'], diff --git a/src/Serialize.cpp b/src/Serialize.cpp index 589dcb9..443e935 100644 --- a/src/Serialize.cpp +++ b/src/Serialize.cpp @@ -10,16 +10,16 @@ int ReadBool(int fd, int count, bool *b) { while (count--) { unsigned char buf[1]; - + if (read(fd, buf, 1) != 1) { STUB_FUNCTION; } - + *b = (buf[0] != 0) ? true : false; - + b++; } - + return 1; } @@ -27,16 +27,16 @@ int ReadShort(int fd, int count, short *s) { while (count--) { unsigned char buf[2]; - + if (read(fd, buf, 2) != 2) { STUB_FUNCTION; } - + *s = (short)((buf[0] << 8) | buf[1]); - + s++; } - + return 1; } @@ -44,16 +44,16 @@ int ReadInt(int fd, int count, int *s) { while (count--) { unsigned char buf[4]; - + if (read(fd, buf, 4) != 4) { STUB_FUNCTION; } - + *s = (int)((buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]); - + s++; } - + return 1; } @@ -65,15 +65,15 @@ union intfloat { int ReadFloat(int fd, int count, float *f) { union intfloat infl; - + while (count--) { ReadInt(fd, 1, &(infl.i)); - + *f = infl.f; - + f++; } - + return 1; } @@ -83,10 +83,10 @@ int ReadXYZ(int fd, int count, XYZ *xyz) ReadFloat(fd, 1, &(xyz->x)); ReadFloat(fd, 1, &(xyz->y)); ReadFloat(fd, 1, &(xyz->z)); - + xyz++; } - + return 1; } @@ -99,9 +99,9 @@ int ReadTexturedTriangle(int fd, int count, TexturedTriangle *tt) ReadFloat(fd, 1, &(tt->r)); ReadFloat(fd, 1, &(tt->g)); ReadFloat(fd, 1, &(tt->b)); - + tt++; } - + return count; } diff --git a/src/Skeleton.cpp b/src/Skeleton.cpp index e039bc4..a5516c6 100644 --- a/src/Skeleton.cpp +++ b/src/Skeleton.cpp @@ -29,10 +29,8 @@ extern int whichtri; extern XYZ normalrotated; extern bool groundish; - void Joint::DoConstraint() { - if(hasparent){ //Find midpoint midp=(position+parent->position)/2; @@ -53,22 +51,22 @@ void Muscle::DoConstraint(int broken) { oldlength=length; relaxlength=findDistance(parent1->position,parent2->position); - + if(type==boneconnect)strength=1; if(type==constraint)strength=0; - + if(strength<0)strength=0; if(strength>1)strength=1; - + length-=(length-relaxlength)*(1-strength)*multiplier*multiplier*10000; length-=(length-targetlength)*(strength)*multiplier*multiplier*10000; if(strength==0)length=relaxlength; - + if((relaxlength-length>0&&relaxlength-oldlength<0)||(relaxlength-length<0&&relaxlength-oldlength>0))length=relaxlength; - + if(length<minlength)length=minlength; if(length>maxlength&&!broken)length=maxlength; - + //Find midpoint midp=(parent1->position+parent2->position)/2; //Find vector from midpoint to second vector @@ -88,7 +86,7 @@ void Muscle::DoConstraint(int broken) void Skeleton::DoConstraints() { numrepeats=3; - + for(int j=0; j<numrepeats; j++){ for(int i=0; i<num_joints; i++){ joints[i].DoConstraint(); @@ -101,9 +99,9 @@ void Skeleton::DoConstraints(Model *collide, XYZ *move, float rotation) friction=20; numrepeats=2; groundlevel=0; - + move->y+=.35; - + for(int j=0; j<numrepeats; j++){ for(int i=0; i<num_joints; i++){ if(joints[i].existing||i==jointlabels[lefthand]||i==jointlabels[righthand]){ @@ -149,7 +147,7 @@ void Skeleton::DoConstraints(Model *collide, XYZ *move, float rotation) gLoc[0]=joints[i].position.x/soundscalefactor; gLoc[1]=joints[i].position.y/soundscalefactor; gLoc[2]=joints[i].position.z/soundscalefactor; -#ifdef DEBIAN_NEEDS_TO_UPDATE_THEIR_OPENAL +#ifdef DEBIAN_NEEDS_TO_UPDATE_THEIR_OPENAL alGetSourceiv(gSourceID[headlandsound], AL_SOURCE_STATE, &tempint); #else alGetSourcei(gSourceID[headlandsound], AL_SOURCE_STATE, &tempint); @@ -174,7 +172,7 @@ void Skeleton::DoConstraints(Model *collide, XYZ *move, float rotation) alGetSourceiv(gSourceID[bodylandsound], AL_SOURCE_STATE, &tempint); #else alGetSourcei(gSourceID[bodylandsound], AL_SOURCE_STATE, &tempint); -#endif +#endif if (tempint != AL_PLAYING){ alSourcef(gSourceID[bodylandsound], AL_MIN_GAIN, ALfloat(findLengthfast(joints[i].velocity)*1/findDistancefast(joints[i].position,camera.position)*soundscalefactor*2)); alSourcef(gSourceID[bodylandsound], AL_MAX_GAIN, ALfloat(findLengthfast(joints[i].velocity)*1/findDistancefast(joints[i].position,camera.position)*soundscalefactor*2)); @@ -190,11 +188,11 @@ void Skeleton::DoConstraints(Model *collide, XYZ *move, float rotation) muscles[i].DoConstraint(broken); } } - + for(int i=0; i<num_joints; i++){ joints[i].realoldposition=joints[i].position; } - + //Add velocity for(int i=0; i<num_joints; i++){ if(joints[i].existing||i==jointlabels[lefthand]||i==jointlabels[righthand])joints[i].position=joints[i].position+joints[i].velocity*multiplier; @@ -218,7 +216,7 @@ void Skeleton::Draw(int muscleview) jointcolor[2]=.5; jointcolor[3]=1; } - + if(muscleview==2){ jointcolor[0]=0; jointcolor[1]=0; @@ -287,9 +285,9 @@ void Skeleton::Draw(int muscleview) glVertex3f(muscles[i].parent1->position.x,muscles[i].parent1->position.y,muscles[i].parent1->position.z); glVertex3f(muscles[i].parent2->position.x,muscles[i].parent2->position.y,muscles[i].parent2->position.z); } - } + } glEnd(); - + if(muscleview!=2){ glPointSize(3); glBegin(GL_POINTS); @@ -301,7 +299,7 @@ void Skeleton::Draw(int muscleview) } glEnd(); } - + //Set old position to current position if(muscleview==2) for(int i=0; i<num_joints; i++){ @@ -318,13 +316,13 @@ void Skeleton::AddJoint(float x, float y, float z, int which) joints[num_joints].position.y=y; joints[num_joints].position.z=z; joints[num_joints].locked=0; - + if(which>=num_joints||which<0)joints[num_joints].hasparent=0; if(which<num_joints&&which>=0){ joints[num_joints].parent=&joints[which]; joints[num_joints].hasparent=1; joints[num_joints].length=findDistance(joints[num_joints].position,joints[num_joints].parent->position); - } + } num_joints++; } } @@ -355,7 +353,7 @@ void Skeleton::DeleteMuscle(int whichmuscle) muscles[whichmuscle].visible=muscles[num_muscles-1].visible; muscles[whichmuscle].type=muscles[num_muscles-1].type; muscles[whichmuscle].targetlength=muscles[num_muscles-1].targetlength; - + num_muscles--; } } @@ -367,13 +365,13 @@ void Skeleton::SetJoint(float x, float y, float z, int which, int whichjoint) joints[whichjoint].position.x=x; joints[whichjoint].position.y=y; joints[whichjoint].position.z=z; - + if(which>=num_joints||which<0)joints[whichjoint].hasparent=0; if(which<num_joints&&which>=0){ joints[whichjoint].parent=&joints[which]; joints[whichjoint].hasparent=1; joints[whichjoint].length=findDistance(joints[whichjoint].position,joints[whichjoint].parent->position); - } + } } } @@ -388,7 +386,7 @@ void Skeleton::AddMuscle(int attach1,int attach2,float minlength,float maxlength muscles[num_muscles].type=type; muscles[num_muscles].minlength=minlength; muscles[num_muscles].maxlength=maxlength; - + num_muscles++; } } @@ -404,7 +402,7 @@ void Skeleton::FindRotationJoint(int which) { XYZ temppoint1,temppoint2,tempforward; float distance; - + temppoint1=joints[which].position; temppoint2=joints[which].parent->position; distance=findDistance(temppoint1,temppoint2); @@ -432,7 +430,7 @@ void Skeleton::FindRotationMuscle(int which) { XYZ temppoint1,temppoint2,tempforward; float distance; - + temppoint1=muscles[which].parent1->position; temppoint2=muscles[which].parent2->position; distance=findDistance(temppoint1,temppoint2); @@ -490,23 +488,23 @@ void Animation::Load(char *fileName) } } } - + files.EndLoad(); - + for(int j=0;j<numframes;j++){ for(int i=0;i<testskeleton.num_joints;i++){ - testskeleton.joints[i].position=position[i][j]; + testskeleton.joints[i].position=position[i][j]; } //Find forward vectors CrossProduct(testskeleton.joints[testskeleton.forwardjoints[1]].position-testskeleton.joints[testskeleton.forwardjoints[0]].position,testskeleton.joints[testskeleton.forwardjoints[2]].position-testskeleton.joints[testskeleton.forwardjoints[0]].position,&testskeleton.forward); Normalise(&testskeleton.forward); - + CrossProduct(testskeleton.joints[testskeleton.lowforwardjoints[1]].position-testskeleton.joints[testskeleton.lowforwardjoints[0]].position,testskeleton.joints[testskeleton.lowforwardjoints[2]].position-testskeleton.joints[testskeleton.lowforwardjoints[0]].position,&testskeleton.lowforward); Normalise(&testskeleton.lowforward); - + //Special forwards testskeleton.specialforward[0]=testskeleton.forward; - + testskeleton.specialforward[1]=testskeleton.joints[testskeleton.jointlabels[rightshoulder]].position+testskeleton.joints[testskeleton.jointlabels[rightwrist]].position; testskeleton.specialforward[1]=testskeleton.joints[testskeleton.jointlabels[rightelbow]].position-testskeleton.specialforward[1]/2; testskeleton.specialforward[1]+=testskeleton.forward*.2; @@ -515,7 +513,7 @@ void Animation::Load(char *fileName) testskeleton.specialforward[2]=testskeleton.joints[testskeleton.jointlabels[leftelbow]].position-testskeleton.specialforward[2]/2; testskeleton.specialforward[2]+=testskeleton.forward*.2; Normalise(&testskeleton.specialforward[2]); - + testskeleton.specialforward[3]=testskeleton.joints[testskeleton.jointlabels[righthip]].position+testskeleton.joints[testskeleton.jointlabels[rightankle]].position; testskeleton.specialforward[3]=testskeleton.specialforward[3]/2-testskeleton.joints[testskeleton.jointlabels[rightknee]].position; testskeleton.specialforward[3]+=testskeleton.lowforward*.2; @@ -567,7 +565,7 @@ void Animation::Load(char *fileName) } } } - + for(int k=0;k<2;k++) for(int j=0;j<numframes;j++){ for(int i=0;i<testskeleton.num_muscles;i++){ @@ -579,7 +577,7 @@ void Animation::Load(char *fileName) if(j!=0&&mrotate2[i][j]<mrotate2[i][j-1]-180)mrotate2[i][j]+=360; if(j!=0&&mrotate1[i][j]>mrotate1[i][j-1]+180)mrotate1[i][j]-=360; if(j!=0&&mrotate1[i][j]<mrotate1[i][j-1]-180)mrotate1[i][j]+=360; - + if(j==0&&mrotate3[i][j]>mrotate3[i][numframes-1]+180)mrotate3[i][j]-=360; if(j==0&&mrotate3[i][j]<mrotate3[i][numframes-1]-180)mrotate3[i][j]+=360; if(j==0&&mrotate2[i][j]>mrotate2[i][numframes-1]+180)mrotate2[i][j]-=360; @@ -597,7 +595,7 @@ void Animation::Load(char *fileName) if(j!=0&&rotate2[i][j]<rotate2[i][j-1]-180)rotate2[i][j]+=360; if(j!=0&&rotate1[i][j]>rotate1[i][j-1]+180)rotate1[i][j]-=360; if(j!=0&&rotate1[i][j]<rotate1[i][j-1]-180)rotate1[i][j]+=360; - + if(j==0&&rotate3[i][j]>rotate3[i][numframes-1]+180)rotate3[i][j]-=360; if(j==0&&rotate3[i][j]<rotate3[i][numframes-1]-180)rotate3[i][j]+=360; if(j==0&&rotate2[i][j]>rotate2[i][numframes-1]+180)rotate2[i][j]-=360; @@ -635,21 +633,21 @@ void Animation::Load(char *fileName, float rotate) } } files.EndLoad(); - + for(int j=0;j<numframes;j++){ for(int i=0;i<testskeleton.num_joints;i++){ - testskeleton.joints[i].position=position[i][j]; + testskeleton.joints[i].position=position[i][j]; } //Find forward vectors CrossProduct(testskeleton.joints[testskeleton.forwardjoints[1]].position-testskeleton.joints[testskeleton.forwardjoints[0]].position,testskeleton.joints[testskeleton.forwardjoints[2]].position-testskeleton.joints[testskeleton.forwardjoints[0]].position,&testskeleton.forward); Normalise(&testskeleton.forward); - + CrossProduct(testskeleton.joints[testskeleton.lowforwardjoints[1]].position-testskeleton.joints[testskeleton.lowforwardjoints[0]].position,testskeleton.joints[testskeleton.lowforwardjoints[2]].position-testskeleton.joints[testskeleton.lowforwardjoints[0]].position,&testskeleton.lowforward); Normalise(&testskeleton.lowforward); - + //Special forwards testskeleton.specialforward[0]=testskeleton.forward; - + testskeleton.specialforward[1]=testskeleton.joints[testskeleton.jointlabels[rightshoulder]].position+testskeleton.joints[testskeleton.jointlabels[rightwrist]].position; testskeleton.specialforward[1]=testskeleton.joints[testskeleton.jointlabels[rightelbow]].position-testskeleton.specialforward[1]/2; testskeleton.specialforward[1]+=testskeleton.forward*.2; @@ -658,7 +656,7 @@ void Animation::Load(char *fileName, float rotate) testskeleton.specialforward[2]=testskeleton.joints[testskeleton.jointlabels[leftelbow]].position-testskeleton.specialforward[2]/2; testskeleton.specialforward[2]+=testskeleton.forward*.2; Normalise(&testskeleton.specialforward[2]); - + testskeleton.specialforward[3]=testskeleton.joints[testskeleton.jointlabels[righthip]].position+testskeleton.joints[testskeleton.jointlabels[rightankle]].position; testskeleton.specialforward[3]=testskeleton.specialforward[3]/2-testskeleton.joints[testskeleton.jointlabels[rightknee]].position; testskeleton.specialforward[3]+=testskeleton.lowforward*.2; @@ -710,7 +708,7 @@ void Animation::Load(char *fileName, float rotate) } } } - + for(int k=0;k<2;k++) for(int j=0;j<numframes;j++){ for(int i=0;i<testskeleton.num_muscles;i++){ @@ -722,7 +720,7 @@ void Animation::Load(char *fileName, float rotate) if(j!=0&&mrotate2[i][j]<mrotate2[i][j-1]-180)mrotate2[i][j]+=360; if(j!=0&&mrotate1[i][j]>mrotate1[i][j-1]+180)mrotate1[i][j]-=360; if(j!=0&&mrotate1[i][j]<mrotate1[i][j-1]-180)mrotate1[i][j]+=360; - + if(j==0&&mrotate3[i][j]>mrotate3[i][numframes-1]+180)mrotate3[i][j]-=360; if(j==0&&mrotate3[i][j]<mrotate3[i][numframes-1]-180)mrotate3[i][j]+=360; if(j==0&&mrotate2[i][j]>mrotate2[i][numframes-1]+180)mrotate2[i][j]-=360; @@ -740,7 +738,7 @@ void Animation::Load(char *fileName, float rotate) if(j!=0&&rotate2[i][j]<rotate2[i][j-1]-180)rotate2[i][j]+=360; if(j!=0&&rotate1[i][j]>rotate1[i][j-1]+180)rotate1[i][j]-=360; if(j!=0&&rotate1[i][j]<rotate1[i][j-1]-180)rotate1[i][j]+=360; - + if(j==0&&rotate3[i][j]>rotate3[i][numframes-1]+180)rotate3[i][j]-=360; if(j==0&&rotate3[i][j]<rotate3[i][numframes-1]-180)rotate3[i][j]+=360; if(j==0&&rotate2[i][j]>rotate2[i][numframes-1]+180)rotate2[i][j]-=360; @@ -801,13 +799,12 @@ void Skeleton::Load(char *fileName) } } files.EndLoad(); - + for(int i=0;i<num_joints;i++){ for(int j=0;j<num_joints;j++){ if(joints[i].label==j)jointlabels[j]=i; } } - - broken=0; -} + broken=0; +} diff --git a/src/Skeleton.h b/src/Skeleton.h index 9730665..7b5be13 100644 --- a/src/Skeleton.h +++ b/src/Skeleton.h @@ -2,7 +2,7 @@ #define _SKELETON_H_ /**> HEADER FILES <**/ -#ifdef OS9 +#ifdef OS9 #include <gl.h> #include "alut.h" #else @@ -24,7 +24,7 @@ //right shoulder, right elbow, right wrist, right hand, //middle, left hip, right hip,groin //left knee,left ankle, left foot, right knee, right ankle, right foort - + #define head 1 #define neck 2 #define leftshoulder 3 @@ -67,7 +67,7 @@ class Joint int label; int hasgun; float rotate1,rotate2,rotate3; - + void DoConstraint(); }; @@ -84,7 +84,7 @@ class Muscle bool visible; void DoConstraint(int broken); float rotate1,rotate2,rotate3; - + float strength; }; @@ -108,34 +108,33 @@ class Animation void Load(char *fileName,float rotate); }; - class Skeleton { public: int num_joints; Joint joints[max_joints]; int jointlabels[max_joints]; - + int num_muscles; Muscle muscles[max_muscles]; - + int selected; - + int forwardjoints[3]; XYZ forward; - + int lowforwardjoints[3]; XYZ lowforward; - + int broken; bool offset; - + XYZ specialforward[5]; - + bool free; - + Files files; - + void DoConstraints(); void DoConstraints(Model *collide, XYZ *move, float rotation); void DoGravity(); @@ -153,4 +152,3 @@ class Skeleton }; #endif - diff --git a/src/Sprites.cpp b/src/Sprites.cpp index 9bf307d..ef60a7d 100644 --- a/src/Sprites.cpp +++ b/src/Sprites.cpp @@ -35,7 +35,7 @@ int Sprites::MakeSprite(int atype, float abrightness, float acolor1, float acolo alivetime[howmanysprites]=0; owner[howmanysprites]=0; if(howmanysprites<maxsprites){howmanysprites++;} - + return 0; } @@ -56,7 +56,7 @@ int Sprites::MakeSprite(int atype, float abrightness, float acolor1, float acolo alivetime[howmanysprites]=0; owner[howmanysprites]=aowner; if(howmanysprites<maxsprites){howmanysprites++;} - + return 0; } @@ -76,10 +76,10 @@ int Sprites::DeleteSprite(int which){ rotation[which]=rotation[howmanysprites-1]; type[which]=type[howmanysprites-1]; type[howmanysprites-1]=0; - + if(howmanysprites>0){howmanysprites--;} } - + return 0; } @@ -118,7 +118,6 @@ void Sprites::LoadBulletTexture(char *fileName) bullettextureptr = loadTexture(fileName); } - void Sprites::DoStuff() { for(int i=0;i<howmanysprites;i++){ @@ -146,14 +145,14 @@ void Sprites::DoStuff() if(type[i]==bloodspritedown||type[i]==particlesspritedown){ velocity[i].y+=gravity*multiplier; } - + if(type[i]!=bulletinstant&&type[i]!=bullet)location[i]=location[i]+velocity[i]*multiplier; - + alivetime[i]+=multiplier; if(brightness[i]<=0)DeleteSprite(i); if(type[i]==snowsprite&&(location[i].y<-.1||environment!=snowy_environment))DeleteSprite(i); if(type[i]==rainsprite&&(location[i].y<-.1||environment!=rainy_environment))DeleteSprite(i); - + if(type[i]==snowsprite){ if(location[i].x<camera.position.x-precipitationhorz){location[i].x+=precipitationhorz*2;} if(location[i].z<camera.position.z-precipitationhorz){location[i].z+=precipitationhorz*2;} @@ -181,9 +180,9 @@ void Sprites::draw() float bulletsize; XYZ point; glAlphaFunc(GL_GREATER, 0.01); - + //glEnable(GL_POLYGON_OFFSET_FILL); - + glEnable(GL_BLEND); glDisable(GL_CULL_FACE); glEnable(GL_TEXTURE_2D); @@ -199,7 +198,7 @@ void Sprites::draw() if(type[i]==snowsprite){fog.ResetFog(); glBindTexture(GL_TEXTURE_2D, snowtextureptr);glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);} if(type[i]==rainsprite){fog.ResetFog(); glBindTexture(GL_TEXTURE_2D, raintextureptr);glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);} if(type[i]==bullet||type[i]==bulletinstant){fog.ResetFog(); glBindTexture(GL_TEXTURE_2D, bullettextureptr);glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);} - + glPushMatrix(); if(type[i]==muzzleflashsprite||type[i]==flashsprite||type[i]==smokesprite||type[i]==smokespritenoup||type[i]==snowsprite||type[i]==particlesspritedown||((type[i]==bloodspritenoup||type[i]==bloodspritedown)&&blood)){ glColor4f(color1[i]*fogcolorr*1.6,color2[i]*fogcolorg*1.6,color3[i]*fogcolorb*1.6,brightness[i]); @@ -214,7 +213,7 @@ void Sprites::draw() glLoadIdentity(); glTranslatef(point.x, point.y, point.z); glRotatef(rotation[i],0,0,1); - + glBegin(GL_TRIANGLES); glTexCoord2f(1.0f, 1.0f); glVertex3f( .3f*size[i], .3f*size[i], 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-.3f*size[i], .3f*size[i], 0.0f); @@ -223,23 +222,21 @@ void Sprites::draw() glTexCoord2f(1.0f, 0.0f); glVertex3f( .3f*size[i], -.3f*size[i], 0.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(-.3f*size[i], .3f*size[i], 0.0f); glEnd(); - + } - + if(type[i]==rainsprite){ glColor4f(color1[i]*fogcolorr*1.6,color2[i]*fogcolorg*1.6,color3[i]*fogcolorb*1.6,brightness[i]); glTranslatef(location[i].x,location[i].y,location[i].z); glGetFloatv(GL_MODELVIEW_MATRIX,M); - for( int k=0; k<3; k+=2 ) + for( int k=0; k<3; k+=2 ) for( int j=0; j<3; j++ ) { if ( k==j ) M[k*4+j] = 1.0; else M[k*4+j] = 0.0; } - - - + glLoadMatrixf(M); glScalef(.2,abs(velocity[i].y)*multiplier,.2); glBegin(GL_TRIANGLES); @@ -251,7 +248,7 @@ void Sprites::draw() glTexCoord2f(0.0f, 1.0f); glVertex3f(-.3f*size[i], .3f*size[i], 0.0f); glEnd(); } - + if(type[i]==grenadesprite||type[i]==spoonsprite||type[i]==pinsprite){ glTranslatef(location[i].x,location[i].y+.2,location[i].z); glDisable(GL_BLEND); @@ -262,11 +259,11 @@ void Sprites::draw() glEnable(GL_COLOR_MATERIAL); glDepthMask(1); glRotatef(rotation[i],1,.6,.3); - + if(type[i]==grenadesprite)gunmodels[grenadebasemodel].draw(); if(type[i]==spoonsprite)gunmodels[grenadespoonmodel].draw(); if(type[i]==pinsprite)gunmodels[grenadepinmodel].draw(); - + glEnable(GL_BLEND); glDisable(GL_FOG); glDisable(GL_CULL_FACE); @@ -275,7 +272,7 @@ void Sprites::draw() glDisable(GL_COLOR_MATERIAL); glDepthMask(0); } - + if(type[i]==bullet||type[i]==bulletinstant){ bulletsize=size[i]; glPushMatrix(); @@ -296,15 +293,15 @@ void Sprites::draw() endProj.z=M[14]; glPopMatrix(); avgProj=(endProj+begProj)/2; - + dx = endProj.x - begProj.x; dy = endProj.y - begProj.y; oolen= 1/sqrt(dx*dx+dy*dy)*0.5; persp=0; persp.x=-dy*oolen; persp.y=dx*oolen; - + glColor4f(color1[i]*fogcolorr*1.6,color2[i]*fogcolorg*1.6,color3[i]*fogcolorb*1.6,brightness[i]); - + glPushMatrix(); glLoadIdentity(); glBegin(GL_TRIANGLES); @@ -316,15 +313,14 @@ void Sprites::draw() glTexCoord2f(1.0f, 1.0f); glVertex3f(endProj.x+persp.x*bulletsize/2, endProj.y+persp.y*bulletsize/2, endProj.z); glEnd(); glPopMatrix(); - glPopMatrix(); + glPopMatrix(); } glPopMatrix(); } - fog.ResetFog(); + fog.ResetFog(); glDepthMask(1); glDisable(GL_TEXTURE_2D); glEnable(GL_CULL_FACE); //glDisable(GL_POLYGON_OFFSET_FILL); - -} +} diff --git a/src/Sprites.h b/src/Sprites.h index b1f6b2e..42edc67 100644 --- a/src/Sprites.h +++ b/src/Sprites.h @@ -2,7 +2,7 @@ #define _SPRITE_H_ #include "Quaternions.h" -#ifdef OS9 +#ifdef OS9 #include <gl.h> #include <glu.h> #else @@ -45,9 +45,9 @@ class Sprites{ GLuint bloodtextureptr; GLuint raintextureptr; GLuint snowtextureptr; - + int howmanysprites; - + XYZ location[maxsprites]; XYZ oldlocation[maxsprites]; XYZ velocity[maxsprites]; @@ -63,13 +63,13 @@ class Sprites{ float rotation[maxsprites]; int type[maxsprites]; int owner[maxsprites]; - + void draw(); - + int DeleteSprite(int which); int MakeSprite(int atype, float abrightness, float acolor1, float acolor2, float acolor3, XYZ alocation, XYZ avelocity, float asize); int MakeSprite(int atype, float abrightness, float acolor1, float acolor2, float acolor3, XYZ alocation, XYZ avelocity, float asize, int aowner); - + void DoStuff(); void LoadMuzzleFlareTexture(char *fileName); void LoadFlareTexture(char *fileName); @@ -78,7 +78,7 @@ class Sprites{ void LoadBloodTexture(char *fileName); void LoadSnowTexture(char *fileName); void LoadRainTexture(char *fileName); - + ~Sprites() { glDeleteTextures( 1, (const GLuint *)muzzleflaretextureptr ); glDeleteTextures( 1, (const GLuint *)flaretextureptr ); @@ -91,4 +91,3 @@ class Sprites{ }; #endif - diff --git a/src/Support.cpp b/src/Support.cpp index 7c77fc5..083de12 100644 --- a/src/Support.cpp +++ b/src/Support.cpp @@ -32,9 +32,9 @@ void GetMouse(Point *p) { int x; int y; - + SDL_GetMouseState(&x, &y); - + p->h = x; p->v = y; } @@ -43,9 +43,9 @@ void GetMouseRel(Point *p) { int x; int y; - + SDL_GetRelativeMouseState(&x, &y); - + p->h = x; p->v = y; } @@ -89,13 +89,13 @@ static int find_filename(char *filename) char *next; DIR *dir; struct dirent *dirent; - + if (access(filename, R_OK) == 0) { return 1; } - + ptr = filename; - + while (*ptr) { if (ptr == filename || *ptr == '/') { if (*ptr == '/') { @@ -103,53 +103,53 @@ static int find_filename(char *filename) } else { cur = ptr; } - + if (*cur == 0) { /* hit the end */ break; } - + next = strchr(cur, '/'); - + if (ptr != filename) { *ptr = 0; } - + if (next) { *next = 0; } - + if (ptr == filename && *ptr == '/') { dir = opendir("/"); } else { dir = opendir(filename); } - + if (dir == NULL) { if (ptr != filename) { *ptr = '/'; } - + if (next) { *next = 0; } - + return 0; } - + while ((dirent = readdir(dir)) != NULL) { if (strcasecmp(cur, dirent->d_name) == 0) { strcpy(cur, dirent->d_name); break; } } - + closedir(dir); - + if (ptr != filename) { *ptr = '/'; } - + if (next) { *next = '/'; ptr = next; @@ -160,11 +160,11 @@ static int find_filename(char *filename) ptr++; } } - + if (access(filename, R_OK) == 0) { return 1; } - + return 0; } @@ -180,28 +180,28 @@ static void fix_filename(const char *original, char *fixed) } fixed[MAX_PATH-1] = 0; - + strncpy(fixed, start, MAX_PATH); - + /* check to see if strncpy overwrote the terminator */ if (fixed[MAX_PATH-1] != 0) { fixed[MAX_PATH-1] = 0; - - fprintf(stderr, "ERROR: file truncation error: %s -> %s\n", + + fprintf(stderr, "ERROR: file truncation error: %s -> %s\n", original, fixed); } - + len = strlen(fixed); for (i = 0; i < len; i++) { if (fixed[i] == ':') { fixed[i] = '/'; } } - - /* + + /* here we would try to see if the file is available (game dir), else try another dir - + really, this function also needs a flag to indicate whether it should only go to local (write) or both (read) */ @@ -218,18 +218,18 @@ Convenient Filename Hacks FILE *cfh_fopen(const char *filename, const char *mode) { char filename1[MAX_PATH]; - + fix_filename(filename, filename1); - - return fopen(filename1, mode); + + return fopen(filename1, mode); } int Files::OpenFile(Str255 Name) { char filename1[MAX_PATH]; - + fix_filename((char *)Name, filename1); - + sFile = open(filename1, O_RDONLY | O_BINARY); return sFile; } @@ -239,11 +239,11 @@ void Files::EndLoad() if (sFile != -1) { FSClose( sFile ); } - + sFile = -1; } -#ifdef NOOGG +#ifdef NOOGG /* Our own special magic version that fixes the filename. */ @@ -252,11 +252,11 @@ void alutLoadWAVFile_CFH(char *filename, ALenum *format, void **wave, { char filename1[MAX_PATH]; ALsizei format1, size1, bits1, freq1; - + fix_filename(filename, filename1); - + alutLoadWAV(filename1, wave, &format1, &size1, &bits1, &freq1); - + *format = format1; *size = size1; *freq = freq1; @@ -304,9 +304,9 @@ void LoadOGG_CFH(char *filename, ALenum *format, void **wave, fprintf(stderr, "ERROR: unable to open %s\n", filename1); exit(EXIT_FAILURE); } - + /* open it up */ - err = ov_open(fp, &vf, NULL, 0); + err = ov_open(fp, &vf, NULL, 0); if (err < 0) { fprintf(stderr, "ERROR: vorbis error %d opening %s\n", -err, filename1); exit(EXIT_FAILURE); @@ -318,16 +318,16 @@ void LoadOGG_CFH(char *filename, ALenum *format, void **wave, fprintf(stderr, "ERROR: vorbis error opening %s (ov_info failed)\n", filename1); exit(EXIT_FAILURE); } - + /* calculate the byte size */ size1 = vi->channels * 2 * ov_pcm_total(&vf, -1); /* hack around some possible ogg vorbis weirdness */ asize = ((size1 + 2047) / 2048 + 1) * 2048; - - /* allocate our buffer */ + + /* allocate our buffer */ wave1 = malloc(asize); - + if (wave1 == NULL) { fprintf(stderr, "ERROR: could not allocate %d bytes while loading %s\n", size1, filename1); exit(EXIT_FAILURE); @@ -336,17 +336,17 @@ void LoadOGG_CFH(char *filename, ALenum *format, void **wave, /* read it in */ eof = 0; buf = (char *)wave1; - + while(!eof) { - long ret = ov_read(&vf, buf, 1024, endian, 2, 1, + long ret = ov_read(&vf, buf, 1024, endian, 2, 1, ¤t_section); - + if (ret == 0) { /* end of file */ eof = 1; } else if (ret < 0) { /* some sort of error */ - + /* TODO: is this ok to ignore? */ } else { buf += ret; @@ -362,13 +362,13 @@ void LoadOGG_CFH(char *filename, ALenum *format, void **wave, fprintf(stderr, "ERROR: ogg %s has %d channels\n", filename1, vi->channels); exit(EXIT_FAILURE); } - + freq1 = vi->rate; /* we are done with the ogg, so free it */ ov_clear(&vf); - - /* finall, give the values to the caller */ + + /* finall, give the values to the caller */ *format = format1; *size = size1; *freq = freq1; diff --git a/src/Support.h b/src/Support.h index 49b83fc..99e264e 100644 --- a/src/Support.h +++ b/src/Support.h @@ -41,20 +41,19 @@ void GetMouseRel(Point *p); void GetKeys(unsigned long *keys); int Button(void); #ifdef NOOGG -void alutLoadWAVFile_CFH(char *filename, ALenum *format, void **wave, +void alutLoadWAVFile_CFH(char *filename, ALenum *format, void **wave, unsigned int *size, ALsizei *freq); -void alutUnloadWAV_CFH(ALenum format, void *wave, unsigned int size, +void alutUnloadWAV_CFH(ALenum format, void *wave, unsigned int size, ALsizei freq); #define alutLoadWAVFile alutLoadWAVFile_CFH -#define alutUnloadWAV alutUnloadWAV_CFH +#define alutUnloadWAV alutUnloadWAV_CFH #else -void LoadOGG_CFH(char *filename, ALenum *format, void **wave, +void LoadOGG_CFH(char *filename, ALenum *format, void **wave, unsigned int *size, ALsizei *freq); -void FreeOGG(ALenum format, void *wave, unsigned int size, +void FreeOGG(ALenum format, void *wave, unsigned int size, ALsizei freq); #endif - FILE *cfh_fopen(const char *filename, const char *mode); #endif diff --git a/src/TGALoader.cpp b/src/TGALoader.cpp index 27fd5b9..ea26920 100644 --- a/src/TGALoader.cpp +++ b/src/TGALoader.cpp @@ -1,10 +1,9 @@ /**> HEADER FILES <**/ #include "TGALoader.h" - /********************> LoadTGA() <*****/ TGAImageRec* LoadTGA( char *filename ) -{ +{ GLubyte TGAheader[12]={0,0,2,0,0,0,0,0,0,0,0,0}; // Uncompressed TGA Header GLubyte TGAcompare[12]; // Used To Compare TGA Header GLubyte header[6]; // First 6 Useful Bytes From The Header @@ -13,7 +12,7 @@ TGAImageRec* LoadTGA( char *filename ) GLuint temp; // Temporary Variable TGAImageRec *texture; FILE *file; - + // Open The TGA File file = cfh_fopen( filename, "rb" ); @@ -26,14 +25,14 @@ TGAImageRec* LoadTGA( char *filename ) fclose( file ); return NULL; } - + // Create a new RGBAImageRec texture = ( TGAImageRec* )malloc( sizeof( TGAImageRec ) ); - + // Determine the TGA width (highbyte*256+lowbyte) and height (highbyte*256+lowbyte) texture->sizeX = header[1] * 256 + header[0]; texture->sizeY = header[3] * 256 + header[2]; - + // Make sure the height, width, and bit depth are valid if( ( texture->sizeX <= 0 ) || ( texture->sizeY <= 0 ) || ( ( header[4] != 24 ) && ( header[4] != 32 ) ) ) { @@ -42,17 +41,17 @@ TGAImageRec* LoadTGA( char *filename ) free( texture ); return NULL; } - + // Grab The TGA's Bits Per Pixel (24 or 32) - texture->bpp = header[4]; + texture->bpp = header[4]; bytesPerPixel = texture->bpp/8; // Divide By 8 To Get The Bytes Per Pixel - + // Calculate The Memory Required For The TGA Data imageSize = texture->sizeX * texture->sizeY * bytesPerPixel; - + // Reserve Memory To Hold The TGA Data - texture->data = ( GLubyte* )malloc( imageSize ); - + texture->data = ( GLubyte* )malloc( imageSize ); + // Make sure the right amount of memory was allocated if( ( texture->data == NULL ) || ( fread( texture->data, 1, imageSize, file ) != imageSize ) ) { @@ -65,7 +64,7 @@ TGAImageRec* LoadTGA( char *filename ) free( texture ); return NULL; } - + // Loop Through The Image Data for( GLuint i = 0; i < int( imageSize ); i += bytesPerPixel ) { @@ -74,9 +73,9 @@ TGAImageRec* LoadTGA( char *filename ) texture->data[i] = texture->data[i + 2]; // Set The 1st Byte To The Value Of The 3rd Byte texture->data[i + 2] = temp; // Set The 3rd Byte To The Value In 'temp' (1st Byte Value) } - + // Close The File fclose( file ); - + return texture; } diff --git a/src/TGALoader.h b/src/TGALoader.h index 83f4476..ab26f88 100644 --- a/src/TGALoader.h +++ b/src/TGALoader.h @@ -1,16 +1,15 @@ -#ifdef OS9 +#ifdef OS9 #pragma once #endif #ifndef _TGA_LOADER_H_ #define _TGA_LOADER_H_ - /**> HEADER FILES <**/ #include <stdlib.h> #include <stdio.h> #include <string.h> -#ifdef OS9 +#ifdef OS9 #include "gl.h" #else #include <GL/gl.h> @@ -27,10 +26,7 @@ typedef struct TGAImageRec GLuint sizeY; } TGAImageRec; - - /**> FUNCTION PROTOTYPES <**/ TGAImageRec* LoadTGA( char *filename ); - #endif diff --git a/src/Text.cpp b/src/Text.cpp index 2c2323a..99878d3 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -12,7 +12,7 @@ void Text::BuildFont() // Build Our Font Display List float cx; // Holds Our X Character Coord float cy; // Holds Our Y Character Coord int loop; - + base=glGenLists(256); // Creating 256 Display Lists glBindTexture(GL_TEXTURE_2D, FontTexture); // Select Our Font Texture for (loop=0; loop<256; loop++) // Loop Through All 256 Lists diff --git a/src/Text.h b/src/Text.h index 99e8a6c..77dee46 100644 --- a/src/Text.h +++ b/src/Text.h @@ -1,10 +1,9 @@ #ifndef _TEXT_H_ #define _TEXT_H_ - /**> HEADER FILES <**/ #include "Quaternions.h" -#ifdef OS9 +#ifdef OS9 #include <gl.h> #include <glu.h> #else @@ -18,15 +17,14 @@ class Text{ public: GLuint FontTexture; GLuint base; - + void LoadFontTexture(char *fileName); void BuildFont(); void glPrint(GLint x, GLint y, char *string, int set, float size, float width, float height); - + ~Text(){ glDeleteTextures( 1, (const GLuint *)FontTexture ); } }; #endif - diff --git a/src/Textures.cpp b/src/Textures.cpp index 0f829dc..dbd3674 100644 --- a/src/Textures.cpp +++ b/src/Textures.cpp @@ -48,7 +48,7 @@ GLuint loadTexture(const char* filename_, GLenum minFilter, GLenum magFilter, bo format = GL_BGR; }; }; - + //well, our textures are upside down. Fixing it here. Uint32 bytesPerRow = surface->format->BytesPerPixel*surface->w; char * buf = new char[bytesPerRow]; @@ -61,13 +61,12 @@ GLuint loadTexture(const char* filename_, GLenum minFilter, GLenum magFilter, bo memcpy(&p[offset2], buf, bytesPerRow); } delete[] buf; - + glTexImage2D(GL_TEXTURE_2D, 0, numColors, surface->w, surface->h, 0, format, GL_UNSIGNED_BYTE, surface->pixels); if (mipmaps) gluBuild2DMipmaps(GL_TEXTURE_2D, format, surface->w, surface->h, format, GL_UNSIGNED_BYTE, surface->pixels); } - + delete surface; return tex; } - diff --git a/src/Timer.cpp b/src/Timer.cpp index 80cc5f9..869c154 100644 --- a/src/Timer.cpp +++ b/src/Timer.cpp @@ -1,28 +1,26 @@ /**> HEADER FILES <**/ #include <string.h> -#include "Timer.h" +#include "Timer.h" #include "Support.h" - /********************> Timer <*****/ void TimerInit(timer* theTimer) { - UnsignedWide ms; + UnsignedWide ms; + + Microseconds(&ms); - Microseconds(&ms); - - memset(theTimer, 0, sizeof(timer)); + memset(theTimer, 0, sizeof(timer)); - theTimer->mm_timer_start = ms.lo; - theTimer->mm_timer_elapsed = theTimer->mm_timer_start; + theTimer->mm_timer_start = ms.lo; + theTimer->mm_timer_elapsed = theTimer->mm_timer_start; } float TimerGetTime(timer* theTimer) { UnsignedWide ms; - + Microseconds(&ms); - - + return( (float) (ms.lo - theTimer->mm_timer_start) * 1000.0f); } diff --git a/src/Timer.h b/src/Timer.h index c0c99a1..2974383 100644 --- a/src/Timer.h +++ b/src/Timer.h @@ -1,18 +1,15 @@ #ifndef _TIMER_H_ #define _TIMER_H_ - /**> HEADER FILES <**/ -class timer +class timer { public: - unsigned long mm_timer_start; - unsigned long mm_timer_elapsed; + unsigned long mm_timer_start; + unsigned long mm_timer_elapsed; }; - void TimerInit(timer* theTimer); float TimerGetTime(timer* theTimer); #endif - |