开发者

Java client and server problems

开发者 https://www.devze.com 2022-12-13 13:26 出处:网络
I\'ve editted this post based on recommendation by a fellow user. My specific problems are as so: Curre开发者_如何学编程ntly when I run Server.java, it loads up a map with a player on it, you cannot

I've editted this post based on recommendation by a fellow user.

My specific problems are as so:

Curre开发者_如何学编程ntly when I run Server.java, it loads up a map with a player on it, you cannot move the player which is how I intended, it simple creates a new "runGame".

The idea is when I run Client.java, it enables the player to move around the map, by creating a new Craft object, as it is now, for some reason it creates another map with the player on it (two running now) and neither of which has movement.

I am not sure how to explain it further, what I would like to know is how would someone go about creating a server and client that opens a background, and adds an object that is moveable via keys but only when a client has connected to the server?

I hope this is worded better than my last attempt.

thank you.


Without looking at the technology specifics, I think stepping back and looking at the overall architecture would be constructive here.

What state needs to be shared ? From the above I guess it's the game board and the state of the two players. So I would put that in one server process. Now the client process (a different instance per player, but the same executable) just needs to connect, make a move, and receive new board information when the other player(s) move.

The server process contains the board, the state of play etc. The clients simply need to be able to reflect that by drawing the board as represented by the server, and handling player inputs. I think you need one server deployable, and one client deployable, with a separate instance per user.

0

精彩评论

暂无评论...
验证码 换一张
取 消