views:

74

answers:

1

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

My specific problems are as so:

Currently 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.

+1  A: 

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.

Brian Agnew
Thank you for the quick reply. You are correct, the board and the location of each player needs to be shared between clients so when one moves the other see's it happen. If I understand you correctly do you mean put everything into the server, the board + current locations of the players, and have the client simply contain the setLoc methods, the keylistener methods and connect to the server?
Craig Jones
That would seem a good first approach, yes
Brian Agnew