diff options
Diffstat (limited to 'src/GameDraw.cpp')
-rw-r--r-- | src/GameDraw.cpp | 168 |
1 files changed, 26 insertions, 142 deletions
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; } - |