Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualRacoonacoon

Posted 15 March 2013 - 05:08 AM

The end goal of my project is to have two sprites moving around the screen, one separate clients controlled by a server. Right now, I just want my server to tell me which key I am sending it. As of now, all I get is:

 
Received a broadcast from 192.168.x.xxx:59145
Message: NONE

 

I just realized this. My derp.

You have a logical error in this if statement:

if (!keyboardState.IsKeyDown(Keys.W) || !keyboardState.IsKeyDown(Keys.A) || !keyboardState.IsKeyDown(Keys.S) || !keyboardState.IsKeyDown(Keys.D))

 

You are saying, if the W is not down or A is not down or S is not down or D is not down, then say we are not moving. You likely want this to be AND. If W And A And S And D are not down THEN send None. As it is now you will have to press WASD all at once to get something other than NONE to be sent.

 

 

The main problem though:

KeyboardState keyboardState = new KeyboardState();

should be

KeyboardState keyboardState = Keyboard.GetState();


#4Racoonacoon

Posted 15 March 2013 - 05:06 AM

The end goal of my project is to have two sprites moving around the screen, one separate clients controlled by a server. Right now, I just want my server to tell me which key I am sending it. As of now, all I get is:

 
Received a broadcast from 192.168.x.xxx:59145
Message: NONE

 

I just realized this. My derp.

You have a logical error in this if statement:

if (!keyboardState.IsKeyDown(Keys.W) || !keyboardState.IsKeyDown(Keys.A) || !keyboardState.IsKeyDown(Keys.S) || !keyboardState.IsKeyDown(Keys.D))

 

You are saying, if the W is not down or A is not down or S is not down or D is not down, then say we are not moving. You likely want this to be AND. If W And A And S And D are not down THEN send None. As it is now you will have to press WASD all at once to get something other than NONE to be sent.

 

 

Also:

KeyboardState keyboardState = new KeyboardState();

should be

KeyboardState keyboardState = Keyboard.GetState();


#3Racoonacoon

Posted 15 March 2013 - 05:01 AM

The end goal of my project is to have two sprites moving around the screen, one separate clients controlled by a server. Right now, I just want my server to tell me which key I am sending it. As of now, all I get is:

 
Received a broadcast from 192.168.x.xxx:59145
Message: NONE

 

I just realized this. My derp.

You have a logical error in this if statement:

if (!keyboardState.IsKeyDown(Keys.W) || !keyboardState.IsKeyDown(Keys.A) || !keyboardState.IsKeyDown(Keys.S) || !keyboardState.IsKeyDown(Keys.D))

 

You are saying, if the W is not down or A is not down or S is not down or D is not down, then say we are not moving. You likely want this to be AND. If W And A And S And D are not down THEN send None. As it is now you will have to press WASD all at once to get something other than NONE to be sent.


#2Racoonacoon

Posted 15 March 2013 - 05:01 AM


 

The end goal of my project is to have two sprites moving around the screen, one separate clients controlled by a server. Right now, I just want my server to tell me which key I am sending it. As of now, all I get is:

 
Received a broadcast from 192.168.x.xxx:59145
Message: NONE

 

I just realized this. My derp.

You have a logical error in this if statement:

if (!keyboardState.IsKeyDown(Keys.W) || !keyboardState.IsKeyDown(Keys.A) || !keyboardState.IsKeyDown(Keys.S) || !keyboardState.IsKeyDown(Keys.D))

 

You are saying, if the W is not down or A is not down or S is not down or D is not down, then say we are not moving. You likely want this to be AND. If W And A And S And D are not down THEN send None. As it is now you will have to press WASD all at once to get something other than NONE to be sent.


#1Racoonacoon

Posted 15 March 2013 - 05:00 AM

The end goal of my project is to have two sprites moving around the screen, one separate clients controlled by a server. Right now, I just want my server to tell me which key I am sending it. As of now, all I get is:

 
Received a broadcast from 192.168.x.xxx:59145
Message: NONE

 

I just realized this. My derp.

You have a logical error in this if statement:

if (!keyboardState.IsKeyDown(Keys.W) || !keyboardState.IsKeyDown(Keys.A) || !keyboardState.IsKeyDown(Keys.S) || !keyboardState.IsKeyDown(Keys.D))

 

You are saying, if the W is not down or A is not down or S is not down or D is not down, then say we are not moving. You likely want this to be AND. If W And A And S And D are not down THEN send None. As it is now you will have to press WASD all at once to get something other than NONE to be sent.


PARTNERS