]> git.jsancho.org Git - lugaru.git/commitdiff
Add a pretty and desactivable damage bar.
authorCôme BERNIGAUD <come.bernigaud@laposte.net>
Sat, 15 May 2010 22:22:09 +0000 (00:22 +0200)
committerCôme BERNIGAUD <come.bernigaud@laposte.net>
Sat, 15 May 2010 22:22:09 +0000 (00:22 +0200)
Source/GameDraw.cpp
Source/GameTick.cpp
Source/Globals.cpp
Source/OpenGL_Windows.cpp

index ea75d51b0eed5a8e5d972dd6fbe3a01ff4dcae03..e01f46ce516c498ce6019bda1c2f8abcfd1ea52a 100644 (file)
@@ -175,6 +175,8 @@ extern float accountcampaigntime[10];
 
 extern bool gamestarted;
 
+extern bool showdamagebar;
+
 extern OPENAL_SAMPLE   *samp[100];
 extern int channels[100];
 extern "C"     void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
@@ -1226,6 +1228,90 @@ int Game::DrawGLScene(void)
                                        text.glPrintOutline(1024/40-4,768/16-4+768*14/16,string,1,1.5*1.25,1024,768);
                                        glColor4f(1,0,0,1);
                                        text.glPrint(1024/40,768/16+768*14/16,string,1,1.5,1024,768);
+                                       if(showdamagebar) {
+                                               glDisable(GL_DEPTH_TEST);                                                       // Disables Depth Testing
+                                               glDisable(GL_CULL_FACE);
+                                               glDisable(GL_LIGHTING);
+                                               glDisable(GL_TEXTURE_2D);
+                                               glDepthMask(0);
+                                               glMatrixMode(GL_PROJECTION);                                            // Select The Projection Matrix
+                                               glPushMatrix();                                                                         // Store The Projection Matrix
+                                               glLoadIdentity();                                                                       // Reset The Projection Matrix
+                                               glOrtho(0,screenwidth,0,screenheight,-100,100);         // Set Up An Ortho Screen
+                                               glMatrixMode(GL_MODELVIEW);                                                     // Select The Modelview Matrix
+                                               glPushMatrix();                                                                         // Store The Modelview Matrix
+                                               glLoadIdentity();                                                                       // Reset The Modelview Matrix
+                                               glTranslatef(15,screenheight*17.5/20,0);
+                                               glScalef(screenwidth/3+20,screenheight/20,1);
+                                               glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
+                                               glEnable(GL_BLEND);
+                                               glColor4f(0.0,0.4,0.0,0.7);
+                                               float bar=((float)player[0].damage)/player[0].damagetolerance;
+                                               glBegin(GL_QUADS);
+                                               glVertex3f((bar<1?bar:1),0,0.0f);
+                                               glVertex3f(1,0,0.0f);
+                                               glVertex3f(1,1,0.0f);
+                                               glVertex3f((bar<1?bar:1),1,0.0f);
+                                               glEnd();
+                                               glColor4f(0.1,0.0,0.0,1);
+                                               bar = ((float)player[0].bloodloss)/player[0].damagetolerance;
+                                               glBegin(GL_QUADS);
+                                               glVertex3f(0,0,0.0f);
+                                               glVertex3f((bar<1?bar:1),0,0.0f);
+                                               glVertex3f((bar<1?bar:1),1,0.0f);
+                                               glVertex3f(0,1,0.0f);
+                                               glEnd();
+                                               glColor4f(0.4,0.0,0.0,0.7);
+                                               bar = ((float)player[0].damage)/player[0].damagetolerance;
+                                               glBegin(GL_QUADS);
+                                               glVertex3f(0,0,0.0f);
+                                               glVertex3f((bar<1?bar:1),0,0.0f);
+                                               glVertex3f((bar<1?bar:1),1,0.0f);
+                                               glVertex3f(0,1,0.0f);
+                                               glEnd();
+                                               glColor4f(0.4,0.0,0.0,0.7);
+                                               bar = ((float)player[0].permanentdamage)/player[0].damagetolerance;
+                                               glBegin(GL_QUADS);
+                                               glVertex3f(0,0,0.0f);
+                                               glVertex3f((bar<1?bar:1),0,0.0f);
+                                               glVertex3f((bar<1?bar:1),1,0.0f);
+                                               glVertex3f(0,1,0.0f);
+                                               glEnd();
+                                               glColor4f(0.4,0.0,0.0,0.7);
+                                               bar = ((float)player[0].superpermanentdamage)/player[0].damagetolerance;
+                                               glBegin(GL_QUADS);
+                                               glVertex3f(0,0,0.0f);
+                                               glVertex3f((bar<1?bar:1),0,0.0f);
+                                               glVertex3f((bar<1?bar:1),1,0.0f);
+                                               glVertex3f(0,1,0.0f);
+                                               glEnd();
+                                               glColor4f(0.0,0.0,0.0,0.7);
+                                               glLineWidth(2.0);
+                                               glBegin(GL_LINE_STRIP);
+                                               glVertex3f(0,0,0.0f);
+                                               glVertex3f(1,0,0.0f);
+                                               glVertex3f(1,1,0.0f);
+                                               glVertex3f(0,1,0.0f);
+                                               glVertex3f(0,0,0.0f);
+                                               glEnd();
+                                               
+                                               glMatrixMode(GL_PROJECTION);                                            // Select The Projection Matrix
+                                               glPopMatrix();                                                                          // Restore The Old Projection Matrix
+                                               glMatrixMode(GL_MODELVIEW);                                                     // Select The Modelview Matrix
+                                               glPopMatrix();                                                                          // Restore The Old Projection Matrix
+                                               glEnable(GL_DEPTH_TEST);                                                        // Enables Depth Testing
+                                               glEnable(GL_CULL_FACE);
+                                               glDisable(GL_BLEND);
+                                               glDepthMask(1);
+                                               glEnable(GL_TEXTURE_2D);
+                                               
+                                               // writing the numbers : 
+                                               sprintf (string, "Damages : %d/%d (%d)",(int)(player[0].damage),(int)(player[0].damagetolerance),(int)(player[0].bloodloss));
+                                               glColor4f(0,0,0,1);
+                                               text.glPrintOutline(1024/40-4,768/16-4+768*14/16-40,string,1,1.5*1.25,1024,768);
+                                               glColor4f(1,0,0,1);
+                                               text.glPrint(1024/40,768/16+768*14/16-40,string,1,1.5,1024,768);
+                                       }
                                }
 
                                glColor4f(.5,.5,.5,1);
index 2e424760f6f8ac8c9797aff2883ecf25924de61e..ae0366d8f76d1d5a9fb1d9ac0d79b3c5c1bb6c64 100644 (file)
@@ -100,6 +100,7 @@ extern bool foliage;
 extern bool trilinear;
 extern bool damageeffects;
 extern bool showpoints;
+extern bool showdamagebar; // (des)activate the damage bar
 extern bool texttoggle;
 extern bool alwaysblur;
 extern float gamespeed;
@@ -1899,6 +1900,8 @@ void      Game::Tick()
                                opstream << KeyToChar(attackkey);
                                opstream << "\nChat key:\n";
                                opstream << KeyToChar(chatkey);
+                               opstream << "\nDamage bar:\n";
+                               opstream << showdamagebar;
                                opstream.close();
                        }
                        if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==13||mainmenu==10||mainmenu==11||mainmenu==100){
@@ -2294,6 +2297,8 @@ void      Game::Tick()
                                opstream << KeyToChar(attackkey);
                                opstream << "\nChat key:\n";
                                opstream << KeyToChar(chatkey);
+                               opstream << "\nDamage bar:\n";
+                               opstream << showdamagebar;
                                opstream.close();
 
                                if(mainmenu==3&&gameon)mainmenu=2;
@@ -2922,6 +2927,8 @@ void      Game::Tick()
                                opstream << KeyToChar(attackkey);
                                opstream << "\nChat key:\n";
                                opstream << KeyToChar(chatkey);
+                               opstream << "\nDamage bar:\n";
+                               opstream << showdamagebar;
                                opstream.close();
                        }
                }
@@ -5364,6 +5371,8 @@ void      Game::Tick()
                                opstream << KeyToChar(attackkey);
                                opstream << "\nChat key:\n";
                                opstream << KeyToChar(chatkey);
+                               opstream << "\nDamage bar:\n";
+                               opstream << showdamagebar;
                                opstream.close();
                        }
                }
index 2eae6fbc7979c31da454398c1257935c144ce1c7..dfb570df66db83fe7bec1590087829f6dd4d26ab 100644 (file)
@@ -119,6 +119,7 @@ char mapname[256] = {0};
 bool loadingstuff = 0;
 bool stillloading = 0;
 bool showpoints = 0;
+bool showdamagebar = 0;
 bool alwaysblur = 0;
 bool immediate = 0;
 bool velocityblur = 0;
index da5118519eb0526874f7878c36d76767a69cedf1..24284725e5605a24f0f17a585c04b11b4ae73332 100644 (file)
@@ -97,6 +97,7 @@ extern Person player[maxplayers];
 extern bool vblsync;
 extern bool stillloading;
 extern bool showpoints;
+extern bool showdamagebar;
 extern bool alwaysblur;
 extern bool immediate;
 extern bool velocityblur;
@@ -600,6 +601,7 @@ Boolean SetUp (Game & game)
        texttoggle=1;
        alwaysblur=0;
        showpoints=0;
+       showdamagebar=0;
        immediate=0;
        velocityblur=0;
 
@@ -699,6 +701,8 @@ Boolean SetUp (Game & game)
                opstream << KeyToChar(game.attackkey);
                opstream << "\nChat key:\n";
                opstream << KeyToChar(game.chatkey);
+               opstream << "\nDamage bar:\n";
+               opstream << showdamagebar;
                opstream.close();
        }
        if(ipstream){
@@ -845,6 +849,10 @@ Boolean SetUp (Game & game)
                ipstream.ignore(256,'\n');
                ipstream >> string;
                game.chatkey=CharToKey(string);
+               ipstream.ignore(256,'\n');
+               ipstream.ignore(256,'\n');
+               ipstream >> i;
+               showdamagebar = (i != 0);
                ipstream.close();
 
                if(detail>2)detail=2;