Ok, i am kind of new to c++ but decided to start a project that i can keep adding what i learn to. and since i started learning c++ so I could create a MUD i decided to do that. I was woundering how i would go about creating rooms, and with a (planned) overhead map (like using symbols to represent the diffrent rooms) like this:
coordinates: 41 x 42
^something like that, exept i will be planning on making it more elaborate (and eventualy adding colors). The map part can wait since im new and all (dont want to get into something i cant handle...) but i want to be able to at least make the rooms and cant find a tutorial for it anywere or know how to do it (arrays?)
any help would be appreciated (BTW im not trying to get anyone to code anything for me, just need to know how i would go about coding it...)
Mhm... That's a good way of doing it.
Both terrain and your rooms can be coded with arrays. You are probably going to need a two-dimensional array. Each of the values in this array should represent an object in the game. To print the map/room on the screen you will have to cycle through the array and print each of the objects using cout or something.
hhmmm... i guess that makes sense (kind of...), im not 100% sure of what i would be doing but i'll read up on arrays until i get it :D thanks for the help (i havent gotten to arrays yet, but when trying to make a tic tac toe game i learned that using arrays to draw the board would be easiest so i kind of figured that this would be close to the same thing...)
I would suggest an "area class" with an instance for each room/area, with information about the size of the room/area, perhaps stored in an array inside the class, and other information, like other players in the area, creatures, objects, etc.
Instead of using arrays (as that would be TOTALLY destructive to ones thought processes :P) take it based on direction. What I mean is this:
Say those are rooms 1, 2 and 3. Basically you would build a class to hold the room data and you would link the rooms together by showing which rooms link in which direction.
Then basically you would link them like this using room 1 for our example.
// set and get methods etc
id = 1
east = 3
south = 2
north = 0
west = 0
So basically if the direction is 0 then there is no room connecting to that particular exit out of the room. But if it's a non zero number that is the number of the room it connects to.
Once you kind of grasp the idea of this you can throw the multi-dimensional array nightmare out the window. You can make this class more functional by adding more to it say like an up and a down, or a northeast anything like that.
Hopefully that helps you a bit even if its just seeing another idea.
As a variant on the above mentioned example, you could also have pointers inside each class and have them point to the next room. ;)
Bubba and I had a big debate about these methods in this forum a while back. I'm sure you can find it if you look hard enough.
Searching quzah and bubba didnt work, but visa versa it did:
Nice thread, that leads to another longer thread, that I'll have to read later. :o