void JButton::Draw() const { Batched& sb = *WinS::sb; glm::vec2 Pos = GlobalPos(); glm::vec4 col; if(aimed){ col = Colors::White; } else { col = Colors::Red; } sb.DrawLine(Pos, glm::vec2(Pos.x, Pos.y + size.y), 2, col); sb.DrawLine(Pos, glm::vec2(Pos.x + size.x, Pos.y), 2, col); sb.DrawLine(glm::vec2(Pos.x, Pos.y + size.y), Pos + size, 2, col); sb.DrawLine(glm::vec2(Pos.x + size.x, Pos.y), Pos + size, 2, col); text->DrawAt(atCenter(text->Size, Pos, size)); }
void speedRun(void) { resetSpeedProfile(); useIRSensors = 1; useSpeedProfile = 1; int nextDir[100] = {0}; int length = 0; xPos = 0; yPos = 0; orientation = 'N'; // Close off untraced routes closeUntracedCells(); updateDistance(); visualizeGrid(); // Simulate path for (int i = 0; !atCenter(); i++) { if (orientation == 'N') { while (!hasNorth(block[yPos][xPos]) && (distance[yPos + 1][xPos] == distance[yPos][xPos] - 1)) { length++; yPos++; } } else if (orientation == 'E') { while (!hasEast(block[yPos][xPos]) && (distance[yPos][xPos + 1] == distance[yPos][xPos] - 1)) { length++; xPos++; } } else if (orientation == 'S') { while (!hasSouth(block[yPos][xPos]) && (distance[yPos - 1][xPos] == distance[yPos][xPos] - 1)) { length++; yPos--; } } else if (orientation == 'W') { while (!hasWest(block[yPos][xPos]) && (distance[yPos][xPos - 1] == distance[yPos][xPos] - 1)) { length++; xPos--; } } distances[i] = length; nextDir[i] = getNextDirection(); length = 0; } /* Print values for (int i = 0; distances[i]; i++) printf("distances[%d] = %d | nextDir[%d] = %d\n\r", i, distances[i], i, nextDir[i]); */ orientation = 'N'; // Run path for (int i = 0; distances[i] != 0; i++) { moveForward(distances[i]); if (nextDir[i] == MOVEN) { moveN(); } else if (nextDir[i] == MOVEE) { moveE(); } else if (nextDir[i] == MOVES) { moveS(); } else if (nextDir[i] == MOVEW) { moveW(); } } useSpeedProfile = 0; turnMotorOff; }