$29
This is an adventure game in which there are multiple rooms laid out relative to eachother. All of the rooms are locked at the beginning of the game, except for the enterance room , which the player starts out in. The player must look around each room and take items from the room. Each of the items is named identically to the room that it unlocks: the elephant item unlocks the elephant room, so on. The point of the game is to navigate the rooms to find the treasure item and make it to the treasure room. The game does not allow you to use items if they do not unlock any neighboring doors.
The game involves 3 structs-
1. Room
- Consists of pointers to all the neighboring rooms
- Contains a list of items in the room
- Contains a boolean to check if a room is locked or not
2. Item
- Has its name, description and a pointer to the next one.
3. Player
- Has its current location
- An inventory of items
- Name of the player
### Functions-
- item:
- Is a constructor for making new items. Takes in the name, description and a pointer to the next item and then returns a pointer to the new item.
- alloc_room:
- Takes in a pointer to a room and uses malloc to dynamically allocate memory for that room
- room: Acts similar to a constructor where it takes a pointer to a room and then other fields like descriptions, items and neighboring rooms and sets the rooms fields to the ones passed in
- print_room_bearings:
Prints your current location and then the surrounding locations in relation to where you are.
- item_name:
Returns the name of the item struct passed in
- item_description:
Returns the description of the item struct passed in
- print_list:
Prints the values of a linked list. Used to print the list of items
- add_item_to_list:
Adds a given item to the end of a given list
use_item_free -
Clears it from the players inventory and clears from the users inventory
take_item -
Takes an item from the room and adds it to the players inventory
use_item -
Uses the item passed in and can potentially unlock a door for the player. Also utilizes the use_item_free to free the memory and remove it from the list
drop_item -
Drops the item from the players inventory
move_direction -
Moves the player in a specific direction
freeItem -
Frees the memory for the item passed in.
Clear_screen -
Clears the terminal window
trim_whitespace -
Stores the trimmed input string into the given output buffer.
create_player -
Creates a player and sets its fields to the other parameters passed in
print_intro -
Prints the introduction of the game