Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Text Adv. C++

39 views
Skip to first unread message

TimeCop221

unread,
Aug 3, 1998, 3:00:00 AM8/3/98
to
i want to create a c++ text adventure, and perhaps add a couple gfx to it
later. So here are my questions:

1) Is it possible to create a text adv. in c++?
2) If it is can some one email me a tutorial or tell me where to get one
3) Also, if you can send me a skeleton of a very small-small world

Thanks,
ED

Jonadab the Unsightly One

unread,
Aug 3, 1998, 3:00:00 AM8/3/98
to

TimeCop221 <timec...@aol.com> wrote in article
<199808031829...@ladder01.news.aol.com>...

> i want to create a c++ text adventure, and perhaps add a couple gfx to it
> later. So here are my questions:
>
> 1) Is it possible to create a text adv. in c++?

Quite possible. Quite difficult. I would suggest that you at least
consider using a system that already has a good text-adventure
library for it, such as the ones most of us use here. It depends on
your purpose for writing the thing, of course. If you are writing
it to make yourself a better c programmer you would probably want
to go ahead and do it in c (but see note below), but if you are
looking to write a text adventure and chose c because it just
came to mind as a language you like to work with, then you
might profit a great deal from examining another language or two.
(Inform, TADS, ...)

If you really do want to use c++, you will need to first spend a
great amount of time creating a good parser and so forth for it --
in which case I would recommend you look at the source code for
the Inform library to get an idea of the type of thing that is involved.
You would need to produce something equivalent to that library, only
in c or c++.

If you do write a good library in c++ or (better, IMO, because more
portable) ANSI c, I imagine it would see a lot of use if you released it,
particularly if you released the source with it.

Even a translation of the Inform library to c might be a
welcome thing, although it would need some additional features
to go with it -- an extra library to handle in c things
that are handled either by Inform or the z-machine rather
than the Inform library. (Examples include save game, restore
game, undo, and transcripting) You also would have to make some
changes to the algorithm of certain routines (ZRegion, for example).

> 2) If it is can some one email me a tutorial or tell me where to get one

I would suggest you read Craft of an Adventure, by Graham Nelson.
This is not so much about programming as game design, but I think
that is important, too.

Could someone post a URL for it here? I only know where to find the
MS-Word version.

> 3) Also, if you can send me a skeleton of a very small-small world

Not in c, I cannot.

Actually, the "skeleton of a very small-small world" would still
need to include a lot of the library mentioned above.

I hope I have not just totally disillusioned you and driven you
away from ever writing any IF.


--
Yr. Obd't & Humble Servant,
Jonadab the Unsightly One

----------------

Different expectations. Crash my Windoze laptop and I'll shrug, reboot
and carry on. Crash my Unix desktop and I'll dig out the debugger.
Crash my palmtop and I'll delete every application you've written from
my machines and *hate* you.

-- Bryan Scattergood

----------------

Send replies to username@isp, where username is jonadab
and isp is bright.net

The zerospam.com address works, but you get an ugly confirmation.

TimeCop221

unread,
Aug 4, 1998, 3:00:00 AM8/4/98
to
Thanks for the help Jonadab, but Im going to start IF later when I am more
familer with the language.

Thanks for the help anyways

Josh G.

unread,
Aug 4, 1998, 3:00:00 AM8/4/98
to
On 3 Aug 1998 18:29:04 GMT, timec...@aol.com (TimeCop221) wrote:

>i want to create a c++ text adventure, and perhaps add a couple gfx to it
>later. So here are my questions:
>
>1) Is it possible to create a text adv. in c++?

sure, you can ... but then you'd be compiling a game for one specific
system only. if you take the time to figure out one of the common
IF-programming languages like Inform or TADS, your game can be played
by many more people as it won't be platform-specific.

-josh g.
IF semi-newbie


Paul Francis Gilbert

unread,
Aug 4, 1998, 3:00:00 AM8/4/98
to
gies...@mts.NOSPAM.com (Josh G.) writes:

>-josh g.
>IF semi-newbie

I agree. Check out the newsgroup rec.arts.int-fiction for more information,
or check out the Interactive Fiction repository at ftp.gmd.de:/if-archive

--
Paul Gilbert | p...@yallara.cs.rmit.edu.au (The DreamMaster)
Bach App Sci, Bach Eng | The opinions expressed are my own, all my own, and
Year 5, RMIT Melbourne | as such will contain no references to small furry
Australia | creatures from Alpha Centauri.

George Caswell

unread,
Aug 4, 1998, 3:00:00 AM8/4/98
to
On 3 Aug 1998, Jonadab the Unsightly One wrote:

>
> TimeCop221 <timec...@aol.com> wrote in article
> <199808031829...@ladder01.news.aol.com>...

> > i want to create a c++ text adventure, and perhaps add a couple gfx to it
> > later. So here are my questions:
> >
> > 1) Is it possible to create a text adv. in c++?
>

Given that
a) most ZIP interpreters are coded in C and
b) C is a subset of C++
the answer must be 'yes'. Of course, the fact that those languages,
and most every other in common use are all Turing-equivalent doesn't hurt
either.

Whether its a good idea is another matter entirely. For a variety of
reasons I'd say it isn't. C++ can be and do a lot of things depending on
how you use it and what libraries you have - but on an IF project you
usually want portability and freedom of display options, which is simplest
when the whole game is in some interpreted form. Additionally it can be
quite handy to work in a language with a syntax that better supports the
things you want to do.

> If you do write a good library in c++ or (better, IMO, because more
> portable) ANSI c, I imagine it would see a lot of use if you released it,
> particularly if you released the source with it.
>

