Commit 8990b817 authored by AlaskaLinuxUser's avatar AlaskaLinuxUser

Game State 0, start sceen

parent 566ef884
......@@ -26,7 +26,18 @@ LiquidCrystal lcd(8, 9, 4, 5, 6, 7); // select the pins used on the LC
// define some values used by the panel and buttons
int lcd_key = 0;
int adc_key_in = 0;
int gameState = 0;
// Game variables:
int gameLineNum = 0; // A way to switch between display lines.
int gameState = 0; // The state of game play.
int gameBullets = 9; // Number of bullets remaining.
int gameSpeed = 1; // The speed of the game.
int gameScore = 0; // Number of asteroids destroyed or past.
int gamePosition = 0; // Your space ships location, 0 for up, 1 for down.
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.
/*
* Game states:
......@@ -37,6 +48,17 @@ int gameState = 0;
* 4 = Pause mode
* 5 = win screen
* 6 = lose screen
*
* Game display: 16 x 2.
*
* B B B W S A A A A A A A A A A A
* P P P W S A A A A A A A A A A A
*
* B = Bullets left
* P = Past Asteroids
* W = Wall of Game
* S = Space Ship
* A = Asteroid Field
*/
#define btnRIGHT 0
......@@ -84,39 +106,41 @@ void loop(){
if (gameState == 0) { // start screen state.
// The initial start screen. Let's set all game variables for a new game.
lcd.setCursor(9,1); // move cursor to second line "1" and 9 spaces over
lcd.print(millis()/1000); // display seconds elapsed since power-up
// Game variables:
gameState = 0; // The state of game play.
gameBullets = 9; // Number of bullets remaining.
gameSpeed = 1; // The speed of the game.
gameScore = 0; // Number of asteroids destroyed or past.
gamePosition = 0; // Your space ships location, 0 for up, 1 for down.
gameAsteroidOne = 14; // First asteroid starting space.
gameAsteroidTwo = 25; // Second asteroid starting space.
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_key = read_LCD_buttons(); // read the buttons
if (gameLineNum != 0){
lcd.print(" Right = Info ");
gameLineNum = 0;
} else {
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
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 ");
case btnRIGHT:{
gameState = 1;
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
gameState = 3;
break;
}
}
// Add a delay in the loop.
delay(1000);
} // End gameState 0, asteroids start screen.
if (gameState == 1) { // Credits state.
......@@ -340,4 +364,5 @@ void loop(){
}
}
} // 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