46 Commits (master)

Author SHA1 Message Date
Aadhavan Srinivasan 6e0b7f8394 Updated include path, and set the type if the game mode is M_SINGLE 6 months ago
Aadhavan Srinivasan 6331d81ba3 Updated serialization include 6 months ago
Aadhavan Srinivasan b6439bf7d5 Free memory allocated with malloc() 7 months ago
Aadhavan Srinivasan f3dcbc3b3e Removed check_server_client() function.
It has been replaced by check_server() and check_client().
7 months ago
Aadhavan Srinivasan 8805402241 Return after catching exception 7 months ago
Aadhavan Srinivasan 0e7ebb4d78 Finished integrating check_server() and check_client(), check_server_client() has been commented out. 7 months ago
Aadhavan Srinivasan c2bedb0601 Wrote the check_num_args() function; still need to integrate it into the program. Also wrote a help text that is printed with -h flag. 7 months ago
Aadhavan Srinivasan 26999a1145 Started working on function to check the number of command-line arguments 7 months ago
Aadhavan Srinivasan 0dbf8936fd Added a #define for math constants on MinGW 7 months ago
Aadhavan Srinivasan 94e08f3863 Used blocking recv here, to ensure that we wait for the server to respond 7 months ago
Aadhavan Srinivasan ef869710e5 Replaced recvAll call with recvAllNB 7 months ago
Aadhavan Srinivasan 06f44d385d Allow user to quit in menu screen; better error handling.
I set up a try-catch to catch the exception thrown by the Server/Client when
it can't create a socket. I also used display_and_exit() to
automatically close the window after the text has been displayed.
7 months ago
Aadhavan Srinivasan 66d7585297 Removed IP version checking code (since this is handled in the Sock constructor), and allowed server (but not client, yet) to quit game before round start 7 months ago
Aadhavan Srinivasan 986e386098 Updated Server and Client constructor calls, so that they don't pass in the IP version 7 months ago
Aadhavan Srinivasan 9a12edcdb1 Started working on better error handling, by throwing exceptions and displaying error messages in the GUI 7 months ago
Aadhavan Srinivasan 8848f0ff8c Removed debug print statements, cleared background before drawing to screen, and added client GUI implementation
I removed a print statement that printed out every position of the ball, because it was no longer necessary.
I also added code to clear the background before drawing to the screen at the start of the game, to remove
any lingering un-erased objects. Finally, and most substantially, I finished the initial implementation of
the client-side GUI. The client should now be able to specify a connect code through the GUI, and connect
to the appropriate server.
7 months ago
Aadhavan Srinivasan 352d3f26f1 Moved struct definition to separate file, and added check for displaying GUI
I moved the GameType struct (and the Mode enum) to a separate file, as I will need
to use it in the check_server and check_client functions as well. I also added the
signum function (which was previously in sign.hpp) to this file, since it was the only
function in sign.hpp. Finally, I added a check, that will only display the GUI, if the
user didn't provide any command-line arguments.
7 months ago
Aadhavan Srinivasan bc0d644399 Replaced compound literal initialization of 'Rectangle' and 'Vector2' types (which is only valid in C), with braced-initialization (valid in C++) 7 months ago
Aadhavan Srinivasan 0d1dc049b5 Worked on further implementation of game mode selection.
I added code to display a help text after the user selects a mode. Currently,
this text is only displayed in single player mode. Additionally, I added a rudimentary
'form' to input IP address and port, if the user selects server mode.
7 months ago
Aadhavan Srinivasan 0286878c70 Rudimentary support for inputting game mode through GUI instead of command-line
The only thing that 'works' right now is the skeleton GUI structure. The buttons don't
actually do anything.
7 months ago
Aadhavan Srinivasan 635d71f1c5 Slightly lowered speed, to make the game a little easier to play 7 months ago
Aadhavan Srinivasan bb4601c5bd Chenged FPS to 60 for release build 7 months ago
Aadhavan Srinivasan f961db5e58 Added code to send quit message only if game is not in single player mode 8 months ago
Aadhavan Srinivasan 91bf5e2ce1 Fixed some commenting issues; Added code to detect if game was quit by peer and, if so, quit the game locally 8 months ago
Aadhavan Srinivasan 4b3d5387a1 Changed code to support Windows libraries and functions as well 8 months ago
Aadhavan Srinivasan ba667d020d Game is mostly finished, added a ton of code for reading and applying peer position.
The most important addition is that the program now parses data in the
Serial_Data struct, and updates the positions accordingly. I also removed
the old implementation with strings, and fixed a bunch of bugs along the way.
8 months ago
Aadhavan Srinivasan 6eb02ab2ee Started working on implementing serialization code into the main game loop.
Currently, I'm trying to serialize data and send it to the peer socket, and deserialize it at the receiving end.
8 months ago
Aadhavan Srinivasan 6ad56fb9ef Started working on client-server communication; so far, I can send the position of client to server, and vice-versa 8 months ago
Aadhavan Srinivasan 89e1e8d45e Worked on further implementation of the network side of things.
Specifically, I added code to send a message from the client, after the client is launched. This message is used to try to connect to the server. Once the server receives this message, it responds back. After the client receives this response, the connection has been established, and the game can begin.

