robot

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#include <iostream>
#include <windows.h>
#include <conio.h>
#include <cstdlib>
#include <string>

using namespace 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;
				}
				else if (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 
Last edited on
i fixed it


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#include <iostream>
#include <windows.h>
#include <conio.h>
#include <cstdlib>
#include <string>

using namespace 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;
				}
				else if (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 


Topic archived. No new replies allowed.