Bool Function Examples, Please!

So I'm working on a program for school and we need to make use of a bool function.

The function must: prompt the player for input, variables to input the numbers that the player has put in (floats for 'angle' and 'speed'), a string for an error (like if the player puts in an invalid number).

This function must do all of this and be a boolean function.

I'm looking for examples of how I can use a bool function to do all of this and return all of this info into the main function.

This boolean function has to return whether the player put in a zero at anytime (this will cause the game to end) or not (the game continues on).

I'm not looking for someone to just give me the answers, as I'd like to figure it out so that I understand it. But an example or two would be helpful as I'm just a little stuck here.

It's all a modification of a previous project that gets the player to input an angle and the speed of a projectile. Then it calculates whether the player hit the target or not. And continues until the player hits the target.
1
2
3
4
5
6
7
8
9
10
11
bool InputIsZero() {
    int a;
    
    cout << "Enter an integer: ";
    cin >> a;
    
    if ( a == 0 )
        return true;    

    return false;
}


The function asks the user to input an integer. If this integer is 0, the function returns true to the caller, otherwise it returns false.

here's some pseudo:
1
2
3
4
5
6
7
8
9
10
11
12
bool myFunc(int& angle, int& speed)
{
   //while(){
   //cin -> angle
   //if(angle != float)
   //{  cout -> invalid input please try again}
   //else{ //we do have a valid angle
   //      if(angle == 0) {return 0;}
   // break;} } //end else, end while
//same idea with speed
return 1;//if both succeed
}
Last edited on
These examples really help!

But how would I have this bool function also prompt the user for input.

ie. "Enter an angle: "
"Enter the speed from 1-10: "

I get how to collect this info, but I guess I'm confused on how to make sure that whatever is inputted into this bool function can then be used in the main function.

bool (string sAskUser, string sInvalidInput, float fSpeed, int iAngle)

It seems that whenever I do something in any other function besides main(), I get these errors that these variables are not being initialized in the main(), but I want those variables to carry over what they became while in the other functions.
This is what I'm working with right now. And at the point that the code is at right now, when I run the program, it completely skips over "Getting the Angle".

Help!

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
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>

using namespace std;

bool GetPlayerInput( string sPrompt, int& iPlayerAngle);

int generateRandomNumber( int random );

int main()
{
	int iPlayerAngle; // ask the player for an initial angle
	float fPlayerSpeed, fProjectile; //ask the player for an initial speed
	float fDistanceFormula = 0; // X value for calculating the distance traveled
	int iTries = 0; // tries the player has made
	int iRandom = 0; // varying the Target by getting user input to generate a random number
	int iNumbersAdded; // used in calculating the target distance
	float fRandNumber = 0; // the distance of the target
	

	cout << "Welcome to the Text-Based Artillery Game!";
	cout << "\n\nPut '0' in response to Angle or Speed to exit the program.";

	/* Calculating a "Random" Number for the Target's distance */

	generateRandomNumber(iRandom);


	do //Game Loop Beginning
	{
		

		
		/*******  Get Angle *********/

		bool GetPlayerInput( "enter an angle: ");

		/*cout << "\n\nChoose an angle of 15, 30, 45, 60, or 75: ";
	
		do
		{
			cin >> iPlayerAngle;

			if( iPlayerAngle > 0, iPlayerAngle < 90, (iPlayerAngle % 15) == 0 )
				if( iPlayerAngle == 0)
					return 0;
				else
					break;
			else
				cout << "\nThat's not a valid angle. It must be one of the five given values: ";
			
	
		} while( iPlayerAngle <= 0, iPlayerAngle > 90, (iPlayerAngle % 15) != 0 );

		*/


		/******** Get Speed **********/

		cout << "\nNow choose an initial speed from 1 - 10: ";

		do
		{
			cin >> fPlayerSpeed;

			if( fPlayerSpeed >= 1.0, fPlayerSpeed <= 10.0 )
				if( fPlayerSpeed == 0 )
					return 0;
				else
					break;
			else
				cout << "\nThat is not a valid speed. It must be between 1.0 and 10.0.";

		} while( fPlayerSpeed = 0, fPlayerSpeed < 1.0, fPlayerSpeed > 10.0 );


		/******** get X value for Distance Formula *********/

		switch( iPlayerAngle )
		{
		case 15:
			fDistanceFormula = 0.5;
			break;
		case 30:
			fDistanceFormula = 0.866;
			break;
		case 45:
			fDistanceFormula = 1.0;
			break;
		case 60:
			fDistanceFormula = 0.866;
			break;
		case 75:
			fDistanceFormula = 0.5;
			break;
		}


		/******* Calculate the distance the projectile flew ***********/

		fProjectile = fPlayerSpeed * fPlayerSpeed * fDistanceFormula / 10;

		cout << "\n\nYour projectile flew a total distance of: \n\n" << fProjectile;
		++iTries;

		

	} while( (fProjectile < (iRandom - 0.5)) || (fProjectile > (iRandom + 0.5)) ); // Game Loop End

	
	
	iTries == 1 ?  cout << "\n\nYou got the target in 1 try!" : cout << "\n\nIt took you " << iTries << " tries to get the Target!";



	std::cin.sync();
	std::cin.get();
	return 0;
}

