Explorar el Código

Encapsulate cursor movement

DricomDragon hace 5 años
padre
commit
25e9ba9d0f
Se han modificado 1 ficheros con 6 adiciones y 2 borrados
  1. 6 2
      main.cc

+ 6 - 2
main.cc

@@ -34,6 +34,10 @@ unsigned int identifyTile(unsigned int y, unsigned int x, unsigned int l) {
 	return y * l + x;
 }
 
+unsigned int moveCursorUp(const unsigned int& h) {
+	cout << "\033[" << h << 'A';
+}
+
 
 class World
 {
@@ -322,7 +326,7 @@ class World
 				markOne(tile, DISCOVERED);
 				display();
 				usleep(DEFAULT_ANIMATION_DELAY);
-				cout << "\033[" << h << 'A';
+				moveCursorUp(h);
 			}
 
 			if (exitFound)
@@ -330,7 +334,7 @@ class World
 					markOne(tile, TRACE);
 					display();
 					usleep(DEFAULT_ANIMATION_DELAY);
-					cout << "\033[" << h << 'A';
+					moveCursorUp(h);
 				}
 		}