From: Ryan Flegel Date: Wed, 24 Nov 2004 18:22:22 +0000 (+0000) Subject: - added debug grid. type 'grid' in-game to toggle X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=97ebb26d836f8dc44cbf74fc6383ce17b2b98416;p=supertux.git - added debug grid. type 'grid' in-game to toggle SVN-Revision: 2173 --- diff --git a/lib/app/globals.cpp b/lib/app/globals.cpp index 8b6e9e5c7..3b042f11d 100644 --- a/lib/app/globals.cpp +++ b/lib/app/globals.cpp @@ -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; diff --git a/lib/app/globals.h b/lib/app/globals.h index 7c76c0de2..83d57edb8 100644 --- a/lib/app/globals.h +++ b/lib/app/globals.h @@ -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; diff --git a/src/gameloop.cpp b/src/gameloop.cpp index 89776b069..69f9f717a 100644 --- a/src/gameloop.cpp +++ b/src/gameloop.cpp @@ -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; diff --git a/src/tilemap.cpp b/src/tilemap.cpp index 47cdeea7b..08784415c 100644 --- a/src/tilemap.cpp +++ b/src/tilemap.cpp @@ -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(); }