multiplayer pong game for LPC 1768

Dependencies:   mbed MbedJSONValue mbed-rtos Adafruit_ST7735 Adafruit_GFX EthernetInterface DebouncedInterrupt

Committer:
vsoltan
Date:
Mon Nov 23 01:19:17 2020 +0000
Revision:
27:fcc5fee18a24
Parent:
23:c38680c32552
Child:
29:4708bfb863cb
fixed game over logic

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