Sign in to follow this  
sp00kymulder

Creating a World for a Text/Menu based Life Sim/RPG

Recommended Posts

I'm trying to learn to code by writing a life sim of sorts, taking on small pieces at a time and wanted to get some input from people regarding staring to build a world. I would like to start of with one city, with a handful of buildings, and some of those buildings with a handful of rooms (like a house, or apartment). Wondering in you guys opinions what would be the most straightforward solution for this for someone with a bigginner to intermediate experience level.

I was thinking something like a 'city' class that contains a list of building objects, which in turn contain rooms objects. Would this be simple enough? Sorry for my basic use of terminology, just trying to keep it simple enough that I can still understand it.

Thanks in advance for any help that you can provide.

Share this post


Link to post
Share on other sites

Ultimately, you are the only person that can decide if it is simple enough for you. However, the fact that you ask about it, rather than know the answer, suggests to me, it's too complicated at this point.

 

There is no shame in starting very small. Less elements means less things going on at the same time, so better chance in understanding.

 

A second point is that I don't see what "city" or "building" adds. Basically, interaction happens between or more persons in the same room, or one person in one room (if you can interact with the room itself). So, maybe you should ask yourself how "two rooms in one house" is relevant, and how "two houses in one city" is relevant (in interacting).

 

 

I never considered writing this kind of program, but maybe a good starting point is a single room. One person interacting with the room, and then two persons in the same room interacting.

You'd get experience in how these things work, and some building blocks to scale up later to cities, the world, and ultimately, the universe!

(ho wait, that was about ruling worlds, never mind ;)   )

 

 

Share this post


Link to post
Share on other sites
I don't necessarily agree with the notion that because someone has to ask a question about something means it's too complicated for them. How is one supposed to learn anything if that's the case? But that aside, I do plan on stating small, like one room at a time, but I want to structure this in a way that I can build on it, rather than rewrite everything when I am ready to move forward. I am not understanding the next part of your reply. 'Two houses in one city' is relevant because the cities will (hopefully) eventually be filled with more people with their own houses. 'Two rooms in a house' seems relevant because different rooms will serve different functions (bedroom, kitchen, bathroom, etc.). Cities will eventually have more than one building (houses, shops, etc.), and ultimately the goal is to have more than one 'city'. Not trying to be difficult or hostile, just having conversation.

Share this post


Link to post
Share on other sites

Not trying to be difficult or hostile, just having conversation

 

You HAVE been.

@Alberth was only trying to help based on very little information he had.

If he mis-understood you in any way, take that as an opportunity to  explain your situation and the help you need more politely 

Share this post


Link to post
Share on other sites
How have I been impolite in any way? Because I disagreed with his initial statement of 'if you have to ask, it's too complicated'? I asked for clarification of his statements becuase I wasn't sure if I was understanding correctly, and then pointed out where I thought a few things WERE relevant. I think that's an unfair criticism.

Share this post


Link to post
Share on other sites

I don't necessarily agree with the notion that because someone has to ask a question about something means it's too complicated for them. How is one supposed to learn anything if that's the case?

Fair enough, but in my experience, the biggest thing you'll learn is that you get very solidly stuck, and get terribly frustrated by it.

If you continue programming, you'll get plenty opportunities to take a too big bite, no need to look for it smile.png
 

But that aside, I do plan on stating small, like one room at a time, but I want to structure this in a way that I can build on it, rather than rewrite everything when I am ready to move forward.

You didn't mention this in your first post, so how was I to know that?

The strategy itself is sound, except you may be putting too much emphasis on re-using the code (but that is normal).
In my experience, the thing that really counts is not the code with the solution, the method of solving is what is really important.
Once you know that, you can rewrite the code in a few hours to a day. When I do that, the code usually also improves until the 3rd or 4th rewrite, as you have the room to start again but you have better knowledge where you want to go.
 

I am not understanding the next part of your reply. 'Two houses in one city' is relevant because the cities will (hopefully) eventually be filled with more people with their own houses. 'Two rooms in a house' seems relevant because different rooms will serve different functions (bedroom, kitchen, bathroom, etc.)

