even if i push the up or down key it wont change the feet number it always thinks its 20. Also how would i put a cap for the feet -1 and feet +1 look in comments to see what i mean. And why is spamming "firing robot miss try to move back" in line 50 but its not infinite.
#include <iostream>
#include <windows.h>
#include <conio.h>
#include <cstdlib>
#include <string>
usingnamespace std;
int main()
{
int score;// points
int feet;// distance
feet = 20;// how close/far to/from the goal
score = 0;// points
SetConsoleTitleA((LPCSTR)"FRC Robot Simulator");
cout << "FRC Robot Simulator" << endl;
cout << "Press the up arrow to move forward" << endl;
cout << "Press the down arrow to move back" << endl;
cout << "Press the left mouse to fire" << endl;
cout << "Press the R key to reset" << endl;
while (true)
{
if (GetAsyncKeyState(0x52))// R key
{
cout << "robot is in the center of the feild" << endl;
feet = 20;
score = 0;
Sleep(1000);
}
if (GetAsyncKeyState(VK_UP))// up arrow
{
cout << string(100, '\n');
cout << "robot is moving toward the goal" << endl;
feet - 1 && feet >= 1; // only as low as 1
cout << "robot is " << feet << " feet away from goal" << endl;
Sleep(1000);
}
if (GetAsyncKeyState(VK_DOWN))// down arrow
{
cout << string(100, '\n');
cout << "robot is moving away from the goal" << endl;
feet + 1 && feet <= 60; // only as high as 60
cout << "robot is " << feet << " feet away from goal" << endl;//always read out as 1
Sleep(1000);
}
if (GetAsyncKeyState(VK_LBUTTON))//left mouse button
{
cout << "firing robot" << endl;// spaming
Sleep(1000);
cout << string(100, '\n');
//gradient of robot shooting range
if (feet >= 5 && feet <= 11)//if feet is between 5 and 11
{
cout << "SCORE; determining points" << endl;// randomly choose amount of assist
int question = rand() % 4;
switch (question)
{
case 1:
cout << "no assist 10 points" << endl;
score + 10;
case 2:
cout << "1 assist 20 points" << endl;
score + 20;
case 3:
cout << "2 assist 30 points" << endl;
score + 30;
case 4:
cout << "3 assist 40 points" << endl;
score + 40;
}
cout << "your score is: " << score << endl;
}
else
{
//gradient of robot shooting range if misses
cout << "your score is: " << score << endl;
cout << "MISS, try to move ";
if (feet < 5)//if between 1 and 4
{
cout << "back" << endl;
}
elseif (feet > 11)//if between 12 and 60
{
cout << "forward" << endl;
}
}
}
}
}
//FRC Robot Simulator
//Press the up arrow to move forward
//Press the down arrow to move back
//Press the left mouse to fire
//Press the R key to reset
//(up arrow)
//robot is moving toward the goal
//robot is X feet away form the goal
//(feet = 5-11)
//SCORE; determining points
//(random)
//your score is: X
//FRC Robot Simulator
//Press the up arrow to move forward
//Press the down arrow to move back
//Press the left mouse to fire
//Press the R key to reset
//(down arrow)
//robot is moving away from the goal
//robot is X feet away form the goal
//(feet = 5-11)
//SCORE; determining points
//(random)
//your score is: X
//FRC Robot Simulator
//Press the up arrow to move forward
//Press the down arrow to move back
//Press the left mouse to fire
//Press the R key to reset
//(up arrow)
//robot is moving toward the goal
//robot is X feet away form the goal
//(feet != 5-11)
//your score is: X
//MISS, try to move
//(feet = 1-4)
//back
//FRC Robot Simulator
//Press the up arrow to move forward
//Press the down arrow to move back
//Press the left mouse to fire
//Press the R key to reset
//(up arrow)
//robot is moving toward the goal
//robot is X feet away form the goal
//(feet != 5-11)
//your score is: X
//MISS, try to move
//(feet = 12-60)
//foward
//FRC Robot Simulator
//Press the up arrow to move forward
//Press the down arrow to move back
//Press the left mouse to fire
//Press the R key to reset
//(down arrow)
//robot is moving toward the goal
//robot is X feet away form the goal
//(feet != 5-11)
//your score is: X
//MISS, try to move
//(feet = 1-4)
//back
//FRC Robot Simulator
//Press the up arrow to move forward
//Press the down arrow to move back
//Press the left mouse to fire
//Press the R key to reset
//(up arrow)
//robot is moving toward the goal
//robot is X feet away form the goal
//(feet != 5-11)
//your score is: X
//MISS, try to move
//(feet = 12-60)
//foward
//FRC Robot Simulator
//Press the up arrow to move forward
//Press the down arrow to move back
//Press the left mouse to fire
//Press the R key to reset
//(R key)
//robot is in the center of the feild
#include <iostream>
#include <windows.h>
#include <conio.h>
#include <cstdlib>
#include <string>
usingnamespace std;
int main()
{
int score;// points
int feet;// distance
feet = 20;// starting spot
score = 0;// setting points
SetConsoleTitleA((LPCSTR)"FRC Robot Simulator");
cout << "FRC Robot Simulator" << endl;
cout << "Press the up arrow to move forward" << endl;
cout << "Press the down arrow to move back" << endl;
cout << "Press enter to fire" << endl;
cout << "Press the R key to reset" << endl;
while (true)
{
if (GetAsyncKeyState(0x52))// R key
{
cout << "robot is in the center of the field" << endl;
feet = 20;
score = 0;
Sleep(100);
}
if (GetAsyncKeyState(VK_UP))// up arrow
{
cout << string(100, '\n');
cout << "robot is moving toward the goal" << endl;
feet = feet - 1; // only as low as 1
cout << "robot is " << feet << " feet away from goal" << endl;
Sleep(100);
}
if (GetAsyncKeyState(VK_DOWN))// down arrow
{
cout << string(100, '\n');
cout << "robot is moving away from the goal" << endl;
feet = feet + 1; // only as high as 60
cout << "robot is " << feet << " feet away from goal" << endl;//always read out as 1
Sleep(100);
}
if (GetAsyncKeyState(VK_RETURN))//left mouse button
{
cout << "firing robot" << endl;// spaming
Sleep(100);
cout << string(100, '\n');
//gradient of robot shooting range
if (feet >= 5 && feet <= 11)//if feet is between 5 and 11
{
cout << "SCORE; determining points" << endl;// randomly choose amount of assist
int question = rand() % 4;
switch (question)
{
case 1:
cout << "no assist 10 points" << endl;
score = score + 10;
break;
case 2:
cout << "1 assist 20 points" << endl;
score = score + 20;
break;
case 3:
cout << "2 assist 30 points" << endl;
score = score + 30;
break;
case 4:
cout << "3 assist 40 points" << endl;
score = score + 40;
break;
}
cout << "your score is: " << score << endl;
}
else
{
//gradient of robot shooting range if misses
cout << "your score is: " << score << endl;
cout << "MISS, try to move ";
if (feet < 5)//if between 1 and 4
{
cout << "back" << endl;
}
elseif (feet > 11)//if between 12 and 60
{
cout << "forward" << endl;
}
}
}
}
}
//FRC Robot Simulator
//Press the up arrow to move forward
//Press the down arrow to move back
//Press the left mouse to fire
//Press the R key to reset
//(up arrow)
//robot is moving toward the goal
//robot is X feet away form the goal
//(feet = 5-11)
//SCORE; determining points
//(random)
//your score is: X
//FRC Robot Simulator
//Press the up arrow to move forward
//Press the down arrow to move back
//Press the left mouse to fire
//Press the R key to reset
//(down arrow)
//robot is moving away from the goal
//robot is X feet away form the goal
//(feet = 5-11)
//SCORE; determining points
//(random)
//your score is: X
//FRC Robot Simulator
//Press the up arrow to move forward
//Press the down arrow to move back
//Press the left mouse to fire
//Press the R key to reset
//(up arrow)
//robot is moving toward the goal
//robot is X feet away form the goal
//(feet != 5-11)
//your score is: X
//MISS, try to move
//(feet = 1-4)
//back
//FRC Robot Simulator
//Press the up arrow to move forward
//Press the down arrow to move back
//Press the left mouse to fire
//Press the R key to reset
//(up arrow)
//robot is moving toward the goal
//robot is X feet away form the goal
//(feet != 5-11)
//your score is: X
//MISS, try to move
//(feet = 12-60)
//foward
//FRC Robot Simulator
//Press the up arrow to move forward
//Press the down arrow to move back
//Press the left mouse to fire
//Press the R key to reset
//(down arrow)
//robot is moving toward the goal
//robot is X feet away form the goal
//(feet != 5-11)
//your score is: X
//MISS, try to move
//(feet = 1-4)
//back
//FRC Robot Simulator
//Press the up arrow to move forward
//Press the down arrow to move back
//Press the left mouse to fire
//Press the R key to reset
//(up arrow)
//robot is moving toward the goal
//robot is X feet away form the goal
//(feet != 5-11)
//your score is: X
//MISS, try to move
//(feet = 12-60)
//foward
//FRC Robot Simulator
//Press the up arrow to move forward
//Press the down arrow to move back
//Press the left mouse to fire
//Press the R key to reset
//(R key)
//robot is in the center of the feild