Hardware Reference
In-Depth Information
Adding a Bit of Splash
After the sound is added to the game a bit of more ambience can be achieved by creating a splash screen so the game
can advertise itself when it is turned on and is not being played. Stack it will display anything placed in the
cubeMove
array when
displaySprites()
is called. Adding a pattern to the screen is the same as Stop It's method of showing
status to the player. The two-dimensional nature of the Gameduino allows for the creation of text using the placement
of sprites with a binary pattern loaded into the
cubeMove
array.
The
stackIt()
function in Listing 11-5 loads a second array with a binary pattern that represents the words
STACK IT
. The pattern is backward in the
logo
array because of how the
displaySprites()
function steps though the
cubeMove
array. The function copies and displays one row of the
logo
array to the
cubeMove
array every 300 ms; then
the win tone is played before the game is prepared for play. The
StackIt()
function can be called in the
setup()
function, replacing the
resetPlay() function
call so that when the game starts, the logo will be displayed.
Listing 11-5.
A Splash Function for Stack It
void StackIt() {
GD.voice(0, 0, 0,0,0);
long logo[18];
logo[0] = 0x00000000; // hex is revese pattern 1 = # 0 = .
logo[1] = 0x00498df6; // .##.#####.##...##..#..#.
logo[2] = 0x002a5249; // #..#..#..#..#.#..#.#.#..
logo[3] = 0x00185241; // #.....#..#..#.#....##...
logo[4] = 0x00185e46; // .##…#..####.#....##...
logo[5] = 0x00285248; // ...#..#..#..#.#....#.#..
logo[6] = 0x004a5249; // #..#..#..#..#.#..#.#..#.
logo[7] = 0x00899246; // .##...#..#..#..##..#...#
logo[8] = 0x00000000;
logo[9] = 0x0003e7c0; // ......#####..#####......
logo[10] = 0x00008100; // ........#......#........
logo[11] = 0x00008100; // ........#......#........
logo[12] = 0x00008100; // ........#......#........
logo[13] = 0x00008100; // ........#......#........
logo[14] = 0x00008100; // ........#......#........
logo[15] = 0x000087c0; // ......#####....#........
logo[16] = 0x00000000;
logo[17] = 0x00ffffff; // ########################
for (int i = 17 ; i >= 0 ; i --) {
cubeMove[i] = logo[i];
displaySprites();
delay (300);
}
WinTone();
delay (500);
resetPlay();
} // end Stack it logo