![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Revenge of the Mouse
Dependencies: 4DGL-uLCD-SE EthernetInterface Game_Synchronizer LCD_fonts MMA8452 SDFileSystem mbed-rtos mbed wave_player
Fork of 2035_Tanks_Shell by
Diff: main.cpp
- Revision:
- 7:9506f2d84162
- Parent:
- 6:3be57cf4bd33
- Child:
- 8:e6dd05393290
diff -r 3be57cf4bd33 -r 9506f2d84162 main.cpp --- a/main.cpp Thu Oct 22 08:02:28 2015 +0000 +++ b/main.cpp Thu Oct 22 09:14:47 2015 +0000 @@ -18,6 +18,18 @@ // For debug only. Don't use in production code. It will slow your game down a lot. Serial pc(USBTX, USBRX); + +int game_menu(void) { + + // Figure out what mode the game will be run in. + // Right button -> Multiplayer + // Left button -> Single player + while(1) { + if(!pb_r) { wait(1); return MULTI_PLAYER; } // Delay to allow user time to stop pushing the button before the game starts! + if(!pb_l) { wait(1); return SINGLE_PLAYER; } // return whichever game mode the user selected. + } +} + void game_init(void) { led1 = 0; led2 = 0; led3 = 0; led4 = 0; @@ -29,7 +41,8 @@ pc.printf("\033[2J\033[0;0H"); // Clear the terminal screen. pc.printf("I'm alive! Player 1\n"); // Let us know you made it this far. - sync.init(); // Connect to the other player. + int mode = game_menu(); + sync.init(mode); // Connect to the other player. pc.printf("Initialized...\n"); // Let us know you finished initializing. } @@ -53,6 +66,7 @@ sync.update(); buttons = sync.get_button_state(); + led1 = buttons[0]; led2 = buttons[1]; led3 = buttons[2];