multiplayer pong game for LPC 1768
Dependencies: mbed MbedJSONValue mbed-rtos Adafruit_ST7735 Adafruit_GFX EthernetInterface DebouncedInterrupt
Revision 34:b19f39ad74ac, committed 2020-11-28
- Comitter:
- vsoltan
- Date:
- Sat Nov 28 03:52:32 2020 +0000
- Parent:
- 33:98ba7b0b8c2b
- Child:
- 35:2c5e582a6ee2
- Commit message:
- issues with reconnecting...
Changed in this revision
gamestate.cpp | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/gamestate.cpp Sat Nov 28 03:30:09 2020 +0000 +++ b/gamestate.cpp Sat Nov 28 03:52:32 2020 +0000 @@ -31,6 +31,7 @@ void GameState::updateAndRender(MbedJSONValue *serverResponse, Graphics *gfx) { string typeResponse = (*serverResponse)["type"].get<std::string>(); if (typeResponse == "connected") { + printf("connected!!!!!\n\r"); if (serverResponse->hasMember("player")) { this->localPlayerNum = (char)(*serverResponse)["player"].get<int>(); }
--- a/main.cpp Sat Nov 28 03:30:09 2020 +0000 +++ b/main.cpp Sat Nov 28 03:52:32 2020 +0000 @@ -63,14 +63,15 @@ GameState *gs = new GameState(); numGamesPlayed++; - // request an open lobby from the server - sock.sendTo(nist, connectionRequest, strlen(connectionRequest)); - // change ISRs to game controls leftButton.attach(&pressLeftGame, IRQ_RISE, DEBOUNCE); middleButton.reset(); rightButton.attach(&pressRightGame, IRQ_RISE, DEBOUNCE); + // request an open lobby from the server + sock.sendTo(nist, connectionRequest, strlen(connectionRequest)); + + printf("hello\n\r"); while (!gs->done()) { if (sendFlag != 0) { serverRequest["type"] = "move"; @@ -108,7 +109,10 @@ // cleanup the socket from the previous game int flushBytes = 0; - while ((flushBytes = sock.receiveFrom(nist, tmp_buffer, sizeof(tmp_buffer))) != 0) {} + while ((flushBytes = sock.receiveFrom(nist, tmp_buffer, sizeof(tmp_buffer))) != 0) { + printf("reading bytes: %i\n\r", flushBytes); + printf("tmp_buffer", tmp_buffer); + } gfx->renderGameOver(gs);