Jump to content

  • Log In with Google      Sign In   
  • Create Account

Mr C

Member Since 04 Jan 2007
Offline Last Active Private

Posts I've Made

In Topic: C#/XNA socket programming question

15 March 2013 - 12:59 PM

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.

I was wondering, since UDP is connection-less how do you store new connections? I haven't found a clear example of this. With TCP there is a connection made which you could store in a struct and/or put into a list easily.


In Topic: C#/XNA socket programming question

15 March 2013 - 12:51 PM

Thank you both for your replies, I will add the fixes and see what I end up with. Although TCP might be "easier" for this, my Prof. wants me to use UDP. Sadly I am at his mercy :) Thanks again.


In Topic: I feel really dumb, but I am stuck on this (changing direction of a sprite)

25 April 2010 - 09:43 AM

Turns out my base issue was having may variables for certain things in the wrong place. Now it works, at least as far as back and fourth bouncing (other issues present but I can deal)

I had re-written the code with
float v_x = 5;
float v_y = 0;

but had put them before the part dealing with the movement, thus putting them inside of a loop, so they where constantly being made and redefined. I moved them to outside of the loop and things work now.

I did learn a lot doing this though, and thanks for pointing me in the right direction as far as the math itself.

In Topic: I feel really dumb, but I am stuck on this (changing direction of a sprite)

23 April 2010 - 10:38 PM

Quote:
Original post by Litheon
I think you are looking for 2D Vector Reflection. :)


If only I understood what any of that meant...

In Topic: A good sprite resource I found

22 April 2010 - 12:03 PM

Quote:
Original post by OrangyTang
I'm not sure I understand your definition of "free to use" sprites. These all seem to be ripped from various commercial games of some kind.


Sorry, I realized they where rips at a later point. But for learning/hobby they should be fine. Apologies for not reading it carefully. I was thinking these would be good for somebody learning who does not have an artist/ability to make sprites. I would think for a commercial release you would want your own images anyways.


PARTNERS