--- a/src/Graphics.cc Mon Dec 08 21:36:00 2008 +0000
+++ b/src/Graphics.cc Mon Dec 08 21:49:54 2008 +0000
@@ -89,7 +89,7 @@
// Draw box for player information
if (player != NULL) {
- player->draw_player_info(this);
+ draw_player_info(gc, (Player*)player);
}
// Flip window buffer, sync
@@ -105,3 +105,53 @@
// redraw display
do_redraw();
}
+
+void Graphics::draw_player_info(CL_GraphicContext *gc, Player *p) {
+ int box_top = GRAPHICS_RESOLUTION_HEIGHT - 100;
+ int box_left = 0;
+ int box_right = GRAPHICS_RESOLUTION_WIDTH;
+ int box_bottom = GRAPHICS_RESOLUTION_HEIGHT;
+ int life_bar_length = 3; // *100
+
+ // draw status info at bottom of display
+ gc->fill_rect(
+ CL_Rect(
+ box_left,
+ box_top,
+ box_right,
+ box_bottom
+ ),
+ CL_Gradient(
+ CL_Color(0, 0, 0, 100),
+ CL_Color(50, 50, 50, 150),
+ CL_Color(50, 50, 50, 150),
+ CL_Color(100, 100, 100, 200)
+ )
+ );
+
+ gc->draw_rect(
+ CL_Rect(
+ box_left + 9,
+ box_top + 9,
+ box_left + 11 + 100 * life_bar_length,
+ box_top + 31
+ ),
+ CL_Color(150, 150, 150)
+ );
+
+ gc->fill_rect(
+ CL_Rect(
+ box_left + 10,
+ box_top + 10,
+ box_left + 10 + (int) (p->getHealthPercent() * life_bar_length),
+ box_top + 30
+ ),
+ CL_Gradient(
+ CL_Color(200, 0, 0),
+ CL_Color(200 - (int)(p->getHealthPercent() * 2), (int)(p->getHealthPercent() * 2), 0),
+ CL_Color(200, 0, 0),
+ CL_Color(200 - (int)(p->getHealthPercent() * 2), (int)(p->getHealthPercent() * 2), 0)
+ )
+ );
+}
+
--- a/src/Graphics.hh Mon Dec 08 21:36:00 2008 +0000
+++ b/src/Graphics.hh Mon Dec 08 21:49:54 2008 +0000
@@ -47,6 +47,7 @@
void on_update (TimeMS tick_length);
+ void draw_player_info(CL_GraphicContext *gc, Player *p);
};
#endif /* GRAPHICS_HH */
--- a/src/Player.cc Mon Dec 08 21:36:00 2008 +0000
+++ b/src/Player.cc Mon Dec 08 21:49:54 2008 +0000
@@ -385,53 +385,3 @@
}
}
-void LocalPlayer::draw_player_info(Graphics *g) {
- CL_GraphicContext *gc = g->get_gc();
-
- int box_top = GRAPHICS_RESOLUTION_HEIGHT - 100;
- int box_left = 0;
- int box_right = GRAPHICS_RESOLUTION_WIDTH;
- int box_bottom = GRAPHICS_RESOLUTION_HEIGHT;
- int life_bar_length = 3; // *100
-
- // draw status info at bottom of display
- gc->fill_rect(
- CL_Rect(
- box_left,
- box_top,
- box_right,
- box_bottom
- ),
- CL_Gradient(
- CL_Color(123, 43, 1, 10),
- CL_Color(22, 234, 111, 100),
- CL_Color(1, 231, 222, 200),
- CL_Color(190, 23, 240, 150)
- )
- );
-
- gc->draw_rect(
- CL_Rect(
- box_left + 9,
- box_top + 9,
- box_left + 11 + 100 * life_bar_length,
- box_top + 31
- ),
- CL_Color(190, 23, 20)
- );
-
- gc->fill_rect(
- CL_Rect(
- box_left + 10,
- box_top + 10,
- box_left + 10 + (int) (getHealthPercent() * life_bar_length),
- box_top + 30
- ),
- CL_Gradient(
- CL_Color(23, 143, 1),
- CL_Color(222, 34, 111),
- CL_Color(122, 231, 222),
- CL_Color(19, 23, 240)
- )
- );
-}
--- a/src/Player.hh Mon Dec 08 21:36:00 2008 +0000
+++ b/src/Player.hh Mon Dec 08 21:49:54 2008 +0000
@@ -184,11 +184,6 @@
* As Player, but also draws the current weapon name if displayWeapon
*/
virtual void draw (Graphics *g, bool displayWeapon, PixelCoordinate camera);
-
- /**
- * Draws downbar containing information about local player
- */
- void draw_player_info(Graphics *g);
};
/**