Real time game development

android, java, libgdx, real-time

Solution

For real time, no need to setup your own server. Just use one of the public time server. Download NtpMessage.java and SntpClient.java from ntp site. Then run SntpClient.java with a ntp port. e.g.

java SntpClient 0.pool.ntp.org

You can use the code of SntpClient class and tweak if you need to.

When user gets out of game (pause state), get the time from ntp and save it. Once the user launches your game, get the time again and compare.

Problem

I want to develop a real time game for Android with libgdx. I need to update some variables even dough the game is not running. For example I want the money to be increased 10 credits per hour (real life hour) so that you can go out of the game and come back an hour later and get that money anyway. How can I do that? Thanks

Original source