Code:/* this program structure is for a simple text based adventure written in c it was written on Dev C 511 in the C programming language on windows 10 Watch your back carefully sentient consciousnesses, enjoy. i remember the loop in this before. might only contain one c library. I am going to take some vocabulary liberties. This is because I can't program. VERSION .01 beta I am not doing your homework I am practicing. */ // evaluate the variables // read the room description // input action // update variables // goto to evaluate #include <stdio.h> // this opens the standard printf library in c // #include <string.h> // string manipulation and search library in c // initialization of original variables int room=0, key=0, gold=0, move_counter=0, lock=0, potatoe=0, bucket=0, dog=0, fries=0, dvdrom=0, list=1, temp_room=0, inventory_list=1; char move1[15]="a", move2[15]="a"; int read_description (int room, char move1[15], char move2[15]); int list_commands (int list); int inventory (int inventory_list); int main (void) { printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); // clears the screen // room=read_description (room, gold, move1, move2); while (room != 999) { // list comands, inventory, or move if ( move1[0] == '?' || ( move1[0] == 'h' && move1[1] == 'e' && move1[2] == 'l' && move1[3] == 'p' ) ) { list_commands (list); } else if ( ( move1[0] == 'i' && move1[1] == 'n' && move1[2] == 'v' ) || ( move2[0] == 'i' && move2[1] == 'n' && move2[2] == 'v') ) { // printf("\nLISTING INVENTORY\n"); inventory (inventory_list); } else{ room=read_description (room, move1, move2); } printf("\nType help for a list of commands.\nEnter a two word action:[ %d >" , move_counter); scanf("%[^ ]%s", move1, move2); // splits the string into two components. fflush(stdin); // flushes the stdin incase more than 2 words used. printf("\nCommand: %s %s room: %d\n", move1, move2, room); // These are all the directional and movements move_counter=move_counter+1; } return 0; } // end of main program /* this is the room description reading function it will read al room descriptions */ int read_description (int room, char move1[15], char move2[15]) //char someletter; { if ( ( move1[0] == 'l' && move1[1] == 'o' && move1[2] == 'o' ) || ( move2[0] == 'l' && move2[1] == 'o' && move2[2] == 'o') ) { printf("\nYou look around at your surroundings...\n"); } if (room == 0) { printf("\n\n"); printf("Welcome to the Looking for My Doggy........\n"); printf("\n"); printf("¦¦¦¦¦¦¦¦+¦¦¦¦¦¦¦+¦¦+ ¦¦+¦¦¦¦¦¦¦¦+ ¦¦¦¦¦+ ¦¦¦¦¦¦+ ¦¦+ ¦¦+¦¦¦¦¦¦¦+¦¦¦+ ¦¦+¦¦¦¦¦¦¦¦+¦¦+ ¦¦+¦¦¦¦¦¦+ ¦¦¦¦¦¦¦+\n"); printf("+--¦¦+--+¦¦+----++¦¦+¦¦+++--¦¦+--+ ¦¦+--¦¦+¦¦+--¦¦+¦¦¦ ¦¦¦¦¦+----+¦¦¦¦+ ¦¦¦+--¦¦+--+¦¦¦ ¦¦¦¦¦+--¦¦+¦¦+----+\n"); printf(" ¦¦¦ ¦¦¦¦¦+ +¦¦¦++ ¦¦¦ ¦¦¦¦¦¦¦¦¦¦¦ ¦¦¦¦¦¦ ¦¦¦¦¦¦¦¦+ ¦¦+¦¦+ ¦¦¦ ¦¦¦ ¦¦¦ ¦¦¦¦¦¦¦¦¦++¦¦¦¦¦+ \n"); printf(" ¦¦¦ ¦¦+--+ ¦¦+¦¦+ ¦¦¦ ¦¦+--¦¦¦¦¦¦ ¦¦¦+¦¦+ ¦¦++¦¦+--+ ¦¦¦+¦¦+¦¦¦ ¦¦¦ ¦¦¦ ¦¦¦¦¦+--¦¦+¦¦+--+ \n"); printf(" ¦¦¦ ¦¦¦¦¦¦¦+¦¦++ ¦¦+ ¦¦¦ ¦¦¦ ¦¦¦¦¦¦¦¦¦++ +¦¦¦¦++ ¦¦¦¦¦¦¦+¦¦¦ +¦¦¦¦¦ ¦¦¦ +¦¦¦¦¦¦++¦¦¦ ¦¦¦¦¦¦¦¦¦¦+\n"); printf(" +-+ +------++-+ +-+ +-+ +-+ +-++-----+ +---+ +------++-+ +---+ +-+ +-----+ +-+ +-++------+\n"); printf("\nPress Enter to Continue...\n"); getchar(); room=1; } if (room == 1) { // begin room 1 ************************************************************************ // if move == north if ( ( room == 1 ) && ( move1[0] == 'n' && move1[1] == 'o' && move1[2] == 'r' && move1[3] == 't' && move1[4] == 'h' ) || ( move2[0] == 'n' && move2[1] == 'o' && move2[2] == 'r' && move2[3] == 't' && move2[4] == 'h' ) ) { room=5; move1[0]='a'; move2[0]='a'; } if ( room == 1 ) { // you feel like you have been here before. printf("\nIt is a warm sunny day.\n"); printf("You are walking down the sidewalk when all of a sudden your faithful puppy dog runs away from you.\n"); printf("He heads off in the North direction. You are standing feeling flummoxed on the sidewalk of the road.\n"); } } // end room 1 ************************************************************************* if (room == 5 ) // if move == north { // begin room 5 ************************************************************************ if ( ( room == 5 ) && ( move1[0] == 'n' && move1[1] == 'o' && move1[2] == 'r' && move1[3] == 't' && move1[4] == 'h' ) || ( move2[0] == 'n' && move2[1] == 'o' && move2[2] == 'r' && move2[3] == 't' && move2[4] == 'h' ) ) { room=10; move1[0]='a'; move2[0]='a'; } if ( ( room == 5 ) && ( move1[0] == 's' && move1[1] == 'o' && move1[2] == 'u' && move1[3] == 't' && move1[4] == 'h' ) || ( move2[0] == 's' && move2[1] == 'o' && move2[2] == 'u' && move2[3] == 't' && move2[4] == 'h' ) ) { room=1; move1[0]='a'; move2[0]='a'; } if (room == 5) { printf("\nYou are now standing in front of a very creepy rundown house with broken windows and tattered walls.\n"); printf("As you begin to look at the house in amazement you see your faithful dog leap into the house through a window.\n"); printf("A cold breeze blows accross your shoulders. You can go North to the house entrance or South to the sidewalk.\n"); } } // end room 5 ************************************************************************ if (room == 10) { // begin room 10 ************************************************************************ if ( ( room == 10 && lock == 1 ) && ( move1[0] == 'n' && move1[1] == 'o' && move1[2] == 'r' && move1[3] == 't' && move1[4] == 'h' ) || ( room == 10 && lock == 1 ) && ( move2[0] == 'n' && move2[1] == 'o' && move2[2] == 'r' && move2[3] == 't' && move2[4] == 'h' ) ) { room=15; move1[0]='a'; move2[0]='a'; } else if ( ( room == 10 && lock == 0 ) && ( move1[0] == 'n' && move1[1] == 'o' && move1[2] == 'r' && move1[3] == 't' && move1[4] == 'h' ) || ( move2[0] == 'n' && move2[1] == 'o' && move2[2] == 'r' && move2[3] == 't' && move2[4] == 'h' ) ) { printf("\nYou can't go that way the entrance door is locked!\n"); room=10; move1[0]='a'; move2[0]='a'; } // move the mat to see the key if ( (room == 10) && ( (move1[0] == 't' && move1[1] == 'a' && move1[2] == 'k' && move1[3] == 'e') || (move1[0] == 'g' && move1[1] == 'e' && move1[2] == 't') || (move1[0] == 'u' && move1[1] == 's' && move1[2] == 'e') || (move1[0] == 'g' && move1[1] == 'r' && move1[2] == 'a' && move1[3] == 'b') || (move1[0] == 'm' && move1[1] == 'o' && move1[2] == 'v' && move1[3] == 'e') || (move1[0] == 'l' && move1[1] == 'o' && move1[2] == 'o' && move1[3] == 'k') ) && (move2[0] == 'm' && move2[1] == 'a' && move2[2] == 't') ) { room=10; printf("\nYou reach and fumble with the mat it moves and you notice a key laying underneat it!\n"); move1[0]='a'; move2[0]='a'; } // get the key if ( (room == 10) && ( ( move1[0] == 't' && move1[1] == 'a' && move1[2] == 'k' && move1[3] == 'e' ) || (move1[0] == 'g' && move1[1] == 'e' && move1[2] == 't' ) || (move1[0] == 'u' && move1[1] == 's' && move1[2] == 'e' ) || ( move1[0] == 'g' && move1[1] == 'r' && move1[2] == 'a' && move1[3] == 'b' ) ) && ( move2[0] == 'k' && move2[1] == 'e' && move2[2] == 'y' ) ) { room=10; key=1; if (key) { printf("\nYou grab the key and place it into your inventory.\n ROOM: %d Key %d \n" , room , key); printf(" ROOM: %d KEY %d\n", room, key); } // printf("You grab the key and place it into your inventory.\n"); // printf(" ROOM: %d KEY %d\n", room, key); move1[0]='a'; move2[0]='a'; } // use the key if ( (room == 10 && key == 1) && (move1[0] == 'u' && move1[1] == 's' && move1[2] == 'e' ) && ( move2[0] == 'k' && move2[1] == 'e' && move2[2] == 'y' ) ) { room=10; lock=1; if (lock) {printf("\nYou place the key carefully into the lock and the door opens.\n"); } printf(" ROOM: %d KEY %d\n", room, key); move1[0]='a'; move2[0]='a'; } if (room == 10) { printf("\nYou are now standing at the entrance to the house. There is a *welcome mat* here with a dirt on it.\n"); printf("There is no door knocker or doorbell. The door is painted a mushroom yellow and appears to be locked.\n"); printf("You can hear your dog whimpering from inside.\n"); } } // end room 10 ************************************************************************ if (room == 15 ) // if move == north { // begin room 15 ************************************************************************ // get the gold bar if ( (room == 15) && ( ( move1[0] == 't' && move1[1] == 'a' && move1[2] == 'k' && move1[3] == 'e' ) || (move1[0] == 'g' && move1[1] == 'e' && move1[2] == 't' ) || (move1[0] == 'u' && move1[1] == 's' && move1[2] == 'e' ) || ( move1[0] == 'g' && move1[1] == 'r' && move1[2] == 'a' && move1[3] == 'b' ) ) && ( ( move2[0] == 'g' && move2[1] == 'o' && move2[2] == 'l' && move2[2] == 'd') || (move2[0] == 'b' && move2[1] == 'a' && move2[2] == 'r' ) ) ) { room=15; gold=1; if (gold) { printf("\nYou grab the gold bar from the floorboard and polish it a little.\n"); printf("\nYou feel the somewhat heavy weight of it as you place it into your inventory.\n"); } // printf("You grab the key and place it into your inventory.\n"); move1[0]='a'; move2[0]='a'; } if (room == 15) { printf("\nThis is the main hall of the house it is covered in dust.\n"); printf("There is a large chandelier that has fallen and crashed onto the floor here opening a floorboard.\n"); printf("Underneath the broken floor board lies what appears to be a glimmer of a metal gold bar.\n"); } } // end room 15 ************************************************************************ return room; // returns the room int variable back to the main program. } // end of room function int list_commands ( int list ) { if ( list == 1) // this is a list of available commands. { printf("\nThe following are a list of commands you may enter in lower case:\n"); printf("\ngo move north south east west\n"); printf("look get take grab\n"); printf("open make use feed\n"); printf("inventory\n"); printf(""); } return 0; } int inventory ( int inventory_list ) { // begin function ************************************************************************* if ( inventory_list == 1) // this is a list of available commands. { printf("\n\ninventory list\n"); printf("--------------\n"); printf("gold bar %d\n", gold); printf("key %d\n", key); printf("bucket %d\n", bucket); printf("potatoe %d\n", potatoe); printf("french fries %d\n", fries); printf("dvdrom %d\n", dvdrom); } return 0; } // end function *************************************************************************