|Syntactic Confectionery Delight|
Daft text adventure projectby Tiefling (Monk)
|on May 29, 2001 at 15:57 UTC||Need Help??|
Tiefling has asked for the wisdom of the Perl Monks concerning the following question:
I am presently undertaking what will forever after be known as 'Tiefling's daft text adventure project'. I am well aware that the advice of many here will be simply 'don't'. I am not deterred. :-)
Some time ago, I wrote a simple text adventure in QBasic, and I was heartily pleased with it. I expanded it, incorporating a rudimentary combat system, and experience, so that it became a crude but playable RPG. But the incoporation of moving monsters made the code elephantine, and DATA lines were overflowing the code size allowed by the free version of QBasic. So I re-wrote the thing from the start. This time I used lots of data files, and used a pointed to move groups of monsters in serial rotation. It coped fine with the file of 1800+ rooms, 200+ objects, and the like, but I was tired of having to read every data item from disk. And then, before the new combat system had been coded, I overran the code size again, and also started getting other spurious, Gates-oriented errors.
I threw up my hands and asked a hacker friend what I should do.
'Use Perl,' he said 'because it has nice, friendly text-handling, which you need lots of, and moreover, you already have it on the Linux dual-boot I set up for you.'
'Excellent!' I said, and set to learning Perl. I studied the wisdom of merlyn, and began to grasp the wonders of the Rubbish Lister.
Then I returned to the text adventure. I managed to write code to convert my Basic-friendly data files to Perl-friendly ones. (I'd used '/' as a list delimiter - what was I thinking?) All went well. The 1800 rooms are now in a format that Perl will read, although I intend to modify that format later.
I got ambitious, and remain so. The new incarnation of the adventure will be a full port of Dungeons and Dragons Third Edition to Linux. (After all,
But (quite aside from the ludicrous scale of the project) there are a few problems. Traditionally, character generators for CRPGs have had a 'back' function, allowing you to ditch the results of the latest stage and start again with the data from the previous step. I'm trying to figure out a nice way of implementing this. Also, vast amounts of data (character races, skills, feats, spells) will be common to most areas of the code for one reason or another. Everyone says 'use strict'. This will, in my case, mean placing vast strings of my definitions at the head of my program. Is this either (a) normal or (b) avoidable?
I know that these are the queries of an ignorant, over-ambitious novice. But too often, the Right Way to Do X sends me to learn about references, which are all