Thank you very much all of you for your fast replies! I used a lot of your suggestions and finally got the code working. I'll post the code below for viewing enjoyment.
Thanks again!
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define ROW 8
#define COL 8
int score = 0; //Score that will be incremented
int prevScore = 0; //Comparison Score
int input;
int array_disp = 0;
int num = 0;
int left[ROW][COL] = {{0,0,0,1,1,0,0,0}, //Left Arrow
{0,0,1,1,0,0,0,0},
{0,1,1,0,0,0,0,0},
{1,1,0,0,0,0,0,0},
{1,1,0,0,0,0,0,0},
{0,1,1,0,0,0,0,0},
{0,0,1,1,0,0,0,0},
{0,0,0,1,1,0,0,0}};
int right[ROW][COL] = {{0,0,0,1,1,0,0,0}, //Right Arrow
{0,0,0,0,1,1,0,0},
{0,0,0,0,0,1,1,0},
{0,0,0,0,0,0,1,1},
{0,0,0,0,0,0,1,1},
{0,0,0,0,0,1,1,0},
{0,0,0,0,1,1,0,0},
{0,0,0,1,1,0,0,0}};
int up[ROW][COL] = { {0,0,0,1,1,0,0,0}, //Up Arrow
{0,0,1,1,1,1,0,0},
{0,1,1,0,0,1,1,0},
{1,1,0,0,0,0,1,1},
{1,0,0,0,0,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,0,0}};
int down[ROW][COL] = { {0,0,0,0,0,0,0,0}, //Down Arrow
{0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0},
{1,0,0,0,0,0,0,1},
{1,1,0,0,0,0,1,1},
{0,1,1,0,0,1,1,0},
{0,0,1,1,1,1,0,0},
{0,0,0,1,1,0,0,0}};
int win[ROW][COL] = { {0,0,0,0,0,0,0,0}, //Array displayed if the player wins, Not implemented yet
{0,1,1,0,0,1,1,0},
{0,1,1,0,0,1,1,0},
{0,1,1,0,0,1,1,0},
{0,1,1,0,0,1,1,0},
{0,1,1,1,1,1,1,0},
{0,1,1,0,0,1,1,0},
{0,1,0,0,0,1,1,0}};
int lose[ROW][COL] = { {0,1,1,0,0,0,0,0}, //L displayed if the player loses
{0,1,1,0,0,0,0,0},
{0,1,1,0,0,0,0,0},
{0,1,1,0,0,0,0,0},
{0,1,1,0,0,0,0,0},
{0,1,1,0,0,0,0,0},
{0,1,1,1,1,1,1,0},
{0,1,1,1,1,1,1,0}};
//displayArray takes in an array 8x8 in size and prints it to
//the Serial Monitor
void displayArray(int array[8][8]) {
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
Serial.print(array[i][j]);
Serial.print(" ");
}
Serial.print("\n");
}
};
//clearScreen prints 20 new lines to clear the Serial Montor Scree
void clearScreen(){
for(int i = 0; i<20;i++){
Serial.println();
}
};
//checkInput takes in a character and an integer.
//Using a switch statement, the character is compared to a few cases.
//Within each case the the supplied integer is checked against another
//integer and if they match the score variable is incremented.
void checkInput(int in, int y) {
switch (in) {
//w
case 119:
if (y == 1) { score++; }
break;
//a
case 97:
if (y == 4) { score++; }
break;
//s
case 115:
if (y == 2) { score++; }
break;
//d
case 100:
if (y == 3) { score++; }
break;
default:
break;
}
};
void generateDirection(){
int array_disp = num = random(1,4);
displayRandom(array_disp);
};
//randomWork takes in an integer and displays an array based
//based on the integer supplied.
void displayRandom(int x){
switch (x) {
case 1:
displayArray(up);
break;
case 2:
displayArray(down);
break;
case 3:
displayArray(right);
break;
case 4:
displayArray(left);
break;
default:
Serial.print("You Should Not See This");
break;
}
};
//countDown displays a countdown to the start of the game.
void countDown(){
Serial.println("The Game will begin in: ");
for(int i=1; i<4;i++){
Serial.println(i);
delay(1000);
}
Serial.println("GO!");
};
//Checks to see if the score has changed, that determines whether or
//not the player continues or loses.
void scoreCheck(){
if (prevScore == score) {
clearScreen();
displayArray(lose);
Serial.println("Game Over, good try!!!");
Serial.print("Score: ");
Serial.print(score);
score = 0;
prevScore = 0;
delay(1000);
}
else {
prevScore = score;
}
};
void setup() {
Serial.begin(115200); //Start serial communication
randomSeed(analogRead(0)); //create a random seed for random()
countDown(); //Start the countdown to the game starting
generateDirection(); //generate the first direction to be displayed
};
void loop(){
if (Serial.available()>0){
input = Serial.read();
checkInput(input,num); //Use checkInput to see if the score gets incremented
delay(500);
scoreCheck(); //Check to see if the scores have changed
clearScreen(); //Clear the screen
generateDirection();
}
}