I am currently developing a game that includes a server and some clients. Currently, the server does its work based on user input then draws the image the clients should see and sends it. Unfortunately, the server's time is taken up almost exclusively by the drawing and encoding. Is there a better way for me to design this?

  • 3
    \$\begingroup\$ You need to provide a lot more detail in order to get useful answers. What is being drawn, what user inputs, what type of encoding, and why the server needs to do the work. \$\endgroup\$ – Seth Battin Nov 1 '12 at 4:03

OK, the obvious answers would be:

  1. Don't do drawing on the server. Just have the server tell the client what it needs to draw and let the client handle the actual drawing.

  2. Have the client keep track of the information it's previously received, so that the server only needs to send it a list of changes rather than sending everything again.

  3. Have the client predict (as far as possible) what will change based on the player's actions, so that the server only needs to send it any changes the client doesn't already know about (such as those caused by actions of other players).

Yeah, I know that's not very specific, but neither is your question. If there's something in particular that you'd like more detail about, you can comment or edit your question to tell us what it is.

  • \$\begingroup\$ #3 is not really doable, #2 only helps if I could implement #1. How could I make #1 work if there are 100s of different images that would be used in combining and the client has a very limited storage (a phone)? \$\endgroup\$ – bear96 Nov 1 '12 at 2:47
  • 1
    \$\begingroup\$ Why not use a sprite sheet & have the server decide which sprite to use? \$\endgroup\$ – thedeadlybutter Nov 1 '12 at 3:59
  • 1
    \$\begingroup\$ +1 for 'not very specific, but neither is your question'. He's right, @bear96, improve your question. \$\endgroup\$ – Seth Battin Nov 1 '12 at 4:10
  • \$\begingroup\$ @bear96: 100s of images doesn't sound that bad, even for a phone, unless those images are huge. To minimize overhead, thedeadlybutter's suggestion of using a sprite sheet sounds like a good idea. \$\endgroup\$ – Ilmari Karonen Nov 1 '12 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.