Commit Graph

46 Commits

Author SHA1 Message Date
6e0b7f8394 Updated include path, and set the type if the game mode is M_SINGLE 2024-04-11 13:26:18 -04:00
6331d81ba3 Updated serialization include 2024-04-11 13:10:08 -04:00
b6439bf7d5 Free memory allocated with malloc() 2024-03-20 00:07:23 -04:00
f3dcbc3b3e Removed check_server_client() function.
It has been replaced by check_server() and check_client().
2024-03-18 13:25:51 -04:00
8805402241 Return after catching exception 2024-03-18 13:22:01 -04:00
0e7ebb4d78 Finished integrating check_server() and check_client(), check_server_client() has been commented out. 2024-03-17 23:34:24 -04:00
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. 2024-03-17 00:30:25 -04:00
26999a1145 Started working on function to check the number of command-line arguments 2024-03-16 10:49:21 -05:00
0dbf8936fd Added a #define for math constants on MinGW 2024-03-13 14:36:10 -05:00
94e08f3863 Used blocking recv here, to ensure that we wait for the server to respond 2024-03-12 10:02:53 -05:00
ef869710e5 Replaced recvAll call with recvAllNB 2024-03-12 09:44:15 -05:00
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.
2024-03-11 13:45:05 -05:00
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 2024-03-11 01:29:56 -05:00
986e386098 Updated Server and Client constructor calls, so that they don't pass in the IP version 2024-03-10 21:56:03 -05:00
9a12edcdb1 Started working on better error handling, by throwing exceptions and displaying error messages in the GUI 2024-03-09 11:05:04 -05:00
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.
2024-03-08 23:35:18 -05:00
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.
2024-03-08 14:46:30 -05:00
bc0d644399 Replaced compound literal initialization of 'Rectangle' and 'Vector2' types (which is only valid in C), with braced-initialization (valid in C++) 2024-03-08 08:20:52 -05:00
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.
2024-03-07 23:19:03 -05:00
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.
2024-03-07 18:10:14 -05:00
635d71f1c5 Slightly lowered speed, to make the game a little easier to play 2024-03-07 07:46:38 -05:00
bb4601c5bd Chenged FPS to 60 for release build 2024-03-06 15:59:12 -06:00
f961db5e58 Added code to send quit message only if game is not in single player mode 2024-03-05 07:57:20 -05:00
91bf5e2ce1 Fixed some commenting issues; Added code to detect if game was quit by peer and, if so, quit the game locally 2024-03-01 22:35:31 -05:00
4b3d5387a1 Changed code to support Windows libraries and functions as well 2024-02-29 16:38:36 -05:00
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.
2024-02-28 00:00:53 -05:00
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.
2024-02-26 21:39:23 -05:00
6ad56fb9ef Started working on client-server communication; so far, I can send the position of client to server, and vice-versa 2024-02-23 11:16:21 -05:00
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.
2024-02-21 22:29:03 -05:00
acf8271126 Renamed 'math-helpers.hpp' to 'sign.hpp' and updated main.cpp to reflect the change 2024-02-15 09:46:53 -05:00
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.
2024-02-14 18:32:40 -05:00
fc041539c5 Changed Sock to Sock* in GameType struct to allow it to be set to null 2024-02-14 08:22:25 -05:00
cb0fe1af6b Defined a 'GameType' struct that can hold both the mode, and the relevant socket, to enable polymorphism when calling socket methods 2024-02-14 08:09:34 -05:00
4c256d8800 Added call to SockQuit at the end 2024-02-11 23:22:19 -05:00
912435bfa3 Added new exception for invalid IP, used it if IP address is neither v4 nor v6 2024-02-07 21:55:05 -05:00
48739f6026 Created enum to denote if game is in client or server mode, and added error checking, to check if IP address is valid 2024-02-07 21:48:43 -05:00
05cc70412c Added comments to better explain the code, and added code to catch more exceptions 2024-02-06 09:44:54 -05:00
2ca17a6225 Moved server / client checking above window initialization 2024-02-06 07:26:16 -05:00
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 2024-02-04 20:33:45 -05:00
c83b347620 Changed include paths, added a cmdline argument ('server') to indicate if the game is networkded or not 2024-01-31 21:01:11 -05:00
7557ce7cf5 Updated header file includes; Changed base speed; Started working on networking code, to send a character when the paddle is moved or stopped 2024-01-29 22:48:58 -05:00
b5a8fd599d Added a randomly generated multiplier to the offset, when the ball collides with a paddle 2024-01-24 12:19:57 -05:00
2940c61314 Added code to wait until user presses SPACE, before starting the game. Also added code to show points 2024-01-24 12:02:45 -05:00
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 2024-01-18 19:30:11 -05:00
6ddf6936bf Added more comments, and fixed bug where ball would sometimes get 'stuck' inside paddle 2024-01-17 23:40:14 -05:00
9180e55c88 First commit 2024-01-17 23:25:43 -05:00