I meant in terms of interaction. I can see two persons in one room interacting with each other (which I guess is a large part of the game). I cannot see one person in one room, and another person in another room, interacting with each other (other than by a quite limited thing called 'phone').
As such in terms of interaction, multiple rooms or multiple houses don't look very relevant to me, it's just (many) more two-persons-in-one-room cases that happen at the same moment in time.
(But you probably have thought about things a lot longer than me, you may be able to point out a flaw in my reasoning.)
 

Not trying to be difficult or hostile, just having conversation.

Not sure where that is coming from, but I have no hostile intentions.
It's just that a text-only medium with smileys as only way to express emotions, has a lot of room for misunderstanding. I write text that I believe to be completely understandable, but you interpret it differently from my intended direction. That's not my fault (other than having to try better), and it's not your fault, it's just the medium that makes communication very difficult. This also happens the other way around; your remarks and questions get interpreted in ways you don't expect.
The only way to solve this is to try be more clear in what you mean in follow-up posts.

Share this post


Link to post
Share on other sites
Oh no, I wasn't point out that you were being hostile, sorry if it came off that way. I didn't want you to think I was by slightly disagreeing with you on a few things. None the less, I appreciate the responses. Apologies for not making it more clear that I was intending to start on the smallest level and work my way up, but you make some good point about the possibilities of maybe having too at some point. I agree with 2 people in different rooms not directly interacting with each other. I guess what I am trying to convey is that eventually I would like to have multiple people other than the player character 'living' in the world doing (or at least simulating) their own lives independent of the player character. Thank you for your clarifications. Your input has given me a few things to think about!

Share this post


Link to post
Share on other sites

I would suggesting considering if there is a difference other than data between a city, building and room and then consider if there is a need for separate classes. It would seem to me that each of "city", "building" and "room" could actually be done with one "location" class that can contain other locations (which could be none). This way you could the add additional "levels" to your structure such as building being made up of floors, cities made up of districts, states made up of cities, etc. without having to create additional classes for each type.

Share this post


Link to post
Share on other sites

I don't know how much programming experience you have, but I'll suggest that before you start planning out a city and filling it with things you try a single room. Then implement some of the things you'd like to simulate, like interacting with another person in the room. After that add a second room, and implement the features that multiple rooms would require, like the ability to move between them, update a room while the player is not there, etc.

 

It's amazing how many design steps you can miss when you start with content in a type of program you haven't written before. I've been amazed by it in my own projects.

 

If you are going to stick with the design as you've laid it out (and for all I know you already have all the details planned for how everything will fit together), it may be better to use a more general Location class as Dragoncar suggested. But your needs and style will inform the specific design approach you use, and there is always more than one way to accomplish a programming task. The right way is a way that works, and you can refine things after the basics are running.

Share this post


Link to post
Share on other sites
Yeah, I really like the idea of using a single generic Location class. Since each location could have a variable number of sublocations, would using a 'list' to hold sublocations be a good way to solve that?

I definitely intend to start small with a single room, and start working my up from there

Thanks for the additional replies!

Share this post


Link to post
Share on other sites
I would expect sublocations be locations inside other locations, eg a house in a city, a room in a house, or a bed/shower/closet in a room.
A list could work, but if you want to find sub locations by name, it's better to use a map/dictionary

You might also want to have "exits" to other locations (from one room to another), unless you want to ask the house about neighbouring sublocations.

(This starts to look a lot like an adventure game structure, it might be useful to have a look at eg inform or tads to see how they handle rooms and exits.)

Share this post


Link to post
Share on other sites


Yeah, I really like the idea of using a single generic Location class. Since each location could have a variable number of sublocations, would using a 'list' to hold sublocations be a good way to solve that?

 

Yes, though there are other details that will matter. A common is to have each Location contain a list of references to Locations that it connects to, with the actual Locations themselves declared, instantiated, and stored in a higher-level object (like a World or Game class). That could be a list, though I'll echo Alberth that it will probably be better to use a Dictionary or map. Again, your exact approach will depend on how you plan to access and manipulate the Location objects in your game.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this