Trying to create a simple battle menu game with a random number genarator from 1-10 for the extra hit points. but when i have tried to combined the users command from either 1 or 2 it says that i haven't created the number generator and its not clarified yet. Is there anything i am doing wrong or have to change.
#include <time.h> // for time()
#include <stdlib.h> // for system()
#include "pch.h"
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <math.h>
#include <string>
using namespace std;
float userAnswer;
int generateRandomValue() {
int range = (10 - 1) + 1;
// establash 'window' size
return rand() % range + 1;
// slide the window
}
int main() {
cout << "Player HP: " << endl; // *addiing hit points for player should be 100
cout << "Enemy HP : " << endl; // ** " "
cout << "Select an action..." << endl; // this is already set
cout << "1.) Attack" << endl; // *** set 1 as attack and combined the random value gen to it
cout << "2.) Heal" << endl; // **** set 2 as heal option to heal player also random value gen to it
cout << ":";
cin >> userAnswer; // where the user will place there answer
cout << userAnswer;
return 0;
}
The code builds out fine, there is no error message with it. All that i am trying to do is take the "userAnswer" (either 1 or 2) and then it takes that and makes a random number and that then displays the number of hit points the player deals.