int generateRandomNumber( int random )
{
	srand( time( NULL ));

	int iRandom = ( rand() % 9) + 1;

	cout << "\n\nThe target is a distance of " << iRandom << " away.";

	cout << "\n\nTry to get a distance between " << ( iRandom - 0.5 );
	cout << " and " << (iRandom + 0.5); 

	

	return (iRandom);
}

bool GetPlayerInput( string sPrompt, int& iPlayerAngle)
{
	cout << sPrompt;

		do
		{
			cin >> iPlayerAngle;

			if( iPlayerAngle > 0, iPlayerAngle < 90, (iPlayerAngle % 15) == 0 )
				break;	
			else
				cout << "\nThat's not a valid angle. It must be one of the five given values: ";
				
			
	
		} while( iPlayerAngle <= 0, iPlayerAngle > 90, (iPlayerAngle % 15) != 0 );

		return 0;
}
Last edited on
Okay, I've done some experimenting/realized a mistake or two... here's the update. I now have the angle section in the bool function. And it would appear to work. Now, the math for it all is messed up. I keep getting ridiculously low numbers after inputting the angle and speed. Not sure what to do now...

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
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <math.h>

using namespace std;

#define M_PI (Radians = Degrees*M_PI / 180);

bool GetPlayerInput( string sPrompt, string sError, int& iPlayerAngle);

int generateRandomNumber( int& iRandom );

int main()
{
	int iPlayerAngle; // ask the player for an initial angle
	float fPlayerSpeed, fProjectile; //ask the player for an initial speed
	float fDistanceFormula = 0; // X value for calculating the distance traveled
	int iTries = 0; // tries the player has made
	int iRandom; // varying the Target by getting user input to generate a random number
	int iNumbersAdded; // used in calculating the target distance
	float fRandNumber = 0; // the distance of the target
	

	cout << "Welcome to the Text-Based Artillery Game!";
	cout << "\n\nPut '0' in response to Angle or Speed to exit the program.";

	/* Calculating a "Random" Number for the Target's distance */

	generateRandomNumber(iRandom);


	do //Game Loop Beginning
	{
		

		
		/*******  Get Angle *********/

		GetPlayerInput( "\nEnter an angle: ", "\nThat is not a valid angle, try again: ", iPlayerAngle);

		/*cout << "\n\nChoose an angle of 15, 30, 45, 60, or 75: ";
	
		do
		{
			cin >> iPlayerAngle;

			if( iPlayerAngle > 0, iPlayerAngle < 90, (iPlayerAngle % 15) == 0 )
				if( iPlayerAngle == 0)
					return 0;
				else
					break;
			else
				cout << "\nThat's not a valid angle. It must be one of the five given values: ";
			
	
		} while( iPlayerAngle <= 0, iPlayerAngle > 90, (iPlayerAngle % 15) != 0 );

		*/


		/******** Get Speed **********/

		cout << "\nNow choose an initial speed from 1 - 10: ";

		do
		{
			cin >> fPlayerSpeed;

			if( fPlayerSpeed >= 1.0, fPlayerSpeed <= 10.0 )
				if( fPlayerSpeed == 0 )
					return 0;
				else
					break;
			else
				cout << "\nThat is not a valid speed. It must be between 1.0 and 10.0.";

		} while( fPlayerSpeed = 0, fPlayerSpeed < 1.0, fPlayerSpeed > 10.0 );


		/******** get X value for Distance Formula ********

		switch( iPlayerAngle )
		{
		case 15:
			fDistanceFormula = 0.5;
			break;
		case 30:
			fDistanceFormula = 0.866;
			break;
		case 45:
			fDistanceFormula = 1.0;
			break;
		case 60:
			fDistanceFormula = 0.866;
			break;
		case 75:
			fDistanceFormula = 0.5;
			break;
		}
		*/

		/******* Calculate the distance the projectile flew ***********/

		fProjectile = fPlayerSpeed * fPlayerSpeed * sin (2 * iPlayerAngle) / 10;

		cout << "\n\nYour projectile flew a total distance of: \n\n" << fProjectile;
		++iTries;

		

	} while( (fProjectile <= (iRandom - 0.5)) || (fProjectile >= (iRandom + 0.5)) ); // Game Loop End

	
	
	iTries == 1 ?  cout << "\n\nYou got the target in 1 try!" : cout << "\n\nIt took you " << iTries << " tries to get the Target!";



	std::cin.sync();
	std::cin.get();
	return 0;
}

