Thread: Inventory, text game

  1. #1
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373

    Inventory, text game

    I don't want to use my previous engine. it was this:

    Code:
    int sword = 0;
    
    if (sword == o)
    this 
    else if (sword == 1)
    that
    I want to be able to pick up and item when crossed, then use it or drop it later on.
    How would i do that?
    This war, like the next war, is a war to end war.

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    thats kind of vague, please elaborate.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  3. #3
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    you mean if u "step" on it?

  4. #4
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    well if thats what u meant, when i first started programming i had a text game, heres how i did it for picking up the amulet:

    Code:
    /***************************************************************
    	****************************************************************
    	Code for Amulet
    	****************************************************************
    	***************************************************************/
    	if (User_Location_X == 0 && User_Location_Y == 5)
    	{
    		if (Amulet == 1)
    		{
    			cout <<"You have returned to where you found Soris's Amulet.\n\n";
    					
    		}
    
    		else if (Amulet == 0)
    		{
    			cout <<"You found Soris's Amulet!\n\n";
    			cout <<"You feel protected and are awarded ten points.\n\n";
    			Amulet = 1;
    			
    		}
    	}
    If you want to see all of the code just ask i'll post it as an attachment.

  5. #5
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    Here are some of the data structures I've used for text games

    PHP Code:
    enum eItemFunction eOnceeInfiniteeFiniteeTimeLimited }; // how many times can you use item?

    enum eRoomType ePatheWalleRoom }; // types of rooms

    struct sItem {
         
    charitemName;
         
    int itemStrBonus;
         
    int itemLifeBonus;
         
    eItemFunction itemUse;
    }


    struct sMapRoom {
         
    eRoomType roomType;
         
    sItem roomItems[4]; // max of 4 items
         
    charroomDescription;
         
    bool bNeedKey;
         
    charkeyName;
    }

    struct sMap {
         
    sMapRoom mapRooms[100][100];
         
    charmapDescription;
         
    // map details like geography etc.
    }

    struct sPlayer {
         
    sItem Inventory[32];
         
    int Life;
         
    int x// map co-ordinates 
         
    int y;
         
    // etc.

    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

  6. #6
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    That helps out a little... but how would i ADD the items to the inventory? My first game was using RoDs engine. i created about 1800 lines of that crap.... and the game was really bad. after 6 games of that i got into using structures... my latest source is this
    attached. Its a game to rival my dads Beave hunter (beave is my nickname). So It's called Dad Hunter. LOL. But when i start the game, im already on that wierd floor with the trap on it.. no matter what, then when i add to the skill, max_y etc, it performs an illegal operation. That really irritates me.
    This war, like the next war, is a war to end war.

  7. #7
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by Blizzarddog
    My first game was using RoDs engine.
    Hm, wha? where? huh? RoD made an engine? Tell me about it!
    Dad Hunter makes me think of my time in BASIC
    You should do something about it, put some things in functions.

  8. #8
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    it was in my first week of C++, i had a junky-at-best txt game that ran on if's, a switch or two, and user input...i mean it was ok but i wouldn't consider it an engine...

  9. #9
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    My first game was using RoDs engine and the game was really bad.
    I love Cut & Paste

  10. #10
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    I call anything that the game runs on an engine, what makes things happen. In my experiance in ZZT, my company made a game call mech trainer with the player at the bottom of the screen controlling the mech above him. That is an engine. If (sword == 2) do this, i consider that an engine because else if (sword == 1) do that
    This war, like the next war, is a war to end war.

  11. #11
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    if its an engine its a ford....prone to problems....

  12. #12
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    And travis, dont call me cut & paste, my dad does that to me when i wrote 3400 lines of C++ code by myself.. and it made me destroy alot of stuff... almost made me break the computer.. so DONT call me that.
    And i dont care much for sarcaasm.. bad week.
    This war, like the next war, is a war to end war.

  13. #13
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    Originally posted by RoD
    if its an engine its a ford....prone to problems....
    I hear ya.
    This war, like the next war, is a war to end war.

  14. #14
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    Originally posted by Blizzarddog
    And travis, dont call me cut & paste, my dad does that to me when i wrote 3400 lines of C++ code by myself.. and it made me destroy alot of stuff... almost made me break the computer.. so DONT call me that.
    And i dont care much for sarcaasm.. bad week.
    Hmmmmm, it was a joke for RoD, anyhow sorryZ.

  15. #15
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    i got the joke, guess he missed it...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with my text adventure game.
    By Haggarduser in forum Game Programming
    Replies: 15
    Last Post: 10-26-2007, 01:53 AM
  2. New Project, text game, design stage.
    By Shamino in forum Game Programming
    Replies: 9
    Last Post: 05-23-2007, 06:39 AM
  3. Text adventure engine idea. thoughts?
    By suzakugaiden in forum Game Programming
    Replies: 16
    Last Post: 01-15-2006, 05:13 AM
  4. My Memory Game
    By jazy921 in forum C Programming
    Replies: 0
    Last Post: 05-05-2003, 05:13 PM
  5. My Pre-Alpha Version Rpg Text Game
    By knight543 in forum C++ Programming
    Replies: 1
    Last Post: 04-06-2002, 06:02 AM