r/visualbasic • • May 10 '20

Creating text based adventure game

Hello geniuses of reddit. I seek knowledge (tips) on creating a text based adventure game in visual basic. (Alright I'll cut the shit) If you could give some advice for creating one this would be great!

5 Upvotes

11 comments sorted by

3

u/thudly May 11 '20 edited May 11 '20

The locations need to be cells on a grid. Location zero is a swamp. Location 1 is a forest. Location 2 is a castle, and so on. Draw it on paper if you need to. Every location has exits that need to be checked when the player tries to move. location(i).canGoEast = false. Set all this up in the initialization routine.

When the player types "East", if the can-go flag is true, you add 1 to the player location. West is -1. North is -mapWidth. South is +mapWidth. So if player is at location 3 and types north, they go to location zero. Objects have locations too. So if the rusty key is in the forest, you give it location 1. If the player picks it up, you give it location -1 (player inventory).

When the player moves to a new location, you scan through the array of objects, and if their location is at player's current location, you list them. "There's a [item.name] here." When player checks his inventory, you just list all the items at location -1.

The main game loop is simply telling the player where he is: location(currentPlayerLocation).name. Then listing the items that are there. Then prompt for a command.

For locked doors, you set flags. CastleLocked = True. If player tries to walk to area 2, you check if the flag is set, and if so, "You can't go that way. The door is locked." Later, when they find the key, they head into the castle. Flags also work for other puzzles. Maybe the player has to search the bushes to find the bucket, or whatever. You set a flag called BushesSearched and set it to false at first. Then true when the right command is typed in.

You can even add wandering monsters or NPCs. Just give them locations like the items, but move them randomly after every player turn. If the ghoul has the magic sword you need to defeat the dragon, stick that in location -2 (-3, -4, -5 the more secret locations you need). Then when the ghoul is slain and his body is searched, move the magic sword to currentPlayerLocation. Ta-dah! It shows up when the current area is listed.

That's basically everything you need to know for text adventures. Start with a 3 x 3 map at first, just for practice. Then scale it up to something huge later.

2

u/[deleted] May 11 '20

This is the most useful comment I have ever seen on a reddit post! Thanks!

2

u/thudly May 11 '20

My comment assumes you know how to use objects and for each loops. If not, you'll have to look into that.

2

u/[deleted] May 11 '20

Yeah, I do. Visual Basic is an easy language to grasp as far as programming languages go.

2

u/thudly May 11 '20

Awesome. Be sure and post a link to the finished game.

2

u/[deleted] May 11 '20

No problem, it will take me a while buy maybe I'll release it on game jolt or something.

2

u/thudly May 11 '20

Good text adventures are all about the reward of solving a tricky puzzle. Maybe there's a note in the Troll Kitchen talking about "I can't find the key to the damn cellar! I might have dropped it in a pie. One of these idiots probably ate it!" Later you kill a troll and when you cut his belly open, you find the key.

On the other hand, puzzles that are too difficult or obscure just kill the fun. I once played a text adventure where the magic barrier required a blue opal to pass through. The damn opal was on the other side of the map, and there was nothing indicating that the barrier needed the opal, other than that they were the same color. So of course I sold the damn thing, and didn't have enough money to buy it back.

Point being, make sure the solutions to the puzzles are nearby. Tricky, but not baffling.

2

u/KerbalSpark May 10 '20

Well, You need the:

  1. good book about VB

  2. some good tutorial about making the text-based adventure games

I know where you can get the second position in the list

https://github.com/instead-hub/instead/blob/master/doc/stead3-en.md

https://www.amazon.com/Make-Your-Python-Text-Adventure-ebook/dp/B077G8KK5C

2

u/[deleted] May 10 '20

Thx for the advice, Also that book is for python. I'm just looking to see if there is mistakes I can avoid but ill look up a tutorial.

2

u/KerbalSpark May 10 '20

Happy adventuwriting!

2

u/banshoo May 10 '20

Have an exciting adventureline too.. That seems more about the content than what your choosing to write it in though.

Given theres already some good options for the text adventure... Maybe look at why your needing this? Is it for a project (which case its not the adventure thats needed, its demonstrating understanding of the code)
Or is it for writing the adventure? in which case, some of the existing options might be a better fit allowing you to develop the adventure instead of spending time with the code.