- added debug grid. type 'grid' in-game to toggle
authorRyan Flegel <rflegel@gmail.com>
Wed, 24 Nov 2004 18:22:22 +0000 (18:22 +0000)
committerRyan Flegel <rflegel@gmail.com>
Wed, 24 Nov 2004 18:22:22 +0000 (18:22 +0000)
SVN-Revision: 2173

lib/app/globals.cpp
lib/app/globals.h
src/gameloop.cpp
src/tilemap.cpp

index 8b6e9e5..3b042f1 100644 (file)
@@ -56,6 +56,7 @@ bool use_joystick;
 bool use_fullscreen;
 bool debug_mode;
 bool show_fps;
+bool debug_grid = false;
 
 int joystick_num = 0;
 char* level_startup_file = 0;
index 7c76c0d..83d57ed 100644 (file)
@@ -67,6 +67,7 @@ namespace SuperTux
   extern bool use_fullscreen;
   extern bool debug_mode;
   extern bool show_fps;
+  extern bool debug_grid;
 
   /** The number of the joystick that will be use in the game */
   extern int joystick_num;
index 89776b0..69f9f71 100644 (file)
@@ -463,6 +463,10 @@ GameSession::process_events()
                           tux.kill(tux.KILL);
                           last_keys.clear();
                           }
+                        if(compare_last(last_keys, "grid"))
+                          {    // toggle debug grid
+                          debug_grid = !debug_grid;
+                          }
                         if(compare_last(last_keys, "hover"))
                           {    // toggle hover ability on/off
                           tux.enable_hover = !tux.enable_hover;
index 47cdeea..0878441 100644 (file)
@@ -160,6 +160,21 @@ TileMap::draw(DrawingContext& context)
     }
   }
 
+  if (debug_grid)
+  {
+    for (pos.x = start_x; pos.x < end_x; pos.x += 32)
+    {
+       context.draw_filled_rect(Vector (pos.x, start_y), Vector(1, fabsf(start_y - end_y)),
+                  Color(225, 225, 225), LAYER_GUI-50);
+    }
+
+    for (pos.y = start_y; pos.y < end_y; pos.y += 32)
+    {
+       context.draw_filled_rect(Vector (start_x, pos.y), Vector(fabsf(start_x - end_x), 1),
+                  Color(225, 225, 225), LAYER_GUI-50);
+    }
+  }
+
   context.pop_transform();
 }