Wednesday, April 20, 2011

Update on the Multiplayer game

Im going to try to post smaller posts more often instead of posting alot of content, really fast (and then getting burnt out, and not posting for a week or two) (which is what ive been doing, heh..)

Ive had alot of progress lately. The game no longer has (as bad of) lag issues.
This is because I am sending the objects velocity, instead of the position. It really helps a lot because instead of sending, for example, 200 object's positions, every frame (40 x a second). I only need to send the velocity of the object once, and the client will take care of the future physics updates. 

I also made it so that each client uses a delta time value in the physics updates. I get delta time by subtracting the previous frame's time from the current time. Something like:

Happens every frame:

import time # except this

previous_time = current_time # sets the previous time before we get the new current time
current_time = time.time() # get the current time
delta_time = current_time -= previous_time # get delta time


I then use the delta_time in calculating current position of objects.
This means that, even if one client has a wooden computer, from 1980, that requires a refueling of coal every 30 minutes. It will still have (in most cases) the same display as the kid down the street using his dads new super duper, high tech, state of the art, mega 2000X computer. 
The point is, no matter the frame rate, the computers will have the same basic visual output.

1 comment:

  1. I have to feed the hamster and get get him back onto the wheel in my wooden computer every 30 minutes, so I'm glad you've solved this problem!