multiplayer pong game for LPC 1768

Dependencies:   mbed MbedJSONValue mbed-rtos Adafruit_ST7735 Adafruit_GFX EthernetInterface DebouncedInterrupt

Files at this revision

API Documentation at this revision

Comitter:
vsoltan
Date:
Sun Nov 15 23:45:34 2020 +0000
Parent:
19:58cc5465f647
Child:
21:992294ffabf4
Commit message:
still need to change update gamestate to check for nested structure in JSON

Changed in this revision

gamestate.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/gamestate.cpp	Sun Nov 15 22:45:48 2020 +0000
+++ b/gamestate.cpp	Sun Nov 15 23:45:34 2020 +0000
@@ -31,15 +31,17 @@
     if (typeResponse == "connected") {
         gfx->renderWaitingRoom(); 
     } else if (typeResponse == "gameState") {
-        this->p1_loc.y = (*serverResponse)["playerOnePos"].get<int>(); 
+        this->p1_loc.y = (*serverResponse)["gameState"]["playerOnePos"].get<int>(); 
+        printf("new player1 location: %i\n\r", this->p1_loc.y); 
         this->p2_loc.y = (*serverResponse)["playerTwoPos"].get<int>(); 
         int updated_ball_x = (*serverResponse)["ballPos"][0].get<int>(); 
         int updated_ball_y = (*serverResponse)["ballPos"][1].get<int>(); 
         this->ball_loc.x = updated_ball_x; 
         this->ball_loc.y = updated_ball_y;
         this->is_done = (char)(*serverResponse)["isOver"].get<int>();
-        this->localPlayerNum = (char)(*serverResponse)["player"].get<int>(); 
+        this->localPlayerNum = (char)(*serverResponse)["player"].get<int>();  
         this->lobbyHash = (*serverResponse)["hash"].get<std::string>(); 
+        gfx->renderGameState(this); 
     }
 }