Commit e44c2662 authored by alaskalinuxuser's avatar alaskalinuxuser

Game state 1, information.

parent 8990b817
......@@ -107,6 +107,8 @@ void loop(){
if (gameState == 0) { // start screen state.
// The initial start screen. Let's set all game variables for a new game.
// Game variables:
lcd.setCursor(0,0); // set the LCD cursor position
lcd.print("Asteroids Game!"); // print a simple message on the LCD
gameState = 0; // The state of game play.
gameBullets = 9; // Number of bullets remaining.
gameSpeed = 1; // The speed of the game.
......@@ -117,7 +119,7 @@ void loop(){
gameAsteroidThree = 17; // Third asteroid starting space.
gameAsteroidFour = 23; // Fourth Asteroid starting space.
lcd.setCursor(0,1); // move to the begining of the second line
lcd.setCursor(0,1); // move to the begining of the second line
if (gameLineNum != 0){
lcd.print(" Right = Info ");
gameLineNum = 0;
......@@ -125,59 +127,88 @@ void loop(){
lcd.print(" Select = Start ");
gameLineNum = 1;
}
lcd_key = read_LCD_buttons(); // read the buttons
switch (lcd_key){// depending on which button was pushed, we perform an action
int gameDelay = 0;
while (gameDelay < 8000){
gameDelay++;
lcd_key = read_LCD_buttons(); // read the buttons
case btnRIGHT:{
gameState = 1;
break;
}
case btnSELECT:{
gameState = 3;
break;
}
}
// Add a delay in the loop.
delay(1000);
switch (lcd_key){ // depending on which button was pushed, we perform an action
case btnRIGHT:{
gameState = 1;
gameLineNum = 0;
break;
}
case btnSELECT:{
gameState = 3;
gameLineNum = 0;
break;
}
}
}
// Add a delay in the loop.
delay(100);
} // End gameState 0, asteroids start screen.
if (gameState == 1) { // Credits state.
// The player wants to know who made this silly 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(" Created By the ");
lcd.setCursor(0,1); // move to the begining of the second line
lcd.print("AlaskaLinuxUser!");
if (gameLineNum > 2) {
lcd.setCursor(0,0); // set the LCD cursor position
lcd.print("Right = How to ");
lcd.setCursor(0,1); // move to the begining of the second line
lcd.print("Left = Main Menu");
gameLineNum = 0;
} else if (gameLineNum == 2) {
lcd.setCursor(0,0); // set the LCD cursor position
lcd.print("ress.com ");
lcd.setCursor(0,1); // move to the begining of the second line
lcd.print(" Select = Start ");
gameLineNum = 3;
} else if (gameLineNum == 1) {
lcd.setCursor(0,0); // set the LCD cursor position
lcd.print("https://thealask");
lcd.setCursor(0,1); // move to the begining of the second line
lcd.print("alinuxuser.wordp");
gameLineNum = 2;
} else if (gameLineNum == 0){
lcd.setCursor(0,0); // set the LCD cursor position
lcd.print(" Created By the ");
lcd.setCursor(0,1); // move to the begining of the second line
lcd.print("AlaskaLinuxUser!");
gameLineNum = 1;
}
int gameDelay = 0;
while (gameDelay < 10000){
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 btnRIGHT:{
gameState = 2;
gameLineNum = 0;
break;
}
case btnLEFT:{
gameState = 0;
gameLineNum = 0;
break;
}
case btnSELECT:{
gameState = 3;
gameLineNum = 0;
break;
}
}
}
// Add a delay in the loop.
delay(100);
} // End gameState 1, credits.
if (gameState == 2) { // How to info 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