Commit b8ead0ee authored by AlaskaLinuxUser's avatar AlaskaLinuxUser

Game state 5/6, win/lose screens.

parent ad8e008c
......@@ -38,6 +38,7 @@ int gameAsteroidOne = 14; // First asteroid starting space.
int gameAsteroidTwo = 25; // Second asteroid starting space.
int gameAsteroidThree = 17; // Third asteroid starting space.
int gameAsteroidFour = 23; // Fourth Asteroid starting space.
int gameDelay = 0; // A time delay factor.
/*
* Game states:
......@@ -127,7 +128,7 @@ void loop(){
lcd.print(" Select = Start ");
gameLineNum = 1;
}
int gameDelay = 0;
gameDelay = 0;
while (gameDelay < 2000){
// Add a delay in the loop.
delay(1);
......@@ -183,7 +184,7 @@ void loop(){
lcd.print("AlaskaLinuxUser!");
gameLineNum = 1;
}
int gameDelay = 0;
gameDelay = 0;
while (gameDelay < 2000){
// Add a delay in the loop.
delay(1);
......@@ -244,7 +245,7 @@ void loop(){
lcd.print("by up/down bttns");
gameLineNum = 1;
}
int gameDelay = 0;
gameDelay = 0;
while (gameDelay < 2000){
// Add a delay in the loop.
delay(1);
......@@ -343,76 +344,92 @@ void loop(){
if (gameState == 5) { // Win state.
// The player has won the game, let's tell them.
lcd.setCursor(9,1); // move cursor to second line "1" and 9 spaces over
lcd.print(millis()/1000); // display seconds elapsed since power-up
lcd.setCursor(0,1); // move to the begining of the second line
lcd.setCursor(0,0); // set the LCD cursor position
lcd.print("Asteroids Game! ");
lcd.setCursor(0,1); // move to the begining of the second line
lcd.print(" YOU WIN ");
if (gameLineNum == 2) {
lcd.setCursor(0,0); // set the LCD cursor position
lcd.print(" Select for Menu");
lcd.setCursor(0,1); // move to the begining of the second line
lcd.print("Asteroids Game! ");
gameLineNum = 0;
} else if (gameLineNum == 1) {
lcd.setCursor(0,0); // set the LCD cursor position
lcd.print(" YOU WIN ");
lcd.setCursor(0,1); // move to the begining of the second line
lcd.print(" Select for Menu");
gameLineNum = 2;
} else if (gameLineNum == 0){
lcd.setCursor(0,0); // set the LCD cursor position
lcd.print("Asteroids Game! ");
lcd.setCursor(0,1); // move to the begining of the second line
lcd.print(" YOU WIN ");
gameLineNum = 1;
}
gameDelay = 0;
while (gameDelay < 2000){
// Add a delay in the loop.
delay(1);
gameDelay++;
lcd_key = read_LCD_buttons(); // read the buttons
switch (lcd_key){ // depending on which button was pushed, we perform an action
case btnRIGHT:{ // push button "RIGHT" and show the word on the screen
lcd.print("RIGHT ");
break;
}
case btnLEFT:{
lcd.print("LEFT "); // push button "LEFT" and show the word on the screen
break;
}
case btnUP:{
lcd.print("UP "); // push button "UP" and show the word on the screen
break;
}
case btnDOWN:{
lcd.print("DOWN "); // push button "DOWN" and show the word on the screen
break;
}
case btnSELECT:{
lcd.print("SELECT"); // push button "SELECT" and show the word on the screen
break;
}
case btnNONE:{
lcd.print("NONE "); // No action will show "None" on the screen
break;
}
}
switch (lcd_key){ // depending on which button was pushed, we perform an action
case btnSELECT:{
gameState = 0;
gameLineNum = 0;
break;
}
}
}
} // End gameState 5, win state.
if (gameState == 6) { // Lose state.
// The player has lost the game. Let's tell them.
lcd.setCursor(9,1); // move cursor to second line "1" and 9 spaces over
lcd.print(millis()/1000); // display seconds elapsed since power-up
lcd.setCursor(0,1); // move to the begining of the second line
lcd.setCursor(0,0); // set the LCD cursor position
lcd.print("Asteroids Game! ");
lcd.setCursor(0,1); // move to the begining of the second line
lcd.print(" YOU LOSE ");
if (gameLineNum == 2) {
lcd.setCursor(0,0); // set the LCD cursor position
lcd.print(" YOU LOSE ");
lcd.setCursor(0,1); // move to the begining of the second line
lcd.print("Asteroids Game! ");
gameLineNum = 0;
} else if (gameLineNum == 1) {
lcd.setCursor(0,0); // set the LCD cursor position
lcd.print(" YOU LOSE ");
lcd.setCursor(0,1); // move to the begining of the second line
lcd.print(" Select for Menu");
gameLineNum = 2;
} else if (gameLineNum == 0){
lcd.setCursor(0,0); // set the LCD cursor position
lcd.print("Asteroids Game! ");
lcd.setCursor(0,1); // move to the begining of the second line
lcd.print(" YOU LOSE ");
gameLineNum = 1;
}
gameDelay = 0;
while (gameDelay < 2000){
// Add a delay in the loop.
delay(1);
gameDelay++;
lcd_key = read_LCD_buttons(); // read the buttons
switch (lcd_key){ // depending on which button was pushed, we perform an action
case btnRIGHT:{ // push button "RIGHT" and show the word on the screen
lcd.print("RIGHT ");
break;
}
case btnLEFT:{
lcd.print("LEFT "); // push button "LEFT" and show the word on the screen
break;
}
case btnUP:{
lcd.print("UP "); // push button "UP" and show the word on the screen
break;
}
case btnDOWN:{
lcd.print("DOWN "); // push button "DOWN" and show the word on the screen
break;
}
case btnSELECT:{
lcd.print("SELECT"); // push button "SELECT" and show the word on the screen
break;
}
case btnNONE:{
lcd.print("NONE "); // No action will show "None" on the screen
break;
}
}
switch (lcd_key){ // depending on which button was pushed, we perform an action
case btnSELECT:{
gameState = 0;
gameLineNum = 0;
break;
}
}
}
} // End gameState 6, Lose state.
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment