Can't go under downbar
authornireco
Mon, 08 Dec 2008 22:23:14 +0000
changeset 318 dca3c836edb2
parent 317 f325fad21f4f
child 319 9f6a838d58c4
Can't go under downbar
src/Graphics.cc
src/Weapon.hh
--- a/src/Graphics.cc	Mon Dec 08 22:10:47 2008 +0000
+++ b/src/Graphics.cc	Mon Dec 08 22:23:14 2008 +0000
@@ -74,8 +74,8 @@
     
     // ...to track our local player
     if ((player = state.getLocalPlayer()) != NULL) {
-        PixelCoordinate target = player->getCoordinate() - resolution / 2;
-        PixelCoordinate max = state.world.getDimensions() - resolution;
+        PixelCoordinate target = player->getCoordinate() - PixelCoordinate(resolution.x / 2, (resolution.y - 100) / 2);
+        PixelCoordinate max = state.world.getDimensions() - resolution + PixelCoordinate(0, 100);
         
         // keep the terrain in view
         camera = PixelCoordinate(
@@ -114,7 +114,7 @@
     int box_left = 0;
     int box_right = GRAPHICS_RESOLUTION_WIDTH;
     int box_bottom = GRAPHICS_RESOLUTION_HEIGHT;
-    int life_bar_length = 3; // *100
+    int bar_length = 3; // *100
 
     // draw status info at bottom of display
     gc->fill_rect(
@@ -131,12 +131,13 @@
             CL_Color(100, 100, 100, 200)
         )
     );
-
+    
+    // Lifebar
     gc->draw_rect(
         CL_Rect(
             box_left + 9,
             box_top + 9,
-            box_left + 11 + 100 * life_bar_length,
+            box_left + 11 + 100 * bar_length,
             box_top + 31
         ),
         CL_Color(150, 150, 150)
@@ -146,7 +147,7 @@
         CL_Rect(
             box_left + 10,
             box_top + 10,
-            box_left + 10 + (int) (p->getHealthPercent() * life_bar_length),
+            box_left + 10 + (int) (p->getHealthPercent() * bar_length),
             box_top + 30
         ),
         CL_Gradient(
@@ -156,5 +157,31 @@
             CL_Color(200 - (int)(p->getHealthPercent() * 2), (int)(p->getHealthPercent() * 2), 0)
         )
     );
+
+    // Ammobar
+    gc->draw_rect(
+        CL_Rect(
+            box_left + 9,
+            box_top + 39,
+            box_left + 11 + 100 * bar_length,
+            box_top + 61
+        ),
+        CL_Color(150, 150, 150)
+    );
+
+    gc->fill_rect(
+        CL_Rect(
+            box_left + 10,
+            box_top + 40,
+            box_left + 10 + (int) (p->getCurrentWeapon()->getReloadTimer() * 100 / p->getCurrentWeapon()->getReloadTime() * bar_length),
+            box_top + 60
+        ),
+        CL_Gradient(
+            CL_Color(100, 100, 0),
+            CL_Color(100, 100, 0),
+            CL_Color(100, 100, 0),
+            CL_Color(100, 100, 100)
+        )
+    );
 }
 
--- a/src/Weapon.hh	Mon Dec 08 22:10:47 2008 +0000
+++ b/src/Weapon.hh	Mon Dec 08 22:23:14 2008 +0000
@@ -105,6 +105,9 @@
     float getRadius (void) const { return radius; }
     TickCount getExpire (void) const { return expire; }
     float getBounce (void) const { return bounce; }
+
+    int getReloadTimer(void) const { return reloadTimer; }
+    int getReloadTime(void) const { return reloadTime; }
     
     /**
      * Start reloading