Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

need help in writing a text adventure game using arrays and structs

i need to write a program from scratch. a text adventure game that uses arrays and structs to hold and display the information as the game progresses. Can one please help i'm a newbie to C++ and need to get a grasp of what to write in the script. If anyone can help...PLEASE!!!!!

Comments

  • pseudocoderpseudocoder Member Posts: 701 ✭✭✭
    : i need to write a program from scratch. a text adventure game that uses arrays and structs to hold and display the information as the game progresses. Can one please help i'm a newbie to C++ and need to get a grasp of what to write in the script. If anyone can help...PLEASE!!!!!
    :

    If it's C++, then consider using a/or class/es instead.

    [code]
    typedef struct
    {
    char name[32];
    int attributes[4];

    } ITEMS;

    typedef struct
    {
    char name[32];
    int lev;
    ITEMS stuff[25];

    } PLAYER;

    PLAYER party[4];

    party[0].name is something
    party[0].lev = something
    party[0].stuff[0].name is something
    party[0].stuff[0].attributes[0] = something
    [/code]

    the structure items consists of two "members" - a name for up to 31 characters + '', and the array attributes, which could hold status boosts or such.

    the structure player consists of similar details, but also inherits the structure items, so that each player can carry 25 items as described above. Likewise, party[4] is declared as an array so that four characters can be included in the game.

    In summary, there can be four players each with his or own name, a level, and an inventory of up to 25 items each with its own name and four possible status effects.

    There you go... *something* on both arrays and structs.

    Have fun.
  • Homie3000Homie3000 Member Posts: 11
    : : i need to write a program from scratch. a text adventure game that uses arrays and structs to hold and display the information as the game progresses. Can one please help i'm a newbie to C++ and need to get a grasp of what to write in the script. If anyone can help...PLEASE!!!!!
    : :
    :
    : If it's C++, then consider using a/or class/es instead.
    :
    : [code]
    : typedef struct
    : {
    : char name[32];
    : int attributes[4];
    :
    : } ITEMS;
    :
    : typedef struct
    : {
    : char name[32];
    : int lev;
    : ITEMS stuff[25];
    :
    : } PLAYER;
    :
    : PLAYER party[4];
    :
    : party[0].name is something
    : party[0].lev = something
    : party[0].stuff[0].name is something
    : party[0].stuff[0].attributes[0] = something
    : [/code]
    :
    : the structure items consists of two "members" - a name for up to 31 characters + '', and the array attributes, which could hold status boosts or such.
    :
    : the structure player consists of similar details, but also inherits the structure items, so that each player can carry 25 items as described above. Likewise, party[4] is declared as an array so that four characters can be included in the game.
    :
    : In summary, there can be four players each with his or own name, a level, and an inventory of up to 25 items each with its own name and four possible status effects.
    :
    : There you go... *something* on both arrays and structs.
    :
    : Have fun.
    :
    12/9/04
    how bout if it involves ONE player that must go through a series of rooms, and in those rooms they have the option of going north/east/south/west into another room.
  • Homie3000Homie3000 Member Posts: 11
    : : : i need to write a program from scratch. a text adventure game that uses arrays and structs to hold and display the information as the game progresses. Can one please help i'm a newbie to C++ and need to get a grasp of what to write in the script. If anyone can help...PLEASE!!!!!
    : : :
    : :
    : : If it's C++, then consider using a/or class/es instead.
    : :
    : : [code]
    : : typedef struct
    : : {
    : : char name[32];
    : : int attributes[4];
    : :
    : : } ITEMS;
    : :
    : : typedef struct
    : : {
    : : char name[32];
    : : int lev;
    : : ITEMS stuff[25];
    : :
    : : } PLAYER;
    : :
    : : PLAYER party[4];
    : :
    : : party[0].name is something
    : : party[0].lev = something
    : : party[0].stuff[0].name is something
    : : party[0].stuff[0].attributes[0] = something
    : : [/code]
    : :
    : : the structure items consists of two "members" - a name for up to 31 characters + '', and the array attributes, which could hold status boosts or such.
    : :
    : : the structure player consists of similar details, but also inherits the structure items, so that each player can carry 25 items as described above. Likewise, party[4] is declared as an array so that four characters can be included in the game.
    : :
    : : In summary, there can be four players each with his or own name, a level, and an inventory of up to 25 items each with its own name and four possible status effects.
    : :
    : : There you go... *something* on both arrays and structs.
    : :
    : : Have fun.
    : :

    12/9/04
    how bout if it involves ONE player that must go through a series of rooms, and in those rooms they have the option of going north/east/south/west into another room. I have to use either structs or classes. whichever you can help me in.

  • chrismax2chrismax2 Member Posts: 10
    I'm not ready (just right yet ) to do my own txt adventure, but I always thought that you would use Arrays as the room locations, however that would require millions of If statements, which I feel there would be another way. As I am rather new myself (and I keep putting off reading classes, but thats next on my do list) Could someone agree that is the best way to move around rooms, or is there another way which would not involve so many if statements, (how about a switch statement, though that still seems a long way of doing it)

    Any suggestions would be appreciated.

    Chris :)

Sign In or Register to comment.