extern "C" { #include #include #include #include } #include "Drawing.h" #include "Simon.h" #define SIN45 0.707107 #define TIME_OUT 1000 #define WAIT_TIME 2000 #define DISPLAY_FLASH_TIME 300 void DrawBoard(ScreenBuffer screen); void DrawWedge(SimonColor eColor, ScreenBuffer buffer, bool bON = true); bool StartKeyPressed(); bool QuitKeyPressed(); bool SimonKeyPressed(SimonColor& eColor); bool DoSlightDelay(int nMS); void itoa(int n, char buffer[3]); int main() { bool play = true; ScreenBuffer screen = GetNewScreenBuffer(); while(play == true) { // Draw a wellcoming message clearScreen(BLACK, screen); drawStr(0, 0 * CHAR_HEIGHT, " +----------+\n" " | nSimon |\n" " +----------+\n" "\n" "---------------------------------------\n" "Controls:\n" " - Green : Up & 8\n" " - Blue : Down & 2\n" " - Red : Right & 6\n" " - Yellow : Left & 4\n\n\n" "Game play: Simply match the pattern!\n\n" "Ctrl/Enter to Start !\n" " Or Esc to quit...\n", 1, 1, CYAN, screen); display(screen); // Wait and init rand while (!StartKeyPressed() && !QuitKeyPressed()) rand(); Simon simon; simon.Initialize(); //Game loop while(play == true) { if( QuitKeyPressed() ) { play = false; break; } DrawBoard(screen); display(screen); //Watch carefully drawStr(SCREEN_WIDTH/2 - 115/*Just looked right*/, SCREEN_HEIGHT/2-CHAR_HEIGHT/2, "Watch carefully", 2, false, RED, screen); display(screen); if( !DoSlightDelay(WAIT_TIME) ) { play = false; break; } //Draw current sequence DrawBoard(screen); for(int i=0; i 0 ) { buffer[0] = '0' + nTens; buffer[1] = '0' + nRemainder; buffer[2] = '\0'; } else { buffer[0] = '0' + nRemainder; buffer[1] = '\0'; } }