0
\$\begingroup\$

I'm programming a game 100% in Java but I'm having some issues concerning the final games architecture.

I plan on having two separate projects: one that will hold the client side of communication and another, the server side. As for all the rest, the Player Class, the Main Game class, etc. I'm not sure whether they should be in the server project or the client project... any suggestions?

\$\endgroup\$
  • \$\begingroup\$ Do you intend to make the app available to your players? Or you keep the server app for you and let your players connect to your server and pay you money to use them? \$\endgroup\$ – Vaillancourt Mar 19 at 16:38
0
\$\begingroup\$

In general I would suggest, do what makes sense for you and your project, if that works, then doesn't really matter if it's "correct" or "wrong". If it doesn't work, then it's a learning experience.

In the case of an online game, it's always tricky to decide what belongs on the client and what on the server. I would say it depends from game to game. One idea is to have everything on the server, and clients only handle input. But that could create problems on big games, as the server might struggle with enough amount of players. This way however you can minimise cheating.

Another idea is to handle everything on the client, and send only the state of "shared" objects to the server. This is really light on the server, but what if a player tampers with the sent data?

My advice? Pick something in-between, depending what you envision for your project. If it works, good. If it doesn't, start altering it until it does.

\$\endgroup\$
0
\$\begingroup\$

your server can be any java program that is accepting connections ( UDP or TCP ), this server should have a list of all connected clients, and should manage if they send data packages to the client and how can process them. That means the server is the one that is processing all the game ( or the server is the game itself ), when the server receives certain package it will broadcast instructions on how the clients must behave... for example:

we have a server with 4 players,

1.- a client 2 send a message to server like ( move_on_x:2 ) 2.- server receive this message and check whether the player 2 have free space to move 2 pixels on X coordinate, if so then the server broadcast a message to all clients saying player2 cordinate is increased by two, that way all 4 clients will see that the player 2 moved 2 pixels on X axis.

and so on, there should be many messages, like jump, die, attack, decrease hp, etc, etc.

this is just one approach. all multiplayers must have some connection handling to check what happens if the player log in into the server, what happens when the connections is suddenly broken, etc, etc.

they are also diferent arquitectures for online games like p2p, client-server, etc,

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.