multiplayer pong game for LPC 1768

Dependencies:   mbed MbedJSONValue mbed-rtos Adafruit_ST7735 Adafruit_GFX EthernetInterface DebouncedInterrupt

Committer:
vsoltan
Date:
Sat Nov 28 01:05:42 2020 +0000
Revision:
29:4708bfb863cb
Parent:
27:fcc5fee18a24
Child:
30:59e9a5409e65
polishing code and added functionality for game countdown

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 29:4708bfb863cb 26 char 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 29:4708bfb863cb 38 char getCountdown();
vsoltan 29:4708bfb863cb 39 void setCountdown(int val);
vsoltan 27:fcc5fee18a24 40 int getPlayerOneScore();
vsoltan 27:fcc5fee18a24 41 int getPlayerTwoScore();
vsoltan 27:fcc5fee18a24 42 void updateAndRender(MbedJSONValue *serverResponse, Graphics *gfx);
vsoltan 27:fcc5fee18a24 43 char done();
vsoltan 15:9d90f68e53da 44 };
vsoltan 15:9d90f68e53da 45
vsoltan 15:9d90f68e53da 46 #endif // GAME_STATE_H