#pragma once #include using namespace std; class gameBoard { public: //Variables/attributes int score; //Current score! int pacRow; //location of PacPerson int pacCol; int rows = 10; int columns = 15; char boardarray[10][15]; int pointsPerPellet; //Constructor gameBoard() { //Initialize board locations to pellets for (int r = 0; r < rows; r++) { for (int c = 0; c < columns; c++) { boardarray[r][c] = '.'; } } //Initialize score score = 0; //Initialize pacperson location pacRow = 5; pacCol = 7; boardarray[pacRow][pacCol] = 'P'; //Points per pellet? pointsPerPellet = 10; } void printBoard() { //Print current score cout << "Score: " << score << endl; //Print all cells of the array for (int r = 0; r < rows; r++) { for (int c = 0; c < columns; c++) { cout << boardarray[r][c] << " "; } cout << endl; } } //Given "u", "d", "l", or "r", //Move pac-person accordingling void move(string direction) { boardarray[pacRow][pacCol] = ' '; if (direction == "u") { pacRow--; } else if (direction == "d") { pacRow++; } else if (direction == "r") { pacCol++; } else if (direction == "l") { pacCol--; } else //Typed in something weird.. { } //Let's see if we score a new pellet if (boardarray[pacRow][pacCol] == '.') { score = score + pointsPerPellet; } boardarray[pacRow][pacCol] = 'P'; } };