I also added code to wait (on the client side) for the server to press the spacebar.
8 months ago
Aadhavan Srinivasan acf8271126 Renamed 'math-helpers.hpp' to 'sign.hpp' and updated main.cpp to reflect the change 8 months ago
Aadhavan Srinivasan 1b1dc4a3a2 Changed include paths to relative paths, and added an agnostic struct.
The agnostic struct consists of a 'Mode' enum, and a 'Sock' type. The
'Sock' can be either a Server or Client, depending on the type of game.
This allows polymorphism, as I don't have to worry about whether the game
is being run in Server or Client mode, and I can call the same methods regardless.
8 months ago
Aadhavan Srinivasan fc041539c5 Changed Sock to Sock* in GameType struct to allow it to be set to null 8 months ago
Aadhavan Srinivasan cb0fe1af6b Defined a 'GameType' struct that can hold both the mode, and the relevant socket, to enable polymorphism when calling socket methods 8 months ago
Aadhavan Srinivasan 4c256d8800 Added call to SockQuit at the end 8 months ago
Aadhavan Srinivasan 912435bfa3 Added new exception for invalid IP, used it if IP address is neither v4 nor v6 8 months ago
Aadhavan Srinivasan 48739f6026 Created enum to denote if game is in client or server mode, and added error checking, to check if IP address is valid 8 months ago
Aadhavan Srinivasan 05cc70412c Added comments to better explain the code, and added code to catch more exceptions 8 months ago
Aadhavan Srinivasan 2ca17a6225 Moved server / client checking above window initialization 8 months ago
Aadhavan Srinivasan cb958d2749 Added code to parse command-line flags, to determine whether the game was started in client or server mode, and call relevant functions to encode or decode address / key 8 months ago
Aadhavan Srinivasan c83b347620 Changed include paths, added a cmdline argument ('server') to indicate if the game is networkded or not 9 months ago
Aadhavan Srinivasan 7557ce7cf5 Updated header file includes; Changed base speed; Started working on networking code, to send a character when the paddle is moved or stopped 9 months ago
Aadhavan Srinivasan b5a8fd599d Added a randomly generated multiplier to the offset, when the ball collides with a paddle 9 months ago
Aadhavan Srinivasan 2940c61314 Added code to wait until user presses SPACE, before starting the game. Also added code to show points 9 months ago
Aadhavan Srinivasan 6e78329eb5 Updated code to use variable paddle speed and keep a constant speed (magnitude of velocity); added function to determine the x and y components of ball velocity after collision with paddle 9 months ago
Aadhavan Srinivasan 6ddf6936bf Added more comments, and fixed bug where ball would sometimes get 'stuck' inside paddle 9 months ago
Aadhavan Srinivasan 9180e55c88 First commit 9 months ago