Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i am getting a lot of errors in this question could you please send me complete solution file. This Assignment is independent of any course.

i am getting a lot of errors in this question could you please send me complete solution file.

This Assignment is independent of any course. The goal of this assignment is to build a simple board game that runs in the console. The player starts at the top left and needs to move left, right, up, and down, until they get to the bottom right using WASD. There are some deadly blocks hidden on the board. The player must reach the end while not being hit by all of them. See the attached A1.exe file (it is zipped because BB does not allow me to upload .exe file). Run the game and play it. What I am looking for in your submission:

Base (max 80% of the assignment grade):

You will create at least five files for this assignment: Game.h, Game.cpp, GameObject.h, GameObject.cpp, Main.cpp

Create a GameObject class (declaration in GameObject.h, implementation in GameObject.cpp):

Protected attribute:

symbol (that is the symbol for the game object that gets displayed)

Public methods:

void setSymbol(char s): set the game object symbol

char getSymbol(): return the game object symbol

Create a UserPlayer class that is a child of the GameObject class (declaration in GameObject.h, implementation in GameObject.cpp):

Private attribute:

x, y (the location of the player)

Public methods:

void setLocation(int x_, int y_): set the attributes x, y

int getX(): return the x location

int getY(): return the y location

Create a Game class (declaration in Game.h, implementation in Game.cpp):

Private attributes (required):

width = 15 (the width of the game board)

height = 10 (the height of the game board)

gameBoard[10][15] (the game board consisting of symbols)

numDeadBlock = 10 (how many deadly blocks are there)

player (UserPlayer object for this game)

block (GameObject object for the empty slots)

Private attributes (optional):

numHit = 0; (how many times the player got hit)

deadBlockLocation[10][2]; (an 2D array of the location of the deadly blocks. You can hardcode this, i.e., explicitly specify the location)

Public methods (required):

Game(UserPlayer p_, GameObject b_): constructor (you may add extra parameters)

void printGameBoard(): print the game board on the screen

void playGame(): runs the game fully by asking the user for input (wasd or q to quit), moving the player if the move is valid, printing the game board after every round, checking if the user has hit a hidden deadly block. It also stops the game when the user is at the end of the board, i.e., bottom right (Hint, when this condition happens, simply write return;. This will exit the whole method). You may want to call print GameBoard and withinBorders methods here.

Public methods (optional):

bool withinBorders(int x, int y): check of x and y are within the game borders.

In the main function (in Main.cpp):

Create a UserPlayer object (for the player)

Create a GameObject object (for empty blocks).

Create a Game object.

Call the playGame method for the game object.

Enhancement (20%):

Create the deadly blocks at random locations (Hint: use the built-in rand() function. In the main function, write down srand((unsigned int)time(nullptr)); before you create the game. This statement tells the compiler to generate more randomized numbers.)

Make what you print in the console colorful! Give every game object in the game a color.

Notes:

Make sure declarations are done in header files (.h) and implementations are done in cpp files (.cpp).

Add description for your classes/methods.

You may add other public/private attributes and methods and even classes. You may do other things in your main function (e.g., ask the user for their name).

You may change the value of the attributes. The ones I gave you just make a simple yet challenging game.

You may use any built-in library.

The optional attributes/methods are ones I used for my solutions to make my code more concise. You may find them useful.

You may add extra features (e.g., add walls that block the player).

During the class, I taught you how to use draw a board in the console and get user input without the need to press enter. You are more than welcome to use that or you can implement your own (e.g., use cin).

You may NOT CHANGE the structure. The goal of the assignment is to have multiple classes (at least 3), implement inheritance, and use an object of type class we built as an attribute in another class. Moreover, you must get used to distributing code across multiple files.

If you put all your code in main, it will be an automatic zero.

If you are up for a challenge, instead of making the attribute gameBoard consists of characters, make it consist of pointers to GameObject objects such that every block is an empty block of GameObject while the player is of type UserPlayer(we can do this because UserPlayer is a child of GameObject). We will start talking about pointers on week 5.

What to submit:

Game.h

GameObject.h

Game.cpp

GameObject.h

Main.cpp

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 Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

More Books

Students also viewed these Databases questions

Question

List the nodes in decision trees.

Answered: 1 week ago

Question

Was there an effort to involve the appropriate people?

Answered: 1 week ago