#include using namespace std; void area1(); void area2(); void divider(); int hammer = 0; // 0 means not picked up int main(){ area1(); // starting point cout <<"Good bye!\n"; } void area1(){ int choice; do{ divider(); cout <<"You are in a room.\n"; if(hammer == 0){ cout <<"There is a hammer.\n"; } cout <<"There is a door.\n"; if(hammer == 0){ cout <<"1) Pick up hammer.\n"; } cout <<"2) Go through the door.\n"; cin >> choice; if(choice == 2){ area2(); } if(choice == 1){ cout << "Picked up the hammer.\n"; hammer = 1; } }while(1); // loops forever - until the player leaves the room } void area2(){ int choice; do{ divider(); cout << "Area 2\n"; cout << "There's loose nail.\n"; cout << "1) Hammer the nail.\n"; cout << "2) Goto room 1.\n"; cin >> choice; if(choice == 1 && hammer == 1){ cout << "You've hammered the nail\n"; } if(choice == 1 && hammer == 0){ cout << "You need a hammer to do that.\n"; } if(choice == 2){ area1(); } }while(1); // loops forever - until the player leaves the room } void divider(){ // this function just separates the room text a bit cout << "\n\n"; // a couple of blank lines cout << "------------------------\n\n"; }