Exemplo n.º 1
0
int main()
{
  bool bCont = true;
  char strCont = 'y';

  while (bCont)
  {
    objScreen.clearScreen();
    objScreen.moveCursor(0, 0);
    cout.flush();

    buildArray();
    printArray();

    if (aBoard[0][0][0].value == ' ')
    {
      objScreen.printChar('-', aBoard[0][0][0].x, aBoard[0][0][0].y, 32, 0, 0, 25000);
    }

    if (mazeMe(0, 0, 0))
    {
      objScreen.printString("Puzzled Solved!", 1, 22, 25000);
    }
    else
    {
      objScreen.printString("Puzzle Unsolvable.", 1, 22, 25000);
    }

    objScreen.moveCursor(0, 23);
    cout.flush();

    objScreen.printString("Do you want to play another game (y/n)? ", 1, 23, 25000);
    cin >> strCont;

    if (strCont == 'n')
    {
      bCont = false;
    }

    cin.ignore(1000, '\n');
  }

  return 0;
}
Exemplo n.º 2
0
void buildArray()
{
  ifstream is;
  char file[256];

  objScreen.printString("Please input file name: ", 1, 1, 25000);
  cin.get(file, 256);

  is.open(file);

  int x[5] = {20, 32, 44, 56, 68};
  int y[5] = {5, 6, 7, 8, 9};

  for (int plane = 0; plane <= 4; plane++)
  {
    for (int row = 0; row <= 9; row++)
    {
      for (int column = 0; column <= 10; column++)
      {
        aBoard[row][column][plane].value = is.get();
        aBoard[row][column][plane].x = x[plane] + column;
        aBoard[row][column][plane].y = y[plane] + row;
      }

      x[plane]--;
    }
  }

  is.close();

  int nIndex = 0;
  for (int i = -1; i <= 1; i++)
  {
    for (int j = -1; j <= 1; j++)
    {
      for (int k = -1; k <= 1; k++)
      {
        aMoves[nIndex].row = i;
        aMoves[nIndex].column = j;
        aMoves[nIndex].plane = k;
        nIndex++;
      }
    }
  }
}