Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: 4DGL-uLCD-SE EthernetInterface Game_Synchronizer MMA8452 SDFileSystem mbed-rtos mbed wave_player
Fork of 2035_Tanks_Shell by
Diff: two_player.h
- Revision:
- 2:c358ad9aedc4
- Parent:
- 1:0589ea36661b
- Child:
- 3:3ddefff03cb2
--- 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;
