X-Git-Url: https://git.ucc.asn.au/?p=progcomp2012.git;a=blobdiff_plain;f=judge%2Fmanager%2Fhuman_controller.cpp;h=e2b5845f81bd8c7c0421af3627a9b715c154e791;hp=bf43e8d71eda1323b89a486a39afd81430f926ea;hb=5f9adddd695f2664a0d690b59a779e40b51ade3d;hpb=1a03b2543b67f0551e62babec4cd119f1e0e4640 diff --git a/judge/manager/human_controller.cpp b/judge/manager/human_controller.cpp index bf43e8d..e2b5845 100644 --- a/judge/manager/human_controller.cpp +++ b/judge/manager/human_controller.cpp @@ -110,9 +110,10 @@ MovementResult Human_Controller::QueryMove(string & buffer) } - + #ifdef BUILD_GRAPHICS if (graphicsEnabled) { + fprintf(stdout, "Click to move!\n"); SDL_Event event; int mouseClick = 0; @@ -144,6 +145,7 @@ MovementResult Human_Controller::QueryMove(string & buffer) { int xDist = x[1] - x[0]; int yDist = y[1] - y[0]; + int magnitude = max(abs(xDist), abs(yDist)); if (abs(xDist) > abs(yDist)) { if (xDist < 0) @@ -155,6 +157,13 @@ MovementResult Human_Controller::QueryMove(string & buffer) buffer += "UP"; else buffer += "DOWN"; + + if (magnitude > 1) + { + stringstream s(""); + s << " " << magnitude; + buffer += s.str(); + } } mouseClick++; break; @@ -164,8 +173,10 @@ MovementResult Human_Controller::QueryMove(string & buffer) } } fprintf(stdout, "Move complete!\n"); + } else + #endif //BUILD_GRAPHICS { buffer.clear(); for (char in = fgetc(stdin); in != '\n'; in = fgetc(stdin))