int generateRandomNumber( int& iRandom)
{
	srand( time( NULL ));

	iRandom = ( rand() % 9) + 1;

	cout << "\n\nThe target is a distance of " << iRandom << " away.";

	cout << "\n\nTry to get a distance between " << ( iRandom - 0.5 );
	cout << " and " << (iRandom + 0.5); 

	

	return iRandom;
}

bool GetPlayerInput( string sPrompt, string sError, int& iPlayerAngle)
{
	cout << sPrompt;

		do
		{
			cin >> iPlayerAngle;

			if( iPlayerAngle >= 0, iPlayerAngle <= 90)
				break;	
			else
				cout << sError;
				
			
	
		} while( iPlayerAngle <= 0, iPlayerAngle >= 90);

		return iPlayerAngle;
}
On many of your ifs and while conditions you use the comma operator, when that is not what you want to do.

Take:

142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
bool GetPlayerInput( string sPrompt, string sError, int& iPlayerAngle)
{
	cout << sPrompt;

		do
		{
			cin >> iPlayerAngle;

			if( iPlayerAngle >= 0, iPlayerAngle <= 90)
				break;	
			else
				cout << sError;
				
			
	
		} while( iPlayerAngle <= 0, iPlayerAngle >= 90);

		return iPlayerAngle;
}


is equivalent to:

142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
bool GetPlayerInput( string sPrompt, string sError, int& iPlayerAngle)
{
	cout << sPrompt;

		do
		{
			cin >> iPlayerAngle;

			if(iPlayerAngle <= 90)
				break;	
			else
				cout << sError;
				
			
	
		} while(iPlayerAngle >= 90);

		return iPlayerAngle;
}


And I suspect it should look more like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// returns false if player entered 0 for iPlayerAngle,
// true if player did not.
bool GetPlayerInput( string sPrompt, string sError, int& iPlayerAngle)
{
    do
    {
        cout << sPrompt ;
        cin >> iPlayerAngle ;

        if ( iPlayerAngle == 0 )
            return false ;

        if ( iPlayerAngle < 0 || iPlayerAngle > 90 )
            cout << sError ;

    } while ( iPlayerAngle < 0 || iPlayerAngle > 90 ) ;

    return true ;
}
Thanks for the tip!

Did some more work on it.

We have to use this function set up:

bool GetPlayerInput(string sPrompt, string sError, float fMin,
float fMax, float &fResult)


That function has to work the Angle and Speed. I'm still not getting how this works. Any ideas?

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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*

Using user input, calculates a "random" target distance. Then using user inputs
for the angle and speed of their projectile, calulcates if the target was hit, if not, the input is 
gathered again until the target is hit.

*/




#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <math.h>

using namespace std;

#define M_PI (Radians = Degrees*M_PI / 180);

bool GetPlayerInput( string sPrompt, string sError, float& fResult, float& fMin, float& fMax);

int generateRandomNumber( int& iRandom );

