How do I move on to the next maze?

Hello everyone, I need to know how to move on to the next maze. Should I create a new function or do I have to use if?



#include<iostream>
#include<conio.h>
#include<Windows.h>
#include<stdio.h>
#include<string.h>
using namespace std;


//Global Variables
char inputKey;
void gotoXY(int, int);
void movement();
void displaymaze1();
void displaymaze2();


int mapArrayOne[20][35] =
{
{ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
{ 1,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 },
{ 1,1,1,0,0,1,1,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1 },
{ 1,1,1,0,0,1,1,1,0,0,1,0,0,1,0,0,1,1,1,1,1,0,0,1,1,1,1,1,1,1,1,0,0,1,1 },
{ 1,1,1,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1 },
{ 1,1,1,0,0,1,1,1,1,1,1,0,0,1,1,1,1,0,0,1,1,1,1,1,1,1,1,0,0,1,1,0,0,1,1 },
{ 1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,1,1,1,1,1,0,0,1,1,0,0,1,1 },
{ 1,0,0,1,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,0,0,1,1 },
{ 1,0,0,1,1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,1,1 },
{ 1,0,0,1,1,1,1,0,0,1,1,1,0,0,1,1,1,0,0,1,1,0,1,1,1,1,1,1,1,1,1,0,0,1,1 },
{ 1,0,0,1,1,1,1,0,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0,1,1,1,1,1,1,1,1,0,0,1,1 },
{ 1,0,0,1,1,1,1,0,0,1,1,1,1,1,1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2,2 },
{ 3,2,2,3,3,2,2,3,3,3,3,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,3,3,2,2,3,3,3,3,3,2,2,3,3,2,2,3 },
{ 3,2,2,3,3,2,2,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,3 },
{ 3,2,2,3,3,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,2,2,3,3,3,2,2,3,3,3,3,3,3,3,3,3,3,2,2,3,3,3,3,3,3,3 },
{ 3,2,2,3,3,2,2,3,3,3,3,3,3,3,3,2,2,3,3,3,3,3,3,3,2,2,3,3,3,2,2,3,3,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3 },
{ 3,2,2,3,3,2,2,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,3,3,3,2,2,3,3,3,3,3,3,3,3,3,3,2,2,3,3,3,3,3,3,3 },
{ 3,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,3,2,2,2,3,3,3,3,3,3,3 },
{ 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3 }
};

void displaymaze2()
{
for (int row = 0; row < 30; row++)
{
for (int column = 0; column < 50; column++)
{
switch (mapArrayTwo[row][column])
{

case 2:
cout << " ";
break;
case 3:
cout << char(219);
break;
}

}

cout << endl;
}
}


void displaymaze1()
{
for (int counter = 0; counter < 20; counter++)
{
for (int probably = 0; probably < 35; probably++)
{
switch (mapArrayOne[counter][probably])
{
case 0:
cout << " ";
break;
case 1:
cout << char(219);
break;
case 2:
cout << " ";
break;
}

}




}

}

void gotoXY(int x, int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}

void movement() {

int x = 1;
int y = 1;
int xBefore = 1;
int yBefore = 1;


while (true) {
gotoXY(xBefore, yBefore);
cout << " ";
gotoXY(x, y);
cout << char(2);
inputKey = _getch();

xBefore = x;
yBefore = y;
if (inputKey == 'w') { y -= 1; }
else if (inputKey == 's') { y += 1; }
else if (inputKey == 'a') { x -= 1; }
else if (inputKey == 'd') { x += 1; }

if (mapArrayOne[y][x] == 1) {

y = yBefore;
x = xBefore;



}




}

}









int main()
{
int d = 0;
char n;

cout << "----------THE MAZE GAME----------" << endl;
cout << endl;
cout << "----THE RULES----" << endl;
cout << "1) Reach to the end of the maze in a desired amount of time" << endl;
cout << "2) There will be two mazes in the game" << endl;
cout << "3) The sooner you finish the maze the more points you get" << endl;
cout << "4) You can also get bonus points depending on your difficulty" << endl;
cout << "5) You will complete the game if you clear both mazes in a desired amount of time" << endl;
cout << endl;
cout << endl;
cout << "----DIFFICULTY----" << endl;
cout << "Press from 1-3 to choose difficulty" << endl;
cout << "1) Easy (90 seconds)" << endl;
cout << "2) Medium (45 seconds)" << endl;
cout << "3) Difficult (30 seconds)" << endl;

cin >> d;

switch (d)
{
case 1:
cout << "Get ready to play" << endl;
cout << endl;
system("CLS");
displaymaze1();
movement();








break;
case 2:
cout << "Get ready to play" << endl;
cout << endl;
break;
case 3:
cout << "Get ready to play" << endl;
cout << endl;
break;
}



return 0;

}

One way would be to create a class Map and store the maps in a vector.
You would need only one int to store the index of the current map and can easily switch between different maps.
Topic archived. No new replies allowed.