The classic dueling tanks game for mbed.
Dependencies: 4DGL-uLCD-SE DRV2605 EthernetInterface Game_Synchronizer MMA8452 SDFileSystem SparkfunAnalogJoystick mbed-rtos mbed wave_player
Fork of 2035_Tanks_Shell by
Diff: main.cpp
- Revision:
- 7:9506f2d84162
- Parent:
- 6:3be57cf4bd33
- Child:
- 8:e6dd05393290
--- 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];