a better crosshair
authorterom
Sun, 07 Dec 2008 20:47:25 +0000
changeset 261 91f769d490a6
parent 260 8377571871f0
child 262 fbc9ce4950de
a better crosshair
src/Config.hh
src/Player.cc
--- a/src/Config.hh	Sun Dec 07 20:44:45 2008 +0000
+++ b/src/Config.hh	Sun Dec 07 20:47:25 2008 +0000
@@ -32,7 +32,8 @@
 const float PLAYER_AIM_MAX = KG_PI/2;
 const float PLAYER_INITIAL_X = 400.0;
 const float PLAYER_INITIAL_Y = 300.0;
-const float PLAYER_CROSSHAIR_LENGTH = 10.0;
+const float PLAYER_CROSSHAIR_DISTANCE = 20.0;
+const float PLAYER_CROSSHAIR_WIDTH = 4;
 const float CROSSHAIR_ANGLE_SPEED = PI/40;
 
 const float PLAYER_MAX_SPEED = 43;
--- a/src/Player.cc	Sun Dec 07 20:44:45 2008 +0000
+++ b/src/Player.cc	Sun Dec 07 20:47:25 2008 +0000
@@ -217,13 +217,17 @@
         ), destination, gc
     );
     
-    // draw "crosshair", a half-line from our position to 10px away
-    Vector crosshair = getDirection() * PLAYER_CROSSHAIR_LENGTH;
-
-    PixelCoordinate aim_start = getCoordinate() + world.getPixelCoordinate(crosshair / 2) - camera;
-    PixelCoordinate aim_end = getCoordinate() + world.getPixelCoordinate(crosshair) - camera;
+    // draw a proper crosshair-box
+    PixelCoordinate crosshair = getCoordinate() + world.getPixelCoordinate(getDirection() * PLAYER_CROSSHAIR_DISTANCE) - camera;
     
-    gc->draw_line(aim_start.x, aim_start.y, aim_end.x, aim_end.y, CL_Color::black);
+    gc->draw_rect(
+        CL_Rectf(
+            crosshair.x - PLAYER_CROSSHAIR_WIDTH / 2,
+            crosshair.y - PLAYER_CROSSHAIR_WIDTH / 2,
+            crosshair.x + PLAYER_CROSSHAIR_WIDTH / 2,
+            crosshair.y + PLAYER_CROSSHAIR_WIDTH / 2
+        ), CL_Color::red
+    );
     
     // draw rope
     rope.draw(g, camera);