int main()
{
	//float fPlayerAngle; // ask the player for an initial angle
	float fProjectile; //ask the player for an initial speed
	float fDistanceFormula = 0; // X value for calculating the distance traveled
	int iTries = 0; // tries the player has made
	int iRandom; // varying the Target by getting user input to generate a random number
	int iNumbersAdded; // used in calculating the target distance
	float fRandNumber = 0; // the distance of the target
	float fResult;
	float fMin;
	float fMax;
	

	cout << "Welcome to the Text-Based Artillery Game!";
	cout << "\n\nPut '0' in response to Angle or Speed to exit the program.";

	/* Calculating a "Random" Number for the Target's distance */

	generateRandomNumber(iRandom);


	do //Game Loop Beginning
	{
		

		
		/*******  Get Angle *********/

		GetPlayerInput( "\nEnter an angle: ", "\nThat is not a valid angle, try again: ", fResult, fMin, fMax);

		float fPlayerAngle;
		fPlayerAngle = fResult;

		/*cout << "\n\nChoose an angle of 15, 30, 45, 60, or 75: ";
	
		do
		{
			cin >> iPlayerAngle;

			if( iPlayerAngle > 0, iPlayerAngle < 90, (iPlayerAngle % 15) == 0 )
				if( iPlayerAngle == 0)
					return 0;
				else
					break;
			else
				cout << "\nThat's not a valid angle. It must be one of the five given values: ";
			
	
		} while( iPlayerAngle <= 0, iPlayerAngle > 90, (iPlayerAngle % 15) != 0 );

		*/


		/******** Get Speed **********/

		GetPlayerInput ("Enter a speed from 1-10: ", "That is not a valid speed. It must be from 1.0 and 10.0: ", fResult, fMin, fMax);

			float fPlayerSpeed;
			fPlayerSpeed = fResult;

	/*	cout << "\nNow choose an initial speed from 1 - 10: ";

		do
		{
			cin >> fPlayerSpeed;

			if( fPlayerSpeed >= 1.0, fPlayerSpeed <= 10.0 )
				if( fPlayerSpeed == 0 )
					return 0;
				else
					break;
			else
				cout << "\nThat is not a valid speed. It must be between 1.0 and 10.0.";

		} while( fPlayerSpeed = 0, fPlayerSpeed < 1.0, fPlayerSpeed > 10.0 );

*/
		/******** get X value for Distance Formula ********

		switch( iPlayerAngle )
		{
		case 15:
			fDistanceFormula = 0.5;
			break;
		case 30:
			fDistanceFormula = 0.866;
			break;
		case 45:
			fDistanceFormula = 1.0;
			break;
		case 60:
			fDistanceFormula = 0.866;
			break;
		case 75:
			fDistanceFormula = 0.5;
			break;
		}
		*/

		/******* Calculate the distance the projectile flew ***********/

		fProjectile = fPlayerSpeed * fPlayerSpeed * sin (2 * fPlayerAngle) / 10;

		cout << "\n\nYour projectile flew a total distance of: \n\n" << fProjectile;
		++iTries;

		

	} while( (fProjectile <= (iRandom - 0.5)) || (fProjectile >= (iRandom + 0.5)) ); // Game Loop End

	
	
	iTries == 1 ?  cout << "\n\nYou got the target in 1 try!" : cout << "\n\nIt took you " << iTries << " tries to get the Target!";



	std::cin.sync();
	std::cin.get();
	return 0;
}

int generateRandomNumber( int& iRandom)
{
	srand( time( NULL ));

	iRandom = ( rand() % 9) + 1;

	cout << "\n\nThe target is a distance of " << iRandom << " away.";

	cout << "\n\nTry to get a distance between " << ( iRandom - 0.5 );
	cout << " and " << (iRandom + 0.5); 

	

	return iRandom;
}

bool GetPlayerInput( string sPrompt, string sError, float& fResult, float& fMin, float& fMax)
{
	
		do
		{
			fMin = 0;
			fMax = 90;

			cout << sPrompt;
			cin >> fResult;

			if( fResult == 0 )
				return false;

			if( fResult < fMin || fResult > fMax )
				cout << sError;
				
		} while( fResult < fMin || fResult > fMax);

		return true;

		do
		{
			fMin = 1.0;
			fMax = 10.0;

			cout << sPrompt;
			cin >> fResult;

			if( fResult == 0 )
				return false;
			
			if( fResult < fMin || fResult > fMax )
				cout << sError;

		} while( fResult >= fMin || fResult <= fMax );

		return true;
}
As it pertains to functions, if I use the '&' symbol in front of the variables within a function, will the values of those variables be carried over to the main function?

That's what I'm trying to do right now. I want to make sure that fResult is actually returning back with the player given value into the main function and then being transferred into the fPlayerAngle that's in the main(), right under where I call the first 'GetPlayerInput' function.

Maybe someone can help clear this up for me??
you should fix this too...
#define M_PI (Radians = Degrees*M_PI / 180);


what are you're try to do with this?
Well we had an assignment last week to create this text based artillery game. This week, we have to take that code and modify it. We have to make a function that prompts the player for input (angle and speed), will show an error if the player inputs an invalid number, and this function has to be a bool function that will return a value for if the player hit '0' in order to quit the game, or not.

