#include #include using namespace std; #include "Grid.h" // randomly generate grid and start score at 0 // Ensure player and enemies start at different places // define the functions for grid char Grid::getDirection() { cout << "Where do you want to go?" << endl; cout << "Please enter u for up, r for right, d for down, l for left, or m " "for a random direction." << endl; cin >> direction; return direction; } //2D array using subtraction in direction /* int Grid::move(int room, char direction) { } */ // 2D array using subtraction in direction int Grid::move(int room, char direction) { if (direction == 'u') { if ((room == 3) || (room == 2) || (room == 1)) { } else { room = room - 3; } } else if (direction == 'r') { if ((room == 3) || (room == 6) || (room == 9)) { } else { room = room + 1; } } else if (direction == 'd') { if ((room == 7) || (room == 8) || (room == 9)) { } else { room = room + 3; } } else if (direction == 'l') { if ((room == 1) || (room == 4) || (room == 7)) { } else { room = room - 1; } } else if (direction == 'm') { room = move(room, getRandDirection()); } else { cout << "Invalid entry. Please input valid entry. "; room = move(room, getDirection()); } return room; } char Grid::getRandDirection() { otherDirection = rand() % 4 + 1; if (otherDirection == 4) { return 'u'; } else if (otherDirection == 2) { return 'r'; } else if (otherDirection == 3) { return 'd'; } else { return 'l'; } } /*void Grid::printGrid(int player, int bosses) { char grid[10]; for (int i = 0; i < 10; i++) { grid[i] = '.'; } grid[player] = 'P'; grid[bosses] = 'B'; cout << grid[1] << grid[2] << grid[3] << endl; cout << grid[4] << grid[5] << grid[6] << endl; cout << grid[7] << grid[8] << grid[9] << endl; }*/ // 2D array print inside a nested loop void Grid::printGrid(int GridRows, int GridColumns) {//are these the appropriate parameters? char grid[GridRows][GridColumns];//sets max spaces in grid; 16 spaces max for(int i = 0; i < GridRows; i++) { for (int j = 0; j < GridColumns; j++) { grid[i][j] = '.'; cout << grid[i][j]; } cout << endl; } }