Qbasicnews.com

Full Version: Banned from Midgaard
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to create a text-based adventure game, and I'm right now planning a structure for the application. I was thinking of a database of some kind with all location descriptions, enemies and items in it. I have tried to make a few different structures, but when it comes up to testing them, there is always something bugging. Now, I would like to hear in what way you would have done this project. No, I don't want any code, just lemme hear in what way you would have constructed such an application.
http://www.geocities.com/pisforpi/eng.htm

It's very discombobulated.

I updated some of it recently, but haven't uploaded it yet.

Keep in mind that I've seen sort of abandoned it.

Hopefully that will give you some more ideas.
Quote:No, I don't want any code, just lemme hear in what way you would have constructed such an application.

For anything that's static but the player can still interact with (ie, switches, signposts, shopkeepers, etc...) have a section of your main array for. So if the map is 80x30, you can have 1 byte for the ascii char being displayed, one byte for the colour, and then two bytes that indicate a look-up value for whatever item it is that's there.

For anything that moves (npcs, baddies, furries, projectiles) have a separate array with a set maximum of like 50 at once, where there's a bit that tags whether it's active or not, and then other bytes that store onscreen position and attributes.

Then when you draw your screen to the buffer, you write first everything that's in the 'board' array, and on top of that cycle through the other array and plop down everything in its current position.

Honestly, though, if you have really great creative ideas and you're getting bogged down with the code, I recommend using MegaZeux. It's by Gregory Jansen and it's got more features for text-based adventures that you could ever need or imagine. And there's tons of great examples out there.
I think he's referring to more of a Zork type game than a Megazeux (which rocks) or Rogue style game. If I'm wrong.. disregard my post, Neoneh. :wink:

Anyways, I've worked on several such engines (Zork/MUD typed games) in QB before and always stop because I just lose interest. I have one on my HD with working areas/scripts but never got around to rocks or NPCs. So.. here's in general the types I would construct:

RoomArray(1 to MaxRoomsinArea)
-Name
-Desc --- (Tricky part. Depending on how descriptive you want your rooms, you might have to do some hacking. I prefer longer descs and always ran into memory limitations. If you want small descs, just do like Desc AS STRING * 50 or whatever and split it up when you format it to the screen. You could also do like Desc1, Desc2, etc. to break it up into lines manually. Or, one time I just didn't have a room for descs and loaded it up from a desc file as I went along. File access routines would be a little slower... but it's a freaking text game. Didn't slow me down any. :wink: )
-Exits (1 TO 4) AS INTEGER (Here I just have an integer array that has the room number for each exit. 1 = North, 2 = East, etc. You can of course add more if you want up/down or non-cardinal directions, which I've done. What I've done in the past is make an actual exit type to handle its destination room and doors/special exit types.)
-Now, as I said, my most recent doesn't have NPCs or items yet, but I've theorized a little on how to get them to be in the room. You can try an array, but you'll have to then limit how many of each can be in a room. No biggie as long as you don't want your char to be able to drop his whole inventory in one space. Array would be the easiest, just having like ItemInRoom(1 TO 5) AS INTEGER and that referring to the item info for that item number. This wouldn't work, though, if you want to have items be modifiable. If that's the case, make an ItemInRoom TYPE that has its index number and then a string that stores its modifications (would take a small amount of code work, but it'd be the best way imo). The other way to handle stuff in the room would again be to use a string, like ItemInRoom AS STRING * Whatever. Not being able to have unlimited strings sucks. In fact, it might be better on memory just to have a larger array of integers than a larger string variable. I'm not quite sure...
-Flags (Maybe a string to handle room flags.)

ItemArray(1 TO MaxItemNumber)
-Name
-Type (light, weapon, armor, etc.)
-Val(1 TO Whatever) AS INTEGER (Values would hold things you'd want depending on type. Maybe first could be weight, then Val(2) for armor could be AC bonus while for weapon it could be number of dice while Val(2) could be type of dice for attack (i.e. 2d6). Whatever you want really.)

NPCArray(1 TO MaxNPCNumber)
-Name
-Flags? (Need to know if it's aggressive, has special attributes, maybe runs a certain script?)
-HP (Can always do random hp by having like HP(1 to 3) as integer with the first being number of dice, second being dicetype, third being base.. like 13d10 + 153.)
-EXP?
-Whatever else you want.

I've done a lot of MUD programming and must say it seems simpler to do in C just because of some data types and no memory limitation as in QB. It can be done, though. Things you want to keep in mind would be do you need to load the whole world into memory at once? I find loading it area by area based on need works easier. Also, should are you going to just load the item/NPC data and store it in an array and then have another array for items and NPCs in the game? That's gonna take twice the memory but will allow you to spawn multiple types of the same one. I already mentioned an easier way to do it for items, though for NPCs it's a little trickier since there's more that can chance (flags, hp dice, stats, whatever else you want them to have).

I'm going to stop here, because I'm not entirely sure if I'm answering your question properly or not. Post on here if any of this is helpful, and if so what other questions did you have or how else might I help you?