Mail Archives: djgpp/1999/05/07/15:27:17
Message-ID: | <015d01be98be$eca81840$9979c897@oemcomputer>
|
From: | "joey barden" <barden AT bellatlantic DOT net>
|
To: | <djgpp AT delorie DOT com>
|
Subject: | Re: Adventure game
|
Date: | Fri, 7 May 1999 15:22:17 -0400
|
MIME-Version: | 1.0
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Mailer: | Microsoft Outlook Express 4.72.3110.1
|
X-MimeOLE: | Produced By Microsoft MimeOLE V4.72.3110.3
|
Reply-To: | djgpp AT delorie DOT com
|
Hey I have put a response to your message on newsgroup comp.os.msdos.djgpp.
It should tell you everything you need to know, if not e-mail me at
barden AT bellatlantic DOT net I did not send the posting to you b/c I want all the
other beginners to see it to b/c it has very important content.
-----Original Message-----
From: Christopher Nelson <paradox AT gye DOT satnet DOT net>
Newsgroups: comp.os.msdos.djgpp
To: djgpp AT delorie DOT com <djgpp AT delorie DOT com>
Date: Tuesday, May 04, 1999 11:20 AM
Subject: Adventure game
>
>
>>Hey im a beginner but i sorta wanna jump ahead and instead of e-mailing
for
>>everything i needed one at a time im doing them all at once!: I want to
>make
>>a little text-adventure game. I know how to output the text to the screen
>and
>>get the user input( i use cin and cout, i dont know any other way )but
>first
>>how would get input with spaces? Such as: Kill Enemy or Get Bottle? How
>would
>>i make those actions work? How do i use random things like...you go
north,
>>random to pick enemies or some items? How do i save the game to a dat file
>as
>>it goes along ( remembers dead enemies or picked up items, also how do i
>add
>>items to a var. like if i wanted to add a Bottle and a Box to items and
>then
>>output it)and save and load at the end(quit)?
>
>
>this isn't too much at all, really.
>the easiest way to get input like that would be to use getc() verses cin,
or
>just do cin characters, e.g.
>
>char c;
>
> cin >> c;
>
>then, you have a loop that gets each character in turn. when you read a
>newline (\n), you can go through the buffer that you've been saving in and
>see if the command is valid.
>
>alternatively, you can try to check each word as it is typed... meaning,
>when you detect a space, check the word against a list of commands. if the
>command is invalid, you might have a little status bar at the bottom that
>says so. (instead of just clearing the line and saying so where they're
>typing.)
>
>e.g:
>
>
>char cbuf[255]; // big command buffer
>int pointer=0; // start at beginning of buffer
>char cmnd_done=0, c;
>char cur_cmnd=0;
>
>
>do
>{
> if (kbhit())
>
>
> c=getc(stdin);
>
> switch(c)
> {
> case 32: // if it's a space, check to see what the command
>in the buffer
> //currently is
>
> cbuf[pointer]=0; //terminates the string so that
>we can strcmp it.
>
> if (cur_cmnd ==0)
> cur_cmnd = is_command(cbuf);
>
> // etc. you can do lots of interesting stuff
>here...
>
> break;
>
> case '\n':
> cbuf[pointer]=0;
> cmnd_done=1;
> break;
> default:
> cbuf[pointer++] = c;
> break;
>
> }
> }
>
>} while(!cmnd_done);
>
>
> anyway, something of the sort...
>
> -={C}=-
>
>
>
- Raw text -