I am new to coding in C++, and I'm getting frustrated at this program. The objective is to upload a lbf file from within the file and move the '@' character around the 'level'. 0 to move forward, 1 to rotate right, 2 to move backwards, 3 to rotate left and 4 to 'toggle' (change the ? character into a * character). I am aware that I would need a new case etc, just any help!
From the main source code, I have created more cpp and header files, that store the voids, chars etc. But due to the limited length, I can't post it.
Any help would be appreciated. Thanks!
note: I wouldn't mind if any help is connected to the project or new code, just an example of what I need.
//Include the Header files, which will connect amongst all the files.
#include "Level1.h"
#include "CommandQueue.h"
#include "executeCommand.h"
using namespace std;
#define TRUE 1
#define FALSE 0
char currentLevel[64][64];
int main()
{
int height, width, posX, posY, menuRepeat;
int userSelection;
//The list of classes, which are created in the header files, which store various chars and void.
Level1 level;
CommandQueue Command;
//Allows the menu to loop, unless option 3 is entered.
menuRepeat = TRUE;
do
{
cout << "\nWhat do you want to do? \n1. Load Level \n2. Print Level (Only use after option 1!)\n3. Quit \n4. Display Commands\n5. Display Current Queue (Only use after Option 4!)\nYour option: ";
cin >> userSelection;
//The menu, with the only option not to loop the menu is case 3.
switch (userSelection)
{
case 1: menuRepeat = level.Loadlevel(height, width, posX, posY);
break;
case 2: level.Printlevel(height, width, posX, posY);
break;
case 3: menuRepeat = FALSE();
break;
case 4: Command.ArrayList();
break;
case 5: Command.Displayed();
break;
}
} while (menuRepeat == TRUE);
//The function which loops the menu.
return 0;
}
int Level1::Loadlevel(int& height, int& width, int& posX, int& posY)
{
int row, col, result;
char currentChar;
//currentChar is @, row is Y (down) and col is X (across).
string input;
cout << "\nPlease enter file name, level1.lbf or level2.lbf: ";
cin >> input;
ifstream file;
//level1.lbf and level2.lbf are both stored in the Project file.
file.open(input, ifstream::in);
if (file.is_open())
{
file >> height;
file >> width;
//File's row and col is stored in an Array
for (int row = 0; row < height; row++)
{
for (int col = 0; col < width; col++)
{
file >> currentChar;
{
//row is up until 3 for level1 and up until 2 for level2
for (int row = 0; row < height; row++)
{
//col is up until 3 for level1 and up until 2 for level2
for (int col = 0; col < width; col++)
{
if (posX == row && posY == col)
{
cout << ("@");
}
else
{
cout << currentLevel[row][col];
}
}
cout << endl;
}
}
int Level1::Updateposition()
{
return 0;
}
void CommandQueue::ArrayList()
{
//The menu option which the user inputs 10 commands.
cout << "\n";
cout << "List of Actions (10 moves required!):" << endl;
cout << "_____________________________________" << endl;
std::cout << "Move Forward: " << anArray[0] << endl;
std::cout << "Move Left: " << anArray[1] << endl;
std::cout << "Move Right: " << anArray[2] << endl;
std::cout << "Toggle Light: " << anArray[3] << endl;
cout << "\n";
//Various commands that the user needs to Input for the UserInput to work.
do
{
cout << "Enter 1st Command: ";
cin >> UserInput;
//An if statement if the User inputs the incorrect command. The menu will break if the user inputs a wrong command.
if(UserInput != anArray[0] && UserInput != anArray[1] && UserInput != anArray[2] && UserInput != anArray[3])
{
std::cout << "Incorrect Input. Returning to Menu.\n";
break;
}