I am working on a game in which several players must play at the same time. This is a game 2D, and all characters must see each other on the screen. As in the game, now all devices simply publish and select each other coordinateson the server. This is accomplished by running in threads:
public void StartCoordinatorFetcherThread(final Sprite Object)
{
Thread CoordinateStarter = new Thread()
{
public void run()
{
while(true)
{
Object.testing = Object.InternetObject.GetMessages();
try {
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
CoordinateStarter.start();
}
public void StartCoordinatorPosterThread(final Sprite Object)
{
Thread CoordinatePoster = new Thread()
{
public void run()
{
while(true)
{
Object.InternetObject.PostCoordinates(Object.x,Object.y);
try {
Thread.sleep(20);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
};
CoordinatePoster.start();
}
Anyway, I would like the characters to move more smoothly, as it might be a bit of "laggy"doing it like this. Does anyone have an idea on how I can achieve this?
Maybe I should have a type of coordinate stack that pushes coordinates to it all the time, and then gives values as the game starts?
Any help would be greatly appreciated.
Hello!
source
share