Jump to content
  • Advertisement
Sign in to follow this  
Syrena

Creating a Text Adventure Game

This topic is 861 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Greetings,

 

If this is the wrong forum for this topic, then please move it.

 

I was wondering if anyone could give me some guidance when it comes to having multiple cites in a text adventure game. I found this example from Google searching, and it's sort of what I have in mind. My problem is moving between cities and then in code, checking if the user as reached the next city. 

 

I guess it depends on how I'm going to design my cites. What I had in mind was that City would be a class, like this:

public class City
{
   private List<GameObject> buildings;
   private List<Character> people;
   private string cityName = String.Empty;
   
  public City()
  {
     cityName = "My New City"
     buildings = new List<GameObject>();
     //code to load buildings list
     people = new List<Character>();
     //code to load Character list
  }
  public void start() {}
  public void checkAction() {}
  public bool ismissionCompleted () {}
}

Am I sort of on the right track when thinking about my cites and how to move around? Is there a better way for looking at it?

Share this post


Link to post
Share on other sites
Advertisement

The search term to use is 'interactive fiction' eg https://en.wikipedia.org/wiki/Interactive_fiction which is bigger than just text adventures.

 

I wonder why you have cities, what's their purpose?

 

In other words, if you'd make a big flat world consisting of connected rooms, and you label a few rooms as  "in city X", and a few others as "in city Y". Would that work?

Is there anything special that must be maintained "city-wide" ? (labeling could take the form of a reference of a pointer to a city object of course)

 

If you have only cities (or you see "outside the cities" also as a special city), you could think of cities as "levels" where the player could move between.

 

 

The great trick in games is often that you put up a lot of smoke and mirrors to make the player believe something, while in reality, you do something much simpler. Don't be afraid to step outside what the real world does, if it serves your purpose. The judgement of a game is in the end always on what the player perceives, and not how you accurate your implementation represents the real world.

Share this post


Link to post
Share on other sites

The search term to use is 'interactive fiction' eg https://en.wikipedia.org/wiki/Interactive_fiction which is bigger than just text adventures.

 

I wonder why you have cities, what's their purpose?

 

In other words, if you'd make a big flat world consisting of connected rooms, and you label a few rooms as  "in city X", and a few others as "in city Y". Would that work?

Is there anything special that must be maintained "city-wide" ? (labeling could take the form of a reference of a pointer to a city object of course)

 

If you have only cities (or you see "outside the cities" also as a special city), you could think of cities as "levels" where the player could move between.

 

 

The great trick in games is often that you put up a lot of smoke and mirrors to make the player believe something, while in reality, you do something much simpler. Don't be afraid to step outside what the real world does, if it serves your purpose. The judgement of a game is in the end always on what the player perceives, and not how you accurate your implementation represents the real world.

 

 

What I want to do is essentially have the player move around the city by typing in commands, for example, if they enter a small medieval city with a tavern, a castle in the distance, hidden dungeons, towns people, and objects (trees, swords, shields,etc...) ,

 

So let say there at the entrance, at the prompt, they can type enter city name, in my game, they can view a map, by type view map. The player decided to go to the tavern, so they type enter tavern, and from there they can chat with NPCs, and so forth, and the NPCs will be a character object in code, rather than just a string. 

 

My main problem was how to structure moving from one city to the next and checking if the player has successfully reached the next city. This afternoon, I got the idea to use a method and take the players current location based on how many (go north, souths) they've typed and calculate the distance the city.  

Edited by Syrena

Share this post


Link to post
Share on other sites

Ah right, missed that question somewhat.

 

If you know whether you are in or out of a city (it would be weird to ask a distance while you are already in the city), you could run a pathfinder from the current location of the player to eg an entrance of the city. That gives you a distance, and even a full path.

 

Your idea may fail if the player walks a few circles??

Share this post


Link to post
Share on other sites

Ah right, missed that question somewhat.

 

If you know whether you are in or out of a city (it would be weird to ask a distance while you are already in the city), you could run a pathfinder from the current location of the player to eg an entrance of the city. That gives you a distance, and even a full path.

 

Your idea may fail if the player walks a few circles??

 

I don't understand the walk in circles part, could you elaborate a little more?

Edited by Syrena

Share this post


Link to post
Share on other sites

I got the idea to use a method and take the players current location based on how many (go north, souths) they've typed and calculate the distance the city.

 

For example the following layout

[attachment=30985:citiesABC.png]

Since you can walk a circle (where you have more south than north) your N/S count can be disturbed.

 

Oh, while typing the above I came up with another item. Suppose I want to go from A to C (without walking a circle). If you subtract number of North from number of South moves, then just 1 N out of city A is the same as 2N (E), and then 1S (2N-1S == 1N). In the latter case you are in the city you wanted to be

Share this post


Link to post
Share on other sites

One of the old MU* (MUD/MUSH/MOO) techniques is to use zones for this sort of thing. Divide the world up into zones, then divide each zone up into rooms. Each zone can be as large or small as you need it to be. You might have one zone represent a city, then next to it a zone representing a stretch of wilderness, then another zone next to it for another city, and so on. You might also have smaller zones to represent dungeons or towers inside a city, caves in the wilderness, and whatever. Each zone has entrances and exits like a room. In essence, it's a room that can contain other rooms, though how far you want to take that (should zones have descriptions? should zones have special features that rooms don't have?) depends on the nature of the gameplay.

Share this post


Link to post
Share on other sites


Since you can walk a circle (where you have more south than north) your N/S count can be disturbed.
Not sure how this would affect the gameplay in any way. Walking a graph is walking a graph.

To maintain your mental sanity, consider data-driven approaches. JSON in particular would allow you to kick various 'hierarchical' layouts with ease so you can keep your complexity inside a single city node.

Share this post


Link to post
Share on other sites

I'm seconding: TA as well as IF are based on "rooms". The player characters is ever in exactly one room. Such a room has a couple of exits. A command like "go north" actually tells the system to look whether the current room provides an exit that is tagged "north". If not, then going north is obviously not possible. Otherwise the exit's reference to the following room is extracted and the current room is set to that reference.

 

Notice that rooms in this sense are not necessarily physical. For example, a forest clearing may be room, and a lonely tree in its center can be a room, too. Hence, after entering the room "forest clearing", you can command "go tree" to go closer the tree, although within the system logic the player enters another room.

 

Although (AFAIK) not necessarily usual in old school games, exits can link to distant rooms. You can use a zone concept so that a zone adds exits to all rooms in that zone, without adding that exit to each rooms explicitly. Such zones should be used for long distant travels, of course.

 

I personally prefer an exit not to link to another room directly, but to an explicit entree of that room. This gives a nice possibility to distinguish from where the player enters the room, e.g. to run different actions.

Edited by haegarr

Share this post


Link to post
Share on other sites
Each location should be a node in a graph. Each node is connected by edges At a given node, possible exits are determined by the edges connected to the node. This way you only need to store the players current node and the nodes can be in a 1D graph. You *Could* remove all the edges, place your nodes on a 2D graph and use collision detection to find nearby accessible nodes... I've done this before when I wanted to take into consideration different modes of transport... I.E: If I am on a node and the 5 unit diameter walk circle collides with another node players can "walk" to that location, if the 50 unit diameter drive circle collides with another node they can "Drive" to the other location. You can also add multiple layers of maps... one the top most map nodes would represent different cities and points of interest, and each city, point of interest would have a subgraph with locations within that point of interest. In any case, you shouldn't need to store more than their current position (via nodeId or NodeId,SubNodeId.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!