It's rather overwhelming.
I've updated the code after doing some more work on it.

I still haven't figured out how I can make the program end when the player inputs '0' for either the angle or the speed.

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

/*
Using user input, calculates a "random" target distance. Then using user inputs
for the angle and speed of their projectile, calulcates if the target was hit, if not, the input is 
gathered again until the target is hit.

*/


#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
#include <math.h>

using namespace std;

#define M_PI (Degrees = Radian * (PI/180));

bool GetPlayerInput( string sPrompt, string sError, float& fResult, float& fMin, float& fMax);

int generateRandomNumber( int& iRandom );

int main()
{

	float fProjectile; //ask the player for an initial speed
	int iTries = 0; // tries the player has made
	int iRandom; // varying the Target by getting user input to generate a random number
	float fResult;
	float fMin;
	float fMax;
	

	cout << "Welcome to the Text-Based Artillery Game!";
	cout << "\n\nPut '0' in response to Angle or Speed to exit the program.";

	/* Calculating a "Random" Number for the Target's distance */

	generateRandomNumber(iRandom);


	do //Game Loop Beginning
	{
		

	
		/*******  Get Angle *********/

		GetPlayerInput( "\nEnter an angle: ", "\nThat is not a valid angle, try again: ", fResult, fMin=0, fMax=90);

		float fPlayerAngle;
		fPlayerAngle = fResult;




		/******** Get Speed **********/

		GetPlayerInput ("Enter a speed from 1-10: ", "That is not a valid speed. It must be from 1.0 and 10.0: ", fResult, fMin = 1.0, fMax =10.0);

			float fPlayerSpeed;
			fPlayerSpeed = fResult;



		/******* Calculate the distance the projectile flew ***********/

	


		fProjectile = fPlayerSpeed * fPlayerSpeed * sin(2 * fPlayerAngle * (3.1415 / 180) ) / 10;

		cout << "\n\nYour projectile flew a total distance of: \n\n" << fProjectile;
		++iTries;

	

	} while( (fProjectile <= (iRandom - 0.5)) || (fProjectile >= (iRandom + 0.5)) ); // Game Loop End

	
	
	iTries == 1 ?  cout << "\n\nYou got the target in 1 try!" : cout << "\n\nIt took you " << iTries << " tries to get the Target!";



	std::cin.sync();
	std::cin.get();
	return 0;
}



int generateRandomNumber( int& iRandom)
{
	srand( time( NULL ));

	iRandom = ( rand() % 9) + 1;

	cout << "\n\nThe target is a distance of " << iRandom << " away.";

	cout << "\n\nTry to get a distance between " << ( iRandom - 0.5 );
	cout << " and " << (iRandom + 0.5); 

	

	return iRandom;
}

bool GetPlayerInput( string sPrompt, string sError, float& fResult, float& fMin, float& fMax)
{
	
		do
		{

			cout << sPrompt;
			cin >> fResult;

			if( fResult = 0 )
				return false;

			if( fResult < fMin || fResult > fMax )
				cout << sError;
				
		} while( fResult < fMin || fResult > fMax);


		return ( fResult >= fMin || fResult <= fMax ) ? true : false;


}


Line 119 is an assignment =

1
2
3
4
5
//this will work but it's bad design for a bigger project...
if( fResult == 0 )
{
   exit(1);
}

It'd be better to check the value of fResult on line 51 and 61.


Also, there's an elaborate return at the end of the bool function but that return value is never handled in main()
Last edited on
I guess right now I'm just frustrated that no where in any of the two books I have for this class is there a deep discussion and examples of boolean functions like the one I now have to make.

Questions:
1. Projectile Calculation: The math for this thing seems very broken. I'm not sure that I'm converting radians to degrees properly or if sin is being used the right way. Can someone offer some assistance on that?

2. Bool Function: I seem to have no idea how to make this return value work. I need to at some point here have a return value that will exit the game if the player inputs '0' for fResult.


I feel like I keep working on this and reading and testing and I'm just sinking deeper into uncertainty and a land of wrong. Help!
2. Bool Function: I seem to have no idea how to make this return value work. I need to at some point here have a return value that will exit the game if the player inputs '0' for fResult.


I've seen you say this a couple times now and I have to say there is no way to have a return value that will exit the game if the player inputs '0'.

What you can do is check the return value, and if it's the value indicating the user input a '0' then take action accordingly, but you must check the return value or there isn't really a point to having one, is there?


Last edited on
Topic archived. No new replies allowed.