I'm in the process of making an text based-rpg in C++. Its just a little project so I can learn some object-oriented programming, nothing serious. My problem is that I've created a class like so:
This is the room class. Yes, its missing a lot, but thats not the point. The problem is that I've got to make this room "link-up" with other rooms. What I mean is that its somehow connected to other rooms, allowing me to traverse from room to room. So I got the idea of passing the objects to the constructor and storing their addresses in a vector of pointers. The problem is how exactly I can pass these rooms the the constructor.
In case I'm not clear enough, here's what I want to do:
This doesnt seem too difficult but since any room can link up with any number of other rooms, something like this can happen:
how exactly can I make the above code work? Or how can I pass any number of objects to a function?
Any help/suggestions are greatly appreciated.
PS: Anyone know of some text based RPG-making C++ tutorials? All I find are either said to be defective in some way or way to complex for me.
Regards,
-Poke386
Code:
class room
{
public:
string description;
room(string s,??) //problem here
{
s=description;
}
vector<room*> next;
}
In case I'm not clear enough, here's what I want to do:
Code:
room something(d,s1,s2); //the vector stores the addresses of rooms s1,s2
Code:
room something(d,s1,s2) //something is "linked" to 2 other rooms room something2(d,t1) //something2 is "linked" to 1 other room room something3(d,q1,q2,q3) //something3 is "linked" to 3 other rooms
Any help/suggestions are greatly appreciated.
PS: Anyone know of some text based RPG-making C++ tutorials? All I find are either said to be defective in some way or way to complex for me.
Regards,
-Poke386
Comment