Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this project, you will design and implement a game in which we have dragons and treasure in a diamond shaped cavern ( game area

In this project, you will design and implement a game in which we have dragons and treasure in a
diamond shaped cavern (game area). The size of the game area is fixed. You will have a game area as
follows:
In the game area, you will have the following characters, items and rules;
Place 5 dragons on random locations in the game area
Place treasure piles on locations where both x and y are odd
Place 3 traps on random locations (make sure that you do not place both dragon and trap on the
same location)
Place two exits on random locations in the game area: one exit opens to the escape route, the
other opens to cliff.
Only gray cells are locations that the player is allowed to move into.
The player can move in any direction (user inputs for moving are w: up, s: down, a: right, d: left)
depending on the players current position. For example, if the player is at location (4,1), he/she can
move to the right but not move to the left, down and up. At the beginning of the game, the player has no
treasure. When the player visits a location having a treasure, his/her treasure amount increases if he/she
can correctly guess 4-digit number randomly generated number. When the player visits a location having
a dragon, he/she bribes the dragon with a portion of their treasure. The amount of treasure used for
bribe will be determined randomly. If the player has enough treasure for bribing the dragon, he/she
gains some game points; otherwise, he/she loses some game points. When the player visits a location
having a trap, he/she loses some of his/her treasure. You can determine the number of points to
lose/gain and the amount of treasure to lose by yourself. The game finishes when the player enters one
of the exits. If he/she enters the Escape Exit, print his/her total game points. If he/she enters the Cliff
Exit, he/she will lose all treasure and lose the game. After each move as the output, print the current
location of the player, the current amount of treasure, the number of dragons visited since the beginning
of the game, total game points, etc. At the end of the game, print the game area showing dragons, traps,
treasure, exits, etc.
Your solution must be modular since you must define sub-tasks and implement methods. You have to
write the following basic methods in your program and use them. You must also write other methods
that you design.
- isDragon (int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int x5, int y5, int x_player, int y_player)
that gets all the dragons location and the players location and returns true if there is a dragon at the
players location.
- isTrap(int x1, int y1, int x2, int y2, int x3, int y3, int x_player, int y_player) that gets the trap locations
and players location and returns true if there is a trap at the players location.
- isTreasure(int x_player, int y_player) that gets the players location and returns true if there are some
treasure at the players location.
- isEscapeExit(int x, int y, int x_player, int y_player) that gets the location of the Escape Exit and the
players location and returns true if the player is at the Escape Exit.
- isCliffExit(int x, int y, int x_player, int y_player) that gets the location of the Cliff Exit and the players
location and returns true if the player is at the Cliff Exit.
- canMove(int x_player, int y_player, char direction) that gets the location of the player and the direction
he/she wants to go and returns true if it is possible to go in that direction (if there is a cell in that
direction on the game area); otherwise returns false.
- generate4DigitNum () that generates a 4-digit positive integer and asks the player to guess this
number, gets the answer, checks the answer and return true if the answer is true; otherwise, false.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions