Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualXanather

Posted 15 March 2013 - 01:50 AM

From past experience I don't think there is a easy way to getting actual keyboard char presses from the keyboard. Last time I successfully achieved it on XNA I had to use unmanaged code (PInvoke) etc... However, the Keyboard.GetState() is fast enough if you call it at the beginning of each tick/update since its as fast as the game is simulating.

 

Anyway I'm guessing your question is how to make two sprites move on the screen, 1 sprite per player? Your server will need a list to store all clients that connect, you will also need to remember the IP for each client as a way as separating up different clients (or you could just use TCP which I think would be easier for beginning networking).

Then you need to do all these required things:
- Handle disbatching of new client connections (add them to the list), which then means...

- Once a client connects you need to send data to all other currently connected clients to indicate that someone has connected (so the existing clients can add the new player to their list aswell).

- Handle the disconnections/time outs of connections, and do the same as the point above, but to remove clients from lists.

- Handle receiving messages, and then relaying the messages to all connected clients.


#1Xanather

Posted 15 March 2013 - 01:49 AM

From past experience I don't think there is a easy way to getting actual keyboard char presses from the keyboard. Last time I successfully achieved it on XNA I had to use unmanaged code (PInvoke) etc... However, the Keyboard.GetState() is fast enough if you call it at the beginning of each tick/update since its as fast as the game is simulating.

 

Anyway I'm guessing your question is how to make two sprites move on the screen, 1 sprite per player? Your server will need a list to store all clients that connect, you will also need to remember the IP for each client as a way as separating up different clients (or you could just use TCP which I think would be easier for beginning networking).

Then you need to do all these required things:
- Handle disbatching of new client connections (add them to the list), which then means...

- Once a client connects you need to send data to all other currently connected clients to indicate that someone has connected (so the existing clients can add the new player to their list aswell).

- Handle the disconnections/time outs of connections, and do the same as the point above, but to remove clients from lists.

- Handle receiving messages, and then relaying the messages to all connected clients.


PARTNERS