server communication and time management

Get help using Construct 2

Post » Wed Aug 15, 2012 11:06 pm

Status:
I have a game that communicates with server from time to time via ajax.
I need the game to know all in every tick, what is the server time.

What I tried:
1) I tried sending server time to game, set a global variable "now" to this value, and in every tick add dt to "now" with no luck, because when game goes out of focus, this will break (c2 pauses)

2) I tried messing with wallclocktime, sent server time to game, set a global variable "server_time" to this value minus current wallclocktime on receive and every tick set a "now" global variable to "server_time" + wallclocktime. My logic tells me this _should_ work, but it doesnt, every time I get new current time from server, "now" goes back around 10 - 20 seconds. why?

any ideas would be greatly appreciated.ranma2012-08-16 00:19:08
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Return to How do I....?

Who is online

Users browsing this forum: emoticon, KeetonCat, makkancs, Matthew de and 28 guests