Well, you're wrong there. :) I can't think of a single saving grace
of C over C++ for anything higher-level than system programming, except,
like you say, portability. But portability is already sacrificed to some
extent even with C - data ranges, system calls, etc. Not to mention all
the incompatibilities with crappy compilers that aren't up to standard.
the ZIP sources are riddled with ugly #ifdefs to handle that stuff.
Anything coded in C++ can be coded in C, of course, but you usually end up
with a lot of pointers and special cases that the programmer shouldn't
have to deal with.

That and, of course, C++ includes a better standard library, full of
containers and algorithms that everyone already knows how to write and
that no one actually -should- have to write, especially for some silly IF
game.

> Even a translation of the Inform library to c might be a
> welcome thing, although it would need some additional features
> to go with it -- an extra library to handle in c things
> that are handled either by Inform or the z-machine rather
> than the Inform library. (Examples include save game, restore
> game, undo, and transcripting) You also would have to make some

I can't even fathom how much more difficult and ugly that would be in C
than it would be in C++. Of course, it's still much, much simpler and
less error-prone when you're in a well-controlled proprietary virtual
machine envrionment (memory and stack dump, all done, where in C or C++
you'd need special code in all the game objects, recursive calls on
save/restore, etc.)

> > 3) Also, if you can send me a skeleton of a very small-small world
>
> Not in c, I cannot.
>

I can... it's in two files... zip.tgz and inform.tgz. :)

Seriously, if you really want to do this, see how it's done already-
take a look at the Z-machine sometime.. That's as good an example as any
of how to handle the object tree, how to do some simple parsing, etc. The
best way I can think of for how to save the state when this is all coded
in C++ is something like this-- save all the immediately known state
variables, then traverse the object tree, calling a get_state function or
something and saving the vector data that is returned. When you restore,
each piece of data saved by an object should contain an identifier of the
object type and the data you need to reinitialize it. (Use some sort of
factory function to handle actual creation of the new object) This is a
little different than the Z-machine, which doesn't support dynamic
alllocation.

---GEC


Allen Garvin

unread,
Aug 4, 1998, 3:00:00 AM8/4/98
to
In article <Pine.OSF.3.96.980803...@wpi.WPI.EDU>,

George Caswell <timb...@wpi.edu> wrote:
Given that
a) most ZIP interpreters are coded in C and
b) C is a subset of C++

the answer must be 'yes'. Of course, the fact that those languages,
and most every other in common use are all Turing-equivalent doesn't
hurt either.

Turing equivalence is boring and mostly useless. I wish people would quit
throwing around the term around so much (though I note here it was just a
side reference). It says almost nothing about the difficulty of
implementation nor the capabilities of the language interacting with its
environment, which are 2 very key issues.

The best way I can think of for how to save the state when this is all
coded in C++ is something like this-- save all the immediately known
state variables, then traverse the object tree, calling a get_state
function or something and saving the vector data that is returned.
When you restore, each piece of data saved by an object should
contain an identifier of the object type and the data you need to
reinitialize it. (Use some sort of factory function to handle actual
creation of the new object)

The best way I could think of doing it (saves, undo's, restores) in C or C++
would be to make a simple virtual machine and byte-compile everything
to and then to... wait... arg, that's what we've already got in TADS and
Inform!

I made a now-lost text adventure in (pre-ansi) C nearly 10 years ago,
and eventually when I tried to add save and restore, found the problem
nearly intractable because I had just hacked the game from the ground
up without much forethought. The incredible mess of data structures and
global variables and special cases made it even more ugly than the rest
of the code. I got so bogged down on that aspect that I never finished
the game. To write a serious game in C or C++ really necessitates a lot
of forethought before any code is written. The original poster, since he
asked for tutorial or examples, probably doesn't want to go through all
that and would be better off with one of the pre-existing languages (however,
I can certainly see the temptation to set off and do the whole thing in
some language no one else has used, coding everything from scratch, but
people who think that is fun don't usually model their efforts off of
existing examples.)

--
Allen Garvin I think I'll
--------------------------------------------- Let the mystery be
eare...@faeryland.tamu-commerce.edu
http://faeryland.tamu-commerce.edu/~earendil Iris Dement

Darin Johnson

unread,
Aug 4, 1998, 3:00:00 AM8/4/98
to
eare...@faeryland.tamu-commerce.edu (Allen Garvin) writes:

> Turing equivalence is boring and mostly useless. I wish people would quit
> throwing around the term around so much (though I note here it was just a
> side reference). It says almost nothing about the difficulty of
> implementation nor the capabilities of the language interacting with its
> environment, which are 2 very key issues.

True. But large IF games have been written for Fortran too (and
without it being an exercise in in masochism). IF in C/C++ should be
straight forward and easy enough. Granted, people that don't know
Fortran or C, would be well advised not to try and leaarn those
languages by writing an IF game :-)

> I made a now-lost text adventure in (pre-ansi) C nearly 10 years ago,
> and eventually when I tried to add save and restore, found the problem
> nearly intractable because I had just hacked the game from the ground
> up without much forethought.

The hardest thing, in any language, is structuring things so the rest
of the implementation is easy (ie, getting proper support routines,
and an overall plan of how things will work).

For instance, I would hate having to take the Fortran or C version of
Dungeon and use it as a base to write a different game. It was
structured to be Dungeon specific, and game knowledge is squirreled
away everywhere you look.

There are really two main parts for a text IF game - parsing and
object representation.

--
Darin Johnson
da...@usa.net.delete_me

0 new messages