Page 1 of 1

Newbie asks: Select from Files of Words to create strings

PostPosted: Mon Apr 16, 2012 10:00 pm
by ggesterGamePro99
One of my projects is a interactive story/game

where you can change all the outcomes of every scene and even the end of the story and the beginning
through what you say to other characters, affecting their feelings. and based on that they take revenge, come back to fight.. cry, whatever.

You push a key to create a dialog buble and the player actor says something..It is a random phrase created from a list of good words, bad words etc.
The lists would be in separate text files.


So my question is..Is it possible to create in Text Editor, files with a list of words and then have your game select random words from chosen file? in order to create a string to display in the dialog bubble.

Re: Newbie asks: Select from Files of Words to create string

PostPosted: Mon Apr 16, 2012 11:39 pm
by skydereign
File operations are allowed in C, and act similarly in gE. You have to use FILE* variables, and different file access functions. For instance you use fopen to open the actual file, and fscanf or fgets to read from a file. I suggest searching the forums for more detailed explanation of how it is done.