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
Revision 2:c358ad9aedc4, committed 2015-10-12
- Comitter:
- jford38
- Date:
- Mon Oct 12 04:23:24 2015 +0000
- Parent:
- 1:0589ea36661b
- Child:
- 3:3ddefff03cb2
- Commit message:
- Last commit with UDP. Switching to TCP.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
two_player.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Oct 07 00:43:25 2015 +0000 +++ b/main.cpp Mon Oct 12 04:23:24 2015 +0000 @@ -23,7 +23,7 @@ pc.printf("Updated. \n"); buttons = uLCD.get_button_state(); pc.printf("Button State: %x %x %x %x %x\n", buttons[0], buttons[1], buttons[2], buttons[3], buttons[4]); - wait(3); + wait(0.5); //pc.printf("\033[2J\033[0;0H"); } //
--- a/two_player.h Wed Oct 07 00:43:25 2015 +0000 +++ b/two_player.h Mon Oct 12 04:23:24 2015 +0000 @@ -28,6 +28,8 @@ BG_COLOR_CMD, CIRCLE_CMD, CLS_CMD, + I_AM_P1, + I_AM_P2 }; @@ -96,18 +98,32 @@ void update() { sock->set_blocking(true, 100); if(p1_p2 == PLAYER1) { + pc.printf("Sending draw data...\n"); sock->sendTo(*endpoint, (char*)buffer, (buffer_idx+1)*sizeof(buffer[0])); buffer_idx = 0; - int n = sock->receiveFrom(*endpoint, (char*)buttons, sizeof(buttons)); + pc.printf("Receiving button data...\n"); + int n = sock->receiveFrom(*endpoint, (char*)buttons, sizeof(buttons)); + if(n < 0) {pc.printf("RECEIVE ERROR.\n");} + pc.printf("Received button data...\n"); + }else if(p1_p2 == PLAYER2) { - - int n = sock->receiveFrom(*endpoint, (char*)buffer, sizeof(buffer)); + pc.printf("Receiving draw buffer...\n"); + int n = sock->receiveFrom(*endpoint, (char*)buffer, sizeof(buffer)); + if(n < 0) {pc.printf("RECEIVE ERROR.\n");} buffer[n] = '\0'; - + pc.printf("Received draw data...\n"); + pc.printf("Sending button data...\n"); sock->sendTo(*endpoint, (char*)buttons, sizeof(buttons)); } + int i = 0; + while(buffer[i] != '\0') { + pc.printf("%d ", buffer[i]); + i++; + } + pc.printf("\n"); + int idx = 0; while(buffer[idx] != '\0') { char cmd = buffer[idx]; @@ -126,6 +142,9 @@ pc.printf("Clear the screen!\n"); idx += 0; break; + case I_AM_P1: + case I_AM_P2: + break; default: pc.printf("UNKNOWN CMD %d: This could get ugly!\n", cmd); idx += 0;