hey all can u tell me a how to create rooms in text adventures?
hey all can u tell me a how to create rooms in text adventures?
HA!code it in.
Well, there are a few things wrong with your code:
1) It does not work.
2) It does not work.
3) It does not work.
Hope this helps.
consider using a 2D array of chars to store the 'object' at each location. if you have trouble with that, post a specific problem along with the code you've written
By text adventure do you mean ASCII graphics, or do you mean the kind of game where it is "You walk forward, you walk left, etc..."?Originally posted by Joe100
hey all can u tell me a how to create rooms in text adventures?
Yeah, a 2d array would be easy for a room. When your character moves just see whats at the spot in your room where the character x,y pos is. Assuming your room starts at the top left of the console window, and you are your room to be 30 "spaces" x 30 "spaces" you would do....
Then, when they user presses up you would do something like....Code:char room[30][30];
You could then have a function that checks to see if anything is at the spot where the character is. Have statements like this in the function...Code:switch(input){ case Up: y--; break; //you should get the idea for the rest of the cases...
edit: Messed up the room array... thanks PerspectiveCode:if(room[y][x]=='D') { cout<<"You are at a door"; }
Last edited by o0obruceleeo0o; 08-05-2003 at 10:25 PM.
>> char room[29][29];
erm, to make a 30 x 30 grid you would need to declare it like...
char map[30][30];
and index it from 0 to 29
When checking what is at a certain element in your room-array, make sure you're not looking outside the bounds (like when you stand at the top of the room and press UP). A simple check in the beginning makes sure this won't happen, in this case I assume that is is a wall outside the array (to prevent the player from walking there).
Code:char GetBlock(int X, int Y) { //Assume walls if outside the array if(X < 0) return 'W'; if(X >= 30) return 'W'; if(Y < 0) return 'W'; if(Y >= 30) return 'W'; //Return what is in the array return Map[X][Y]; }
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
If you want just want it to be like "you moved left" then that should be fairly simple to do. If you want to have graphics - like '|' represents a wall, then it gets a little more complicated only because you have to draw it all out...So if I were you I would stick with first approach, and then when your're done you can go and add text graphics to it.
Well, there are a few things wrong with your code:
1) It does not work.
2) It does not work.
3) It does not work.
Hope this helps.
IMO, the best way to do this is create a text game editor and make the game that way, but that may be above your current ability
You might want to check out the Text Advnetur tutorial located at GameTutorials.com, it is very simple to understand.
link: Text Adventure Tuts
off the topic but.. perspective u should have the wc3 tft illidan as your avatar he looks so much better.. but how the f**k does artharas kill him.. i dont c how
ok then umm.....yea what ever you say man
"Be Quick Or Be Dead"
[img]
http://www.danasoft.com/sig/GU.jpg
[/img]