Permalink
Browse files

Add health bars

  • Loading branch information...
1 parent 53ac36f commit 0b5dd781971e2afde61e7e3e83debe42a4bc8832 @DolceTriade DolceTriade committed Apr 28, 2012
Showing with 13 additions and 1 deletion.
  1. +12 −1 src/gamelogic/gpp/src/cgame/cg_draw.c
  2. +1 −0 src/gamelogic/gpp/ui/menudef.h
View
13 src/gamelogic/gpp/src/cgame/cg_draw.c
@@ -1492,6 +1492,15 @@ static void CG_DrawPlayerBuildTimerBar( rectDef_t *rect, vec4_t foreColor, qhand
CG_DrawPlayerProgressBar( rect, foreColor, 1-progress, 0.9, shader );
}
+static void CG_DrawPlayerHealthBar( rectDef_t *rect, vec4_t foreColor, qhandle_t shader )
+{
+ playerState_t *ps = &cg.snap->ps;
+
+ float progress = (float)ps->stats[ STAT_HEALTH ] / (float)BG_Class( ps->stats[ STAT_CLASS ] )->health;
+ CG_DrawPlayerProgressBar( rect, foreColor, progress, -0.3, shader );
+}
+
+
static void CG_DrawProgressLabel( rectDef_t *rect, float text_x, float text_y, vec4_t color,
float scale, int textalign, int textvalign,
@@ -3757,7 +3766,9 @@ void CG_OwnerDraw( float x, float y, float w, float h, float text_x,
case CG_PLAYER_HEALTH:
CG_DrawPlayerHealthValue( &rect, foreColor );
break;
-
+ case CG_PLAYER_HEALTH_BAR:
+ CG_DrawPlayerHealthBar( &rect, foreColor, shader );
+ break;
case CG_PLAYER_HEALTH_CROSS:
CG_DrawPlayerHealthCross( &rect, foreColor );
break;
View
1 src/gamelogic/gpp/ui/menudef.h
@@ -133,6 +133,7 @@ enum
enum
{
CG_PLAYER_HEALTH,
+ CG_PLAYER_HEALTH_BAR,
CG_PLAYER_HEALTH_CROSS,
CG_PLAYER_AMMO_VALUE,
CG_PLAYER_CLIPS_VALUE,

0 comments on commit 0b5dd78

Please sign in to comment.