For this week’s Final Project Milestone you implemented the Room Map in wk7_Room.cpp. That Map code will support the app code you write for this assignment. Be sure to complete the Milestone assignment first!
- Start with these files: wk6_completed_code.zip provided below.
- This week’s starter code provides the Look command. Build the app and try it out!
- Study these files: wk7_app_init_rooms.cpp and wk7_app.h.
- Use Cut/Paste to customize wk7_app_init_rooms.cpp with your room initialization code. After this step you should have two room initialization functions.
- Make sure the room initialization function prototypes are correct in wk7_app.h. The function names should correspond to your custom room names.
- Choose a direction from the room you already had to the new room you just added. Use one of the provided direction constants: ROOM_NORTH, ROOM_SOUTH, etc.
- >>> This is wrong: In wk7_app_init_rooms.cpp, at the bottom of the room initialization function for the room you already had, add code to set one of the room map direction pointers to the pointer for your new room. <<< Instead, initialize both rooms first. Save the returned room pointers in global variables. Only then can you initialize the room map pointers – all the the room pointers need to be valid first!
- >>> You don’t need to do this. Set all other room map direction pointers for the old room to point to the old room. <<< Instead, just set the room pointers you need as in the code above.
- Choose a direction from the new room to the room you already had.
- >>> This is wrong – you took care of this in Step 7 above: In wk7_app_init_rooms.cpp, at the bottom of the room initialization function for the new room, add code to set one of the room map direction pointers to the pointer for your old room. <<<
- >>> You don’t need to do this. Set all other room map direction pointers for the new room to point to the new room. <<< Instead, just set the room pointers you need as in the code above.
- In the file wk7_app.cpp, change the way you handle each direction command. Instead of displaying direction text, update the current room pointer with the room map pointer for that direction. I put sample code for this in one of the direction command cases in the app’s switch statement.
- Code the setRoomDirectionPtr() and getRoomDirectionPtr() member functions in this file. The new Room member functions for the Room Map are similar to the Room direction text member functions you previously coded.
Assignment Requirements
Your game app should compile cleanly with the provided class declaration files (don’t edit these files!):
- wk7_Treasure.h
- wk7_Room.h
- wk7_Player.h
Your running app should handle all direction commands by “moving” the player to the appropriate room, based on your room map pointers.