C++/Got some basic questions for ya
Hey, I'm learning C++ and I have a question. I'd like to be able to jump around in parts of my code, repeat parts of the program as desired, etc. What I have in mind is a RPGesque program-I've called it Quest for Awesome. The player chooses which monster they want to fight, then they can fight the monster. This part I've got programmed already. The problem is, as the game is Quest for Awesome, I'd like the player to be able to collect awesome to make there be some point to the game aside from smacking down monsters. I'm curious how I can take the variable of awesome from one function and retain it for all functions. I'd also like to know how to return to int main after doing a different function-the idea being that the user chooses a monster, fights the monster, accumulates awesome, then returns to the main screen where they can see how much awesome they have and pick the next monster to fight. I have absolutely no idea how to do this though. My knowledge of C++ is very basic-I know the basic functions of the iostream library, and I can do looping, if statements, and use strings but that's about it, so go slow :) Thanks!
BTW, in case it matters, the compiler I'm using is Turbo C++ by Boreland. Also, I don't have a compiler at home, so if there are some free ones out there on the web you'd recommend, that'd be extra awesome for you :)
I hope u'll be fine. For ur problems to be solved in a proper manner, u need to extend ur "basic knowledge" of c++ to atleast classes level. How to get a value from a function and retain it in other related funstions is a child's play (and in fact a part ) in object oriented programming(in object oriented programming, u use classes). It can also be done without using classes, but that would be non professional and inefficient too.
Second problem: how to return to int main function. This can't be done. Any program starts executing from the main function and terminates when the main function ends. So to solve ur problem, u need to define another function, say
that calls the other functions in the required sequence.
For example, ur StartGame function might look like
DisplayStartScreen();//a fn. that displays the basic //interface of ur program
Now that u have this type of function, u just need to call this function again when ur player wants to restart the game by choosing a new monster.
About ur compiler problem, i really don't know any such sites. U may want to search on the popular search engines for the free download.
Plz. feel free to ask a followup, if u need to.
Thanks for contacting me