multiplayer pong game for LPC 1768

Dependencies:   mbed MbedJSONValue mbed-rtos Adafruit_ST7735 Adafruit_GFX EthernetInterface DebouncedInterrupt

Committer:
vsoltan
Date:
Sat Nov 28 04:21:08 2020 +0000
Revision:
36:46bb54b669bc
Parent:
32:7cbf4d9a82af
Child:
37:8a0fc62a0512
starting to refactor

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 int countdown;
vsoltan 18:32fce82690a1 27 char localPlayerNum;
vsoltan 23:c38680c32552 28 char lobbyHash[21];
vsoltan 27:fcc5fee18a24 29 int score[2];
vsoltan 15:9d90f68e53da 30 public:
vsoltan 19:58cc5465f647 31 GameState();
vsoltan 19:58cc5465f647 32 Coord getPlayerLocation(char player);
vsoltan 15:9d90f68e53da 33 Coord getPlayerOneLocation();
vsoltan 15:9d90f68e53da 34 Coord getPlayerTwoLocation();
vsoltan 15:9d90f68e53da 35 Coord getBallLocation();
vsoltan 23:c38680c32552 36 char *getLobbyHash();
vsoltan 19:58cc5465f647 37 char getLocalPlayerNum();
vsoltan 30:59e9a5409e65 38 int getCountdown();
vsoltan 30:59e9a5409e65 39 char hasStarted();
vsoltan 29:4708bfb863cb 40 void setCountdown(int val);
vsoltan 27:fcc5fee18a24 41 int getPlayerOneScore();
vsoltan 27:fcc5fee18a24 42 int getPlayerTwoScore();
vsoltan 36:46bb54b669bc 43 int getPlayerScore(int player);
vsoltan 27:fcc5fee18a24 44 void updateAndRender(MbedJSONValue *serverResponse, Graphics *gfx);
vsoltan 27:fcc5fee18a24 45 char done();
vsoltan 15:9d90f68e53da 46 };
vsoltan 15:9d90f68e53da 47
vsoltan 15:9d90f68e53da 48 #endif // GAME_STATE_H