Browse Source

Add colors in terminal display

DricomDragon 5 years ago
parent
commit
c3e770ef3e
1 changed files with 15 additions and 1 deletions
  1. 15 1
      main.cc

+ 15 - 1
main.cc

@@ -21,6 +21,7 @@ using namespace std;
 #define DEFAULT_PROBABILITY 0.2
 #define DEFAULT_ANIMATION true
 #define DEFAULT_ANIMATION_DELAY 50000 // us
+#define DEFAULT_COLOR_ENABLE true
 
 // Tile codes
 #define FREE 0
@@ -119,22 +120,35 @@ class World
 							cout << " ";
 							break;
 						case WALL:
+							if (DEFAULT_COLOR_ENABLE) cout << "\033[0;43m";
 							cout << "#";
 							break;
 						case ORIGIN:
+							if (DEFAULT_COLOR_ENABLE) cout << "\033[1;33m";
 							cout << "o";
 							break;
 						case TARGET:
+							if (DEFAULT_COLOR_ENABLE) cout << "\033[1;33m";
 							cout << "T";
 							break;
 						case DISCOVERED:
+							if (DEFAULT_COLOR_ENABLE) cout << "\033[0;34m";
 							cout << ":";
 							break;
 						case TRACE:
-							cout << "+";
+							if (DEFAULT_COLOR_ENABLE) {
+								cout << "\033[0;32m";
+								cout << "\033[1;42m";
+								cout << ":";
+							}
+							else
+								cout << "+";
 							break;
 					}
+
+					if (DEFAULT_COLOR_ENABLE) cout << "\033[0;30m";
 				}
+
 				cout << endl;
 			}
 		}