Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <conio.h>
- #include <windows.h>
- #include <time.h>
- using namespace std;
- ifstream screenInput;
- void createScreen();
- void printScreen();
- void input();
- void createTeams();
- void updateAllianceSelect();
- void updateTeamSelect();
- void updateMode();
- void updatePassAssist();
- void updateGoal();
- void updateCaughtBall();
- void updateDroveForward();
- static char screen[20][69];
- static char droveForwardString[13] = {'D', 'R', 'O', 'V', 'E', ' ', 'F', 'O', 'R', 'W', 'A', 'R', 'D'};
- static char ballCatchString[13] = {'C', 'A', 'T', 'C', 'H', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '};
- static char blueTeamOneName[4];
- static char blueTeamTwoName[4];
- static char blueTeamThreeName[4];
- static char redTeamOneName[4];
- static char redTeamTwoName[4];
- static char redTeamThreeName[4];
- static int blueTeam;
- static int blueTeamOne;
- static int blueTeamTwo;
- static int blueTeamThree;
- static int redTeam;
- static int redTeamOne;
- static int redTeamTwo;
- static int redTeamThree;
- static int teamSelect = 1; // 1 | 2 | 3
- static int passAssist = 0; // 0 | 1 | 2 | 3
- static bool gameMode = false; // false = autonomous | true = teleop
- static bool goal = true; // false = low | true = high
- static bool ballCatch = false; // false = no | true = yes
- static bool droveForward = false; // false = no | true = yes
- static bool allianceSelect = false; // false = red | true = blue
- int main()
- {
- bool runTime = true;
- bool runCommand = false;
- createScreen();
- createTeams();
- while (runTime)
- {
- printScreen();
- input();
- }
- return 0;
- }
- void createScreen()
- {
- screenInput.open("screen.txt");
- for (int x = 0; x != 20; x++)
- {
- for (int y = 0; y != 69; y++)
- {
- screenInput >> screen[x][y];
- if (screen[x][y] == '.')
- screen[x][y] = ' ';
- if (screen[x][y] == 'x')
- screen[x][y] = (char)219;
- }
- }
- screenInput.close();
- }
- void printScreen()
- {
- COORD set{ 0, 0 };
- SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), set);
- for (int x = 0; x != 20; x++)
- {
- for (int y = 0; y != 69; y++)
- {
- cout << screen[x][y];
- }
- cout << endl;
- }
- }
- void input()
- {
- int command = _getch();
- if (command == 77 || command == 109) // m key | changes auto and tele
- {
- if (gameMode)
- gameMode = false;
- else if (!gameMode)
- gameMode = true;
- updateMode();
- }
- if (command == 74 || command == 106) // j key | high or low goal selection
- {
- if (goal)
- goal = false;
- else if (!goal)
- goal = true;
- updateGoal();
- }
- if (command == 75 || command == 107) // k key | pass assist counter
- {
- if (passAssist >= 0 && passAssist <= 2)
- passAssist++;
- else if (passAssist == 3)
- passAssist = 0;
- updatePassAssist();
- }
- if (command == 76 || command == 108) // l key | caught a ball or not | drove forward or not
- {
- if (gameMode)
- {
- if (ballCatch)
- ballCatch = false;
- else if (!ballCatch)
- ballCatch = true;
- updateCaughtBall();
- }
- else if (!gameMode)
- {
- if (droveForward)
- droveForward = false;
- else if (!droveForward)
- droveForward = true;
- updateDroveForward();
- }
- }
- if (command == 65 || command == 68 || command == 97 || command == 100) // a and d key | alliance select
- {
- if (allianceSelect)
- allianceSelect = false;
- else if (!allianceSelect)
- allianceSelect = true;
- updateAllianceSelect();
- }
- if (command == 83 || command == 87 || command == 115 || command == 119) // w and s key | team select
- {
- if (teamSelect == 1 || teamSelect == 2)
- teamSelect++;
- else if (teamSelect == 3)
- teamSelect = 1;
- updateTeamSelect();
- }
- }
- void createTeams()
- {
- cout << "ENTER THE TEAM NUMBER FOR EACH TEAM\nRED TEAM 1: ";
- cin.getline(redTeamOneName, 5);
- cout << "RED TEAM 2: ";
- cin.getline(redTeamTwoName, 5);
- cout << "RED TEAM 3: ";
- cin.getline(redTeamThreeName, 5);
- cout << "\nBLUE TEAM 1: ";
- cin.getline(blueTeamOneName, 5);
- cout << "BLUE TEAM 2: ";
- cin.getline(blueTeamTwoName, 5);
- cout << "BLUE TEAM 3: ";
- cin.getline(blueTeamThreeName, 5);
- for (int i = 4; i != 10; i += 2)
- {
- for (int x = 0; x != 4; x++)
- {
- if (i == 4)
- screen[i][11 + x] = redTeamOneName[x];
- else if (i == 6)
- screen[i][11 + x] = redTeamTwoName[x];
- else if (i == 8)
- screen[i][11 + x] = redTeamThreeName[x];
- }
- }
- for (int i = 4; i != 10; i += 2)
- {
- for (int x = 0; x != 4; x++)
- {
- if (i == 4)
- screen[i][45 + x] = blueTeamOneName[x];
- else if (i == 6)
- screen[i][45 + x] = blueTeamTwoName[x];
- else if (i == 8)
- screen[i][45 + x] = blueTeamThreeName[x];
- }
- }
- }
- void updateAllianceSelect()
- {
- if (allianceSelect)
- {
- screen[2][39] = '[';
- screen[2][53] = ']';
- screen[2][5] = ' ';
- screen[2][18] = ' ';
- if (teamSelect == 1)
- {
- screen[4][39] = '[';
- screen[4][49] = ']';
- screen[4][5] = ' ';
- screen[4][15] = ' ';
- }
- else if (teamSelect == 2)
- {
- screen[6][39] = '[';
- screen[6][49] = ']';
- screen[6][5] = ' ';
- screen[6][15] = ' ';
- }
- else if (teamSelect == 3)
- {
- screen[8][39] = '[';
- screen[8][49] = ']';
- screen[8][5] = ' ';
- screen[8][15] = ' ';
- }
- }
- else if (!allianceSelect)
- {
- screen[2][5] = '[';
- screen[2][18] = ']';
- screen[2][39] = ' ';
- screen[2][53] = ' ';
- if (teamSelect == 1)
- {
- screen[4][5] = '[';
- screen[4][15] = ']';
- screen[4][39] = ' ';
- screen[4][49] = ' ';
- }
- else if (teamSelect == 2)
- {
- screen[6][5] = '[';
- screen[6][15] = ']';
- screen[6][39] = ' ';
- screen[6][49] = ' ';
- }
- else if (teamSelect == 3)
- {
- screen[8][5] = '[';
- screen[8][15] = ']';
- screen[8][39] = ' ';
- screen[8][49] = ' ';
- }
- }
- }
- void updateTeamSelect()
- {
- if (!allianceSelect)
- {
- if (teamSelect == 1)
- {
- screen[4][5] = '[';
- screen[4][15] = ']';
- screen[8][5] = ' ';
- screen[8][15] = ' ';
- }
- else if (teamSelect == 2)
- {
- screen[6][5] = '[';
- screen[6][15] = ']';
- screen[4][5] = ' ';
- screen[4][15] = ' ';
- }
- else if (teamSelect == 3)
- {
- screen[8][5] = '[';
- screen[8][15] = ']';
- screen[6][5] = ' ';
- screen[6][15] = ' ';
- }
- }
- else if (allianceSelect)
- {
- if (teamSelect == 1)
- {
- screen[4][39] = '[';
- screen[4][49] = ']';
- screen[8][39] = ' ';
- screen[8][49] = ' ';
- }
- else if (teamSelect == 2)
- {
- screen[6][39] = '[';
- screen[6][49] = ']';
- screen[4][39] = ' ';
- screen[4][49] = ' ';
- }
- else if (teamSelect == 3)
- {
- screen[8][39] = '[';
- screen[8][49] = ']';
- screen[6][39] = ' ';
- screen[6][49] = ' ';
- }
- }
- }
- void updateMode()
- {
- if (!gameMode)
- {
- screen[17][62] = '[';
- screen[17][67] = ']';
- screen[18][62] = ' ';
- screen[18][67] = ' ';
- for (int x = 0; x != 13; x++)
- screen[12][38 + x] = droveForwardString[x];
- }
- else if (gameMode)
- {
- screen[18][62] = '[';
- screen[18][67] = ']';
- screen[17][62] = ' ';
- screen[17][67] = ' ';
- for (int x = 0; x != 13; x++)
- screen[12][38 + x] = ballCatchString[x];
- }
- }
- void updatePassAssist()
- {
- if (passAssist == 1)
- {
- screen[12][19] = '[';
- screen[12][33] = ']';
- }
- else if (passAssist == 2)
- {
- screen[14][19] = '[';
- screen[14][33] = ']';
- screen[12][19] = ' ';
- screen[12][33] = ' ';
- }
- else if (passAssist == 3)
- {
- screen[16][19] = '[';
- screen[16][33] = ']';
- screen[14][19] = ' ';
- screen[14][33] = ' ';
- }
- else if (passAssist == 0)
- {
- screen[16][19] = ' ';
- screen[16][33] = ' ';
- }
- }
- void updateGoal()
- {
- if (goal)
- {
- screen[12][5] = '[';
- screen[12][15] = ']';
- screen[14][5] = ' ';
- screen[14][14] = ' ';
- }
- else if (!goal)
- {
- screen[14][5] = '[';
- screen[14][14] = ']';
- screen[12][5] = ' ';
- screen[12][15] = ' ';
- }
- }
- void updateCaughtBall()
- {
- if (ballCatch)
- {
- screen[12][37] = '[';
- screen[12][43] = ']';
- }
- else if (!ballCatch)
- {
- screen[12][37] = ' ';
- screen[12][43] = ' ';
- }
- }
- void updateDroveForward()
- {
- if (droveForward)
- {
- screen[12][37] = '[';
- screen[12][51] = ']';
- }
- else if (!droveForward)
- {
- screen[12][37] = ' ';
- screen[12][51] = ' ';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment