room progression(again)

Started by
8 comments, last by Kelly G 19 years, 8 months ago
my freind has been harping me to make a harry potter game for some time. so, I finally got sick of it and told her I would, but im lost. im using a revised version of the battle system I made for my other game called armor core arenas. my probem is, I still dont know how to make the rooms. I donwloaded the text adventure tutorial off of gametutorials, but I was lost. I am interested in using arrays, because it seems like the best choice. so, could somebody better clarify this or point me to another tutorial? edit: the game is a text adventure
______________________________My website: Quest Networks
Advertisement
is this going to be a 2D side scroller / over head game, or a 3D game?
An array might not be the best data-structure for your text game. Consider making a "Space Node" with a description of itself, and pointers to a North, South, East, West "Space Node"

Something like this

* *
| |
*-*

The * represent space nodes, and the lines represent links. So in the upper left node, the player can go west, south. In the upper right node, the player can go east, south.
first, the game is a text adventure, so, um, no it wont be 3d :) second, I have no clue what a space node is. I just want this to be as simple as possible.
______________________________My website: Quest Networks
Hey jakpandora do you have AIM or any other messaging system? If so can you post your s/n, maybe we can help eachother.

AIM: Verkivious
this is jakpandora(really. I dont fell like signing in) I dont really know how to set up a name on aim, but my email is Mic46686@aol.com can anyone else help?
i think using nodes is a little more difficult than using an arary.

what you need to do is create a two dimensional array, this basically creates a grid ...

for example ...
int grid[5][5];

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

now you can give yourself a position withen this grid (x, y)
and make numbers withen this grid coraspond to differnt rooms.

so say you are at position (2, 4)
note: arrays start at 0 not 1 ... you would be there in the grid ...

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 X 0 0
0 0 0 0 0

you can make it so at differnt positions you get specific options on which direction to go and so on ... when you want to move you can increase your x position and or your y position ... here is an example ...

#include <iostream>using namespace std;void room_type_1 (int &x, int &y){    char d;    cout << "you can move in any direction" << endl;    cout << "which direction do you want to go? (N, S, W, E): ";    cin >> d;    if (d == 'n') y --;    if (d == 's') y ++;    if (d == 'w') x --;    if (d == 'e') x ++;}void room_type_2 (int &x, int &y){    char d;    cout << "you can move north and south" << endl;    cout << "which direction do you want to go? (N, S): ";    cin >> d;    if (d == 'n') y --;    if (d == 's') y ++;}        int main (){    int grid[5][5] = {        { 1, 1, 1, 1, 1 },        { 1, 1, 2, 1, 2 },        { 1, 1, 1, 1, 1 },        { 1, 1, 2, 1, 2 },        { 1, 1, 2, 1, 2 }    };    int x = 2;    int y = 3;    bool done = false;    do    {        cout << "x: " << x << endl;        cout << "y: " << y << endl;                if (grid[x][y] == 1)            room_type_1 (x, y);        else if (grid[x][y] == 2)            room_type_2 (x, y);    } while (!done);    return 0;}


i hope this helps you ... also make sure you dont let your x and y positions go below 0 or over the max ...
I just scanned over your code, but after reading it, It all started to make sense. thanks!
______________________________My website: Quest Networks
I sent you an e-mail, hope it helps a little.
What I did was make a one-dimensional array of structs- a struct for each room which included the desription and where all the directions lead (as ints storing array indeces of other rooms, or -1 for walls). It's basically a linked structure like Onemind described, except implemented using a one-dimensional array. This method is very simple to code, but you need to map out the rooms and assign them numbers ahead of time. Also you can't create rooms at runtime. You can however link rooms together at run time.

By the way, I like the sound of "Harry Potter: Armor Core Arenas" for the title :).

This topic is closed to new replies.

Advertisement