game controller & clean up
This commit is contained in:
parent
78f1e0e143
commit
18f5aa3165
|
@ -174,6 +174,10 @@ namespace RPI_Matrix {
|
|||
if (!isInGame)
|
||||
hasSelected = true;
|
||||
// Select given option in Tetris' 'GameOver' Screen
|
||||
else if (isSnake && SnakeGame.SnakeGame.selection)
|
||||
SnakeGame.SnakeGame.enterSelection();
|
||||
else if (isFlappy && FlappyBird.FlappyBird.selection)
|
||||
FlappyBird.FlappyBird.enterSelection();
|
||||
else if (isTetris && Tetris.Tetris.selection)
|
||||
Tetris.Tetris.enterSelection();
|
||||
break;
|
||||
|
@ -218,9 +222,11 @@ namespace RPI_Matrix {
|
|||
if (!FlappyBird.FlappyBird.isReady)
|
||||
FlappyBird.FlappyBird.stopPlaying = true;
|
||||
// Otherwise go back to 'ready' Screen by ending the Game
|
||||
else
|
||||
else {
|
||||
FlappyBird.FlappyBird.EndGame();
|
||||
// If in Tetris, end the Game and return to menu
|
||||
FlappyBird.FlappyBird.selection = false;
|
||||
}
|
||||
// If in Tetris, end the Game and return to menu
|
||||
} else if (isTetris)
|
||||
Tetris.Tetris.EndGame();
|
||||
break;
|
||||
|
@ -229,12 +235,18 @@ namespace RPI_Matrix {
|
|||
// If in the selection screen, decrement index
|
||||
if (!isInGame && selectionIndex > 0)
|
||||
selectionIndex--;
|
||||
// If in SnakeGame, Steer the Snake upwards
|
||||
else if (isSnake)
|
||||
SnakeGame.SnakeGame.SteerUp(SnakeGame.SnakeGame.self);
|
||||
else if (isSnake) {
|
||||
// Handle index in 'GameOver' Screen
|
||||
if (SnakeGame.SnakeGame.selection && SnakeGame.SnakeGame.selectionIndex > 0)
|
||||
SnakeGame.SnakeGame.selectionIndex--;
|
||||
// If in SnakeGame, Steer the Snake upwards
|
||||
else
|
||||
SnakeGame.SnakeGame.SteerUp(SnakeGame.SnakeGame.self);
|
||||
// If in Tetris and in Tetris' 'GameOver' Screen, decrement its index.
|
||||
else if (isTetris && Tetris.Tetris.selection && Tetris.Tetris.selectionIndex > 0)
|
||||
Tetris.Tetris.selectionIndex--;
|
||||
} else if (isTetris && Tetris.Tetris.selection && Tetris.Tetris.selectionIndex > 0)
|
||||
Tetris.Tetris.selectionIndex--;
|
||||
else if (isFlappy && FlappyBird.FlappyBird.selection && FlappyBird.FlappyBird.selectionIndex > 0)
|
||||
FlappyBird.FlappyBird.selectionIndex--;
|
||||
break;
|
||||
case "FF-7F-02-01":
|
||||
// Code for Arrow-Down Press
|
||||
|
@ -242,15 +254,23 @@ namespace RPI_Matrix {
|
|||
if (!isInGame && selectionIndex < 3)
|
||||
selectionIndex++;
|
||||
// If in SnakeGame, Steer the Snake downwards
|
||||
else if (isSnake)
|
||||
SnakeGame.SnakeGame.SteerDown(SnakeGame.SnakeGame.self);
|
||||
else if (isTetris)
|
||||
else if (isSnake) {
|
||||
// Handle index in 'GameOver' Screen
|
||||
if (SnakeGame.SnakeGame.selection && SnakeGame.SnakeGame.selectionIndex < 1)
|
||||
SnakeGame.SnakeGame.selectionIndex++;
|
||||
// If in SnakeGame, Steer the Snake downwards
|
||||
else
|
||||
SnakeGame.SnakeGame.SteerDown(SnakeGame.SnakeGame.self);
|
||||
// If in Tetris and in Tetris' 'GameOver' Screen, decrement its index.
|
||||
} else if (isTetris)
|
||||
// If in Tetris and in Tetris' 'GameOver' Screen, increment its index.
|
||||
if (Tetris.Tetris.selection && Tetris.Tetris.selectionIndex < 1)
|
||||
Tetris.Tetris.selectionIndex++;
|
||||
// Otherwise, move Tetris piece down
|
||||
else
|
||||
Tetris.Tetris.moveDownOnce();
|
||||
Tetris.Tetris.moveDownOnce();
|
||||
else if (isFlappy && FlappyBird.FlappyBird.selection && FlappyBird.FlappyBird.selectionIndex < 1)
|
||||
FlappyBird.FlappyBird.selectionIndex++;
|
||||
break;
|
||||
case "01-80-02-00":
|
||||
// Code for Arrow-Left Press
|
||||
|
|
Loading…
Reference in New Issue
Block a user