-
Just wondering.
On my on-going game project for school I have come to a slight halt with the design.
I am making the game so it generates a randon number 1, 2 or 3 and this selects a story.
I was wondering if there is a way I can have a kind of 'go to' which goes to a certain place within any other .cpp file (e.g. story 1.cpp, story2.cpp, etc) if the user selects the story or do I have to keep it within 1 file.
If there is an option which would be more practical?
Thanks
-
You can make functions. Declare the functions in a header, implement them in separate files. Then switch on the number to select the function to call.
Or implement a simple story interpreter and write the stories in completely separate text files. :)
-
ummm ok then Haha.
Well I have interaction in it, such as math functions, choices etc, so Im not sure how a story interp will work. although riting the story parts in a text file aint half bad idea!
-
Example (if you want to go that far):
Code:
mainroom {
description {You are standing in the middle of a room ...}
west: hallway
east: outside
}
hallway {
description {This seems to be a deserted hallway...}
east: mainroom
}
...
It sounds like that might be a little too difficult for you to implement at the moment, but it's something for you to keep in mind for future projects. :)
-
Yeah slightly, I am pretty new to this :)
So I could make a function for each story in a external page and then call it into the main file when needed? Or write parts of the story into functions and call them..
-
Right. Using different files is just something that is convenient for you (the programmer), and allows you to modularize the program (object files). So the main idea here is that your different stories are different functions. You could then define these functions wherever you like... in one file, in several files...