multiplayer pong game for LPC 1768

Dependencies:   mbed MbedJSONValue mbed-rtos Adafruit_ST7735 Adafruit_GFX EthernetInterface DebouncedInterrupt

Committer:
vsoltan
Date:
Sat Nov 28 02:48:31 2020 +0000
Revision:
30:59e9a5409e65
Parent:
29:4708bfb863cb
Child:
32:7cbf4d9a82af
potential fix to replay-ability issue

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vsoltan 15:9d90f68e53da 1
vsoltan 15:9d90f68e53da 2 #ifndef GAME_STATE_H
vsoltan 15:9d90f68e53da 3 #define GAME_STATE_H
vsoltan 15:9d90f68e53da 4
vsoltan 15:9d90f68e53da 5 #include "mbed.h"
vsoltan 15:9d90f68e53da 6 #include "stdint.h"
vsoltan 17:32ae1f106002 7 #include "MbedJSONValue.h"
vsoltan 18:32fce82690a1 8 #include "graphics.h"
vsoltan 18:32fce82690a1 9 #include <string>
vsoltan 15:9d90f68e53da 10
vsoltan 15:9d90f68e53da 11 struct Coord {
vsoltan 15:9d90f68e53da 12 int8_t x;
vsoltan 15:9d90f68e53da 13 int8_t y;
vsoltan 15:9d90f68e53da 14 };
vsoltan 15:9d90f68e53da 15
vsoltan 18:32fce82690a1 16 class Graphics;
vsoltan 18:32fce82690a1 17
vsoltan 15:9d90f68e53da 18 class GameState {
vsoltan 23:c38680c32552 19 // TODO: make the syntax consistent please
vsoltan 15:9d90f68e53da 20 private:
vsoltan 15:9d90f68e53da 21 Coord p1_loc;
vsoltan 15:9d90f68e53da 22 Coord p2_loc;
vsoltan 15:9d90f68e53da 23 Coord ball_loc;
vsoltan 18:32fce82690a1 24 char is_done;
vsoltan 23:c38680c32552 25 char has_started;
vsoltan 30:59e9a5409e65 26 char connected;
vsoltan 30:59e9a5409e65 27 int countdown;
vsoltan 18:32fce82690a1 28 char localPlayerNum;
vsoltan 23:c38680c32552 29 char lobbyHash[21];
vsoltan 27:fcc5fee18a24 30 int score[2];
vsoltan 15:9d90f68e53da 31 public:
vsoltan 19:58cc5465f647 32 GameState();
vsoltan 19:58cc5465f647 33 Coord getPlayerLocation(char player);
vsoltan 15:9d90f68e53da 34 Coord getPlayerOneLocation();
vsoltan 15:9d90f68e53da 35 Coord getPlayerTwoLocation();
vsoltan 15:9d90f68e53da 36 Coord getBallLocation();
vsoltan 23:c38680c32552 37 char *getLobbyHash();
vsoltan 19:58cc5465f647 38 char getLocalPlayerNum();
vsoltan 30:59e9a5409e65 39 int getCountdown();
vsoltan 30:59e9a5409e65 40 char hasStarted();
vsoltan 30:59e9a5409e65 41 char isConnected();
vsoltan 29:4708bfb863cb 42 void setCountdown(int val);
vsoltan 27:fcc5fee18a24 43 int getPlayerOneScore();
vsoltan 27:fcc5fee18a24 44 int getPlayerTwoScore();
vsoltan 27:fcc5fee18a24 45 void updateAndRender(MbedJSONValue *serverResponse, Graphics *gfx);
vsoltan 27:fcc5fee18a24 46 char done();
vsoltan 15:9d90f68e53da 47 };
vsoltan 15:9d90f68e53da 48
vsoltan 15:9d90f68e53da 49 #endif // GAME_STATE_H