DirectInput multiplayer game problem

Started by
3 comments, last by Paul7 20 years ago
Am currently making a multiplayer game using directPlay. When a player moves using the arrow keys a message is sent to the server which forwards this message to all other player telling them the new position of the player. When the other players receive this message the player model of the other player is moved by the required amount and the screen rerendered. This all worked fine when using windows api to handle keyboard input. I then needed to use diretInput so as to be able to have multiple key presses and smoother results. After doing this if one player moves around none of the others can move while that player has the keys pressed. When they stop moving the first player to press the keys can move and no one else can. Could it be to do with the cooperative level of directinput, ive currently got it set to : SetCooperativeLevel(hWnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE); Does anyone else have any suggestions on how to resolve this problem? Thanks [edited by - Paul7 on April 3, 2004 3:06:50 PM]
Advertisement
DirectInput is completely independent of DirectPlay, so using it can''t possibly be the source of the problem. This sounds like a network code problem. Like you are perhaps, flooding the server.
.
yeah i realise that they`re independant of each other. Dont no how can be flooding the server, all i`m sending to it is the players position (a vector) and it works fine when using windows api keyboard response. Does using directinput cause a lot more messages to be sent to the server? Dont see y it wouldnt be able to cope with it though if thats the case? If it was that is there any way to reduce the number of messages sent?
Depends upon how you were using win32 to get keyboard info. If you were using WM_CHAR messages, those only occcur at a limited rate, whereas with DirectInput the key input is asynchronous and if you are sending a message to the server everytime the key is seen down, well, you can see how you could end up flooding the server.
.
Yeah I see what you mean now. Have fixed the problem by only calling the direct input function say 50 times a second, or something like that. It works fine now, thanks alot.

This topic is closed to new replies.

Advertisement