Answered step by step
Verified Expert Solution
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 dragons on random locations in the game area
Place treasure piles on locations where both x and y are odd
Place 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 heshe 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, hisher treasure amount increases if heshe
can correctly guess digit number randomly generated number. When the player visits a location having
a dragon, heshe 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, heshe
gains some game points; otherwise, heshe loses some game points. When the player visits a location
having a trap, heshe loses some of hisher treasure. You can determine the number of points to
losegain and the amount of treasure to lose by yourself. The game finishes when the player enters one
of the exits. If heshe enters the Escape Exit print hisher total game points. If heshe enters the Cliff
Exit heshe 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 subtasks 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 x int y int x int y int x int y int x int y int x int y int xplayer, int yplayer
that gets all the dragons location and the players location and returns true if there is a dragon at the
players location.
isTrapint x int y int x int y int x int y int xplayer, int yplayer that gets the trap locations
and players location and returns true if there is a trap at the players location.
isTreasureint xplayer, int yplayer that gets the players location and returns true if there are some
treasure at the players location.
isEscapeExitint x int y int xplayer, int yplayer that gets the location of the Escape Exit and the
players location and returns true if the player is at the Escape Exit.
isCliffExitint x int y int xplayer, int yplayer that gets the location of the Cliff Exit and the players
location and returns true if the player is at the Cliff Exit.
canMoveint xplayer, int yplayer, char direction that gets the location of the player and the direction
heshe 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.
generateDigitNum that generates a 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started