Creating a treasure hunt game in c++. Use the pdf file to complete the hw05.zip files. the .zip files contain .cpp and .h flies.
ECGR2104: Spring 2020 Homework 5 Due: 04/28/2020 Points: 200 1 General Instructions This coding homework should be completed individually (NOT A GROUP ASSIGNMENT). The template files is available in canvas. NOTE: The files have dependencies. DO NOT change the makefile. The assignment will NOT be accepted if the file structure is not followed 1.1 Compilation To compile the cpp file: • Open the Terminal • Make sure you are in the directory of the cpp file • Execute the below command to compile make • On successful compilation, execute the code by below command ./treasure 1.2 Important Linux Commands • ls – lists all contents of the current directory • pwd – prints the “path” of your current directory • cd – change directory • make – compiles file using makefile 1 2 Coding Problem 1. [200 pts] You will be a creating a “treasure hunt” game where a player explores a virtual map looking for treasure. This will be a text based game, so the terminal will be utilized for describing the player’s surrounding and exploration options. This will be a randomly generated game, where each play will have a random map/world for the player to explore. The goal of the game is for the player to find the hidden ruins and discover the treasure before running out of energy. The core of this game is exploring a map with different types of “Lands”. There will be four different kinds of lands to explore, such as forests, deserts, orchards, lakes, and ruins. The player will have a set x,y position within the map, and each turn will be given the option to explore north, south, east, or west. To start with a map of a certain dimension will be constructed (default dimension is 10 × 10). Player will be placed in the middle of map (default is at 5 × 5) with en- ergy level set to 5 . The user will be provided with the description on what is seen in NORTH, SOUTH, EAST, and WEST direction. The sample descriptions are as follows: You see , a tropical dense forest to the north , an orchard filled with apples to the south , a water body to quench your thirst to the west , an arid hot desert to the east. Then the user will make a choice on which direction to move. Depending on the move the user will either increase the energy or decrease the energy and an outcome will be described. The energy level and description are as follows: Land Outcome Energy Level Desert You walk through the hot and dry desert Decrements by 2 Forest You trek through the dense forest Decrements by 1 Orchard You eat an apple in the orchard Increment by 2 Lake You are hydrated Increment by 1 After each turn, a banner is displayed which details the current energy level of the user. The game ends when the user runs out of the energy or finds the treasure. 2 2. Implementation To implement you will use the following files: • Player : Player.h consists of the definition of the Player class and the implemen- tation is done in Player.cpp • Land : Land.h consists of an Abstract class (pure virtual function) and Derived class for Desert, Forest, Orchard, Lake, and Ruins. • gameEngine.cpp : Creates the map using a random number generator, and con- trols the game through a Player object • treasure : treasure.h is the game header which includes all the necessary header. treasure.cpp creates the Player object and calls the gameEngine function Description: • Player class will contain (minimal) – the current x and y position, energy level, treasure found or not. Write acces- sors and mutators to access these data members – the map dimension. This should be a static private member and add a public static function to access the data – the player movement function. These function (one for each direction North, South, East, South) will increment or decrement depending on player move- ment. Make sure to check the boundaries else will result in segmentation fault • Land class will contain – An abstract class with two pure virtual function. One for the description and the other for player visit – derived classes (derived form Land) for Forest, Orchard, Desert, Lake, and Ruins. In each derived class the description and player visit function is re- defined. The player visit function requires Player object to increment and decrement the energy level • GameEngine will contain – a two dimensional map of all the Land. Use the upcasting technique to create a variable (Remember Land is an Abstract class you CANNOT have a valued object of Land) – map is defined using random variable generator. (Use random library and NOT time rand() function) – a loop for game runtime which displays the description, gets the user input, and displays the outcome until the energy is exhausted, or user finds the treasure, or user press Q (Q for QUIT) 3 3 Deliverable There is no demo for this lab. Instead you turn in the following: 1. Upload all the cpp and h file (do not upload the makefile) 2. Take a screenshot of your output showing at least two turns and upload it to Canvas (in PNG) 4 General Instructions Compilation Important Linux Commands Coding Problem Deliverable