Assignment 4-A

Text Adventure Game

Create an interactive text-based adventure game using arrays for game state, strings for narrative, and vectors for dynamic inventory management.

6-8 hours
Intermediate
200 Points
Submit Assignment
What You'll Practice
  • 1D and 2D arrays for game maps
  • String manipulation & parsing
  • Vectors for dynamic inventory
  • Array searching & sorting
  • Game state management
01

Assignment Overview

Build a Text Adventure Game where players explore rooms, collect items, solve puzzles, and manage inventory using arrays, strings, and vectors.

Arrays (4.1)

Game map, room data, player stats

Strings (4.2)

Descriptions, commands, parsing

Vectors (4.3)

Dynamic inventory, item collection

02

The Scenario

The Mysterious Mansion

Create "The Mysterious Mansion" - a text adventure where players explore a haunted mansion, collect keys and items, solve puzzles, and try to escape.

03

Requirements

1
Game Map (2D Array)

Create a 5x5 grid representing mansion rooms. Each cell contains room type (0-5 for different rooms).

2
Room Descriptions (String Array)

Store descriptions for each room type. Use string manipulation for dynamic messages.

3
Inventory System (Vector)

Use vector<string> for player inventory. Implement add, remove, display, search operations.

4
Command Parser

Parse commands like "go north", "take key", "use lantern", "inventory", "look".

5
Game State

Track player position, health, visited rooms (bool array), and win/lose conditions.

04

Submission

Required Repository Name
cpp-text-adventure
cpp-text-adventure/
├── game.cpp            # Main game file
├── game.h              # Header with declarations
├── sample_output.txt   # Sample gameplay
└── README.md           # How to play guide
05

Grading Rubric

CriteriaPoints
Game Map (2D array)30
Room System (string arrays)30
Inventory (vector operations)40
Command Parser (string manipulation)35
Game Logic & Win Condition35
Code Quality30
Total200