Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C + + PLEASE Assignment 5 C: Level Map Creator. There are a variety of ways that game developers store their level layouts. One simple

C++ PLEASE Assignment 5C: Level Map Creator. There are a variety of ways that game developers store their level layouts. One simple method is to associate level elements with certain symbols, and then storing them in a 2D grid inside a text file. We will use our knowledge of 2D arrays to create a very simple Level Map Creator tool. The program should prompt the user to enter a width and height for the level. Then it should initialize a 2D array and fill every element with the *** symbol. Afterwards, the user should be given the following options via a menu: 1. Clear Level 2. Add Platform 3. Add Item Re-initialize the 2D array and fill every element with the *** symbol. Prompt the user to enter a starting point and length for the horizontal platform. Replace those elements in the 2D array with the "=" symbol. If the length is longer than the number of columns (or out of bounds), notify the user that this is not possible. Prompt the user to enter a column and row index. Replace that element in the 2D array with the "0" symbol. If the column and row index in outside the bounds of the array, notify the user that this is not possible. End the program 4. Quit: After completing the task, print the modified 2D array, If anything other than Quit is selected, display the menu again. Otherwise, tell the player "Good byel and stop, Hints: Since we're using a 2D array to represent the level map, we'll use its indexes for our level coordinates. 0,0 will be the top-left corner of the map, and will correspond to array[0][0] Sample Output : [FYE Level Map Creator) Enter a level map width: 20 Enter a level map height: 6
Hello, I've done the question above, but am running into an error in case 2 of my switch statement. Could you tell me how to relsolve the issue in C++?
My code:
{
int xi?? defines x coordinate
int yi?? defines y coordinate
string player ="P"; //deines the symbol for case 3
string platform ="="; //deines the platform symbol
int choice; //players choice of action
string symbol ="-";
int width;//defines user inouted width
int height; //defines user inputed height
cout "[FYE Level Map Creator]??
;
cout "Enter a level map width: ";
cin width;
cout "Enter a level map height: ";
cin height;
string** array = new string *[height]; //creates a dynamic 2D array
for (int i=0;i height; i++
array[i]= new string[width];
for (int j=ij width; j++){
array[i][j]= symbol;
}
do {
for (int i=0;i height; i++ prints the current arry
for (int j=0;j width; j++){
cout array[i][j];
}
cout ?
;
}
cout "Options ??
;
cin choice;
switch (choice){
case 1: //creates a code silar to above and reenters the sybol for each part
for (int i=0;i height; i++){
array[i]= new string[width];
for (int j=0ij width; j++){
array[i][j]= symbol;
}
}case 2:
int length; //defines length of platform
//ask user for input info
cout "
[Add Platform]
";
cout "Enter X Coordinate: ";
cin x;
cout "Enter Y Coordinate: ";
cin y;
cout "Enter a Length: ";
cin length;
//statements for what this input can be
if (x> width ||y> height){
cout "This is not a valid location!
";
break;
}
else if (length > width){
cout "This platform won't fit in the level!
";
}
break;
//assign new values to array
for (int z=0;z length; z++){
array [x][y]= platform;
}
y++;
break;
case 3 :
cout "[Add Item]??
;
cout "Enter x Coordinate: ";
cin x;
cout "Enter Y Coordinate: ";
cin y;
array[y][x]= player;
}
} while (choice !=4);
cout "
Goodbye!";
}
image text in transcribed

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

Students also viewed these Databases questions

Question

Describe the new business planning process.

Answered: 1 week ago

Question

Explain the factors influencing wage and salary administration.

Answered: 1 week ago

Question

Examine various types of executive compensation plans.

Answered: 1 week ago

Question

1. What is the meaning and definition of banks ?

Answered: 1 week ago

Question

2. What is the meaning and definition of Banking?

Answered: 1 week ago

Question

Methods of Delivery Guidelines for

Answered